diff options
| author | hebingning <[email protected]> | 2023-10-23 18:38:37 +0800 |
|---|---|---|
| committer | hebingning <[email protected]> | 2023-10-23 18:38:37 +0800 |
| commit | 15ebce06876c066b3f9331333a50f0b01a28043e (patch) | |
| tree | 7accae0571b359a975202929ffea05cf041788e4 | |
| parent | 4082673cc6da7ce41f41750b1c44c43102bfc767 (diff) | |
调整policies新建/修改相关逻辑,适应23.10版本接口修改导致的policies结构修改lts
| -rw-r--r-- | keyword/objects/object.robot | 9 | ||||
| -rw-r--r-- | keyword/policys/policy.robot | 36 | ||||
| -rw-r--r-- | keyword/policys/process_policy_body.robot | 5 | ||||
| -rw-r--r-- | keyword/system/administration/administering_access_tokens.robot | 1 | ||||
| -rw-r--r-- | keyword/system/iplibraries.robot | 9 | ||||
| -rw-r--r-- | keyword/system/schsedules.robot | 1 | ||||
| -rw-r--r-- | keyword/system/tags.robot | 1 | ||||
| -rw-r--r-- | keyword/system/trouble_shooting/packet_capture.robot | 1 | ||||
| -rw-r--r-- | keyword/testin/testin_operation.robot | 1 | ||||
| -rw-r--r-- | keyword/verify/verify.robot | 1 |
10 files changed, 38 insertions, 27 deletions
diff --git a/keyword/objects/object.robot b/keyword/objects/object.robot index ba7cda5..c9125ae 100644 --- a/keyword/objects/object.robot +++ b/keyword/objects/object.robot @@ -634,9 +634,12 @@ ObjectsByTemplate OrangeFilter
[Documentation] filer对象处理,把一个filter的list处理为一个filter
#[Arguments] ${filterList} ${objectList}
- [Arguments] ${objectList}
- ${filter} Create Dictionary filter=${objectList}
- ${list} Create List ${filter}
+ [Arguments] ${objectList}
+ ${filter} Create Dictionary objectList=${objectList}
+ # ${list} Create List ${filter}
+ ${list} Create Dictionary filter=${filter}
+ ${list} Create List ${list}
+ Log To Console ${list}
#${filterList} Append To List ${filter}
[Return] ${list}
GetPortFromPortRange
diff --git a/keyword/policys/policy.robot b/keyword/policys/policy.robot index e3d52b2..d11fb71 100644 --- a/keyword/policys/policy.robot +++ b/keyword/policys/policy.robot @@ -401,6 +401,7 @@ PolilcysByTemplate ${updateStatus} Run Keyword If ${tsgVersion}>=22.06 Run Keyword And Continue On Failure DisablePolicies ${policyTemp} disable
... ELSE Run Keyword And Continue On Failure DisablePolicies ${policyTemp} disable
Log To Console 当前验证已执行完成并关闭策略
+ sleep 3
Run Keyword If "${updateStatus}" != "200" Log DisableError FOR POLICYS
${updateVerifyPolicyId} Run Keyword If "${opAction}"=="add" Set Variable ${policyId}
log ${editPolicyId}
@@ -931,12 +932,12 @@ ExcuteCommand ${returnConnect} ${connect} Run Keyword And Ignore Error Open Connection ${manageIp}
${returnLogin} ${login} Run Keyword And Ignore Error SSHLibrary.Login ${manageUser} ${managePassword}
${return} ${write} Run Keyword And Ignore Error SSHLibrary.Write ${command}
- ${return} ${res} Run Keyword And Ignore Error Read delay=20s
+ ${return} ${res} Run Keyword And Ignore Error Read delay=30s
${returnIsExcute} ${excute} Run Keyword If "${commandRes}"=="Connection reset by peer" Run Keyword And Ignore Error Should Contain Any ${res} ${commandRes} timed out
... ELSE Run Keyword And Ignore Error Should Contain ${res} ${commandRes}
- ${returnIsExcute} Run Keyword If "${returnIsExcute}"=="FAIL" Run Keyword And Continue On Failure Wait Until Keyword Succeeds 5min 30sec RetryCommand ${command} ${commandRes}
+ ${returnIsExcute} Run Keyword If "${returnIsExcute}"=="FAIL" Run Keyword And Continue On Failure Wait Until Keyword Succeeds 5min 50sec RetryCommand ${command} ${commandRes}
... ELSE Set Variable ${returnIsExcute}
Run Keyword If "${logSwitch}"=="1" sleep ${policyLogVerificationSleepSeconds}
... ELSE Log To Console no log verify
@@ -1008,7 +1009,7 @@ RetryCommand ... 因为linux上执行curl命令过于不稳定,将逻辑修改为如果一次不通过,就再次重新尝试两次
[Arguments] ${command} ${commandRes}
Write ${command}
- ${return} ${res} Run Keyword And Ignore Error Read delay=10s
+ ${return} ${res} Run Keyword And Ignore Error Read delay=30s
Should Contain ${res} ${commandRes}
${returnIsExcute} Set Variable PASS
[Return] ${returnIsExcute}
@@ -1342,9 +1343,12 @@ CreatePolicysAndObjects ${destinationList} json.Dumps ${destinationList}
${filterList} json.Dumps ${filterList}
log ${sourceList}
- ${policyJson} Replace String ${policyJson} "source": null "source":${sourceList}
- ${policyJson} Replace String ${policyJson} "destination": null "destination":${destinationList}
- ${policyJson} Replace String ${policyJson} "filterList": null "filterList":${filterList}
+ ${policyJson} Run Keyword If "${tsgVersion}" >= "23.10" Replace String ${policyJson} "source": null "source":{"objectList":${sourceList}}
+ ... ELSE Replace String ${policyJson} "source": null "source":${sourceList}
+ ${policyJson} Run Keyword If "${tsgVersion}" >= "23.10" Replace String ${policyJson} "destination": null "destination":{"objectList":${destinationList}}
+ ... ELSE Replace String ${policyJson} "destination": null "destination":${destinationList}
+ ${policyJson} Run Keyword If "${tsgVersion}" >= "23.10" Replace String ${policyJson} "filterList": null "filterList":${filterList}
+ ... ELSE Replace String ${policyJson} "filterList": null "filterList":${filterList}
log ${policyJson}
#${policyInfo} Get From Dictionary ${policyData} condation
Comment 处理策略数据: "opAction": "add" "returnData": 1 "policyName": "autotest" "policyType": "tsg_security" "action": "allow" "userTags": "" "doBlacklist": 0 "doLog": 1 "policyDesc": "autotest" "effectiveRange": "userRegion": "appIdObjects": "appSelectorObjects": "isValid": 1 "scheduleId":
@@ -1486,7 +1490,7 @@ CreatePolicysAndObjects ${traffic_mirror} = Run Keyword If "${return}"!="FAIL" and "${traffic_mirror}" != "None" Set Variable ${traffic_mirror}
... ELSE Set Variable ""
${traffic_mirror} json.Dumps ${traffic_mirror}
- ${appIdObjectIds} Create List
+ ${appIdObjectIds}= Create List
${return} ${logCapture} Run Keyword And Ignore Error Get From Dictionary ${policyData} logCapture
${logCapture} Run Keyword If "${return}"!="FAIL" Set Variable ${logCapture} ELSE Set Variable ${EMPTY}
${return} ${captureDepth} Run Keyword And Ignore Error Get From Dictionary ${policyData} captureDepth
@@ -1496,22 +1500,27 @@ CreatePolicysAndObjects log ${appIdObjects}
FOR ${key} IN @{appIdObjects}
log ${key}
- ${appObjId} Get From Dictionary ${objprotol} ${key}
+ ${appObjId} Get From Dictionary ${objprotol} ${key}
+ # ${appObjId} Create Dictionary objectId=${appObjId}
+ # ${appObjId} json.Dumps ${appObjId}
+ # Log To Console ${appObjId}
+ ${appObjId} Set Variable {\"objectId\":${appObjId}}
Append To List ${appIdObjectIds} ${appObjId}
+ Log To Console ${appIdObjectIds}
log ${objprotol}
log ${profileIds}
${userRegionStr} Run Keyword If "${method}" == "alert" and ("${profileIds}"=="None" or "${profileIds}"=="${EMPTY}") Set Variable {"method": "${method}","code":${code},"${messageKey}":"${message}"}
- ... ELSE IF "${method}" == "alert" and "${profileIds}"!="None" Set Variable {"method": "${method}","code":${code},"${messageKey}":${profileIds}}
+ ... ELSE IF "${method}" == "alert" and "${profileIds}"!="None" Set Variable {"method": "${method}","code":${code},"${messageKey}":${profileIds},"packet_capture":{"enable":0}}
... ELSE IF "${method}" == "block" and "${key}"=="mail" and "${return}" != "FAIL" Set Variable {"method": "${method}","code":${code},"packet_capture":{"enable":${logCapture},"capture_depth":${captureDepth}}}
- ... ELSE IF "${method}" == "block" and "${key}"=="mail" and "${return}" == "FAIL" Set Variable {"method": "${method}","code":${code}}
+ ... ELSE IF "${method}" == "block" and "${key}"=="mail" and "${return}" == "FAIL" Set Variable {"method": "${method}","code":${code},"packet_capture":{"enable":0}}
... ELSE IF "${method}" == "hijack" or "${method}" == "insert" or "${method}" == "run_script" Set Variable {"method": "${method}","${messageKey}":${profileIds}}
... ELSE IF "${method}" == "redirect" and "${key}"=="http" Set Variable {"method": "${method}","code":${code},"to":"${redirect_to}"}
... ELSE IF "${method}" == "redirect" and "${key}"=="dns" Set Variable {"method": "${method}","resolution":${dnsResolution}}
... ELSE IF "${method}" == "replace" or "${method}" == "edit_element" Set Variable {"method": "${method}","rules":${rules}}
... ELSE IF "${method}" == "rate_limit" and "${return}" == "FAIL" Set Variable {"method": "${method}","bps":${bps},"enforce_direction":"both"}
... ELSE IF "${method}" == "rate_limit" and "${return}" != "FAIL" Set Variable {"method": "${method}","bps":${bps},"packet_capture":{"enable":${logCapture},"capture_depth":${captureDepth}},"enforce_direction":"both"}
- ... ELSE IF "${method}" == "block" and "${key}"!="mail" and "${profileIds}"=="${EMPTY}" and "${returnCode}"!="FAIL" Set Variable {"method": "${method}","code":${code},"${messageKey}":"${message}"}
- ... ELSE IF "${method}" == "block" and "${key}"!="mail" and "${profileIds}"!="${EMPTY}" and "${returnCode}"!="FAIL" Set Variable {"method": "${method}","code":${code},"${messageKey}":${profileIds}}
+ ... ELSE IF "${method}" == "block" and "${key}"!="mail" and "${profileIds}"=="${EMPTY}" and "${returnCode}"!="FAIL" Set Variable {"method": "${method}","code":${code},"${messageKey}":"${message}","packet_capture":{"enable":0}}
+ ... ELSE IF "${method}" == "block" and "${key}"!="mail" and "${profileIds}"!="${EMPTY}" and "${returnCode}"!="FAIL" Set Variable {"method": "${method}","code":${code},"${messageKey}":${profileIds},"packet_capture":{"enable":0}}
... ELSE IF "${method}" == "block" and "${key}"!="mail" and "${profileIds}"=="${EMPTY}" and "${returnCode}"=="FAIL" Set Variable {"method": "${method}"}
... ELSE IF "${action}" == "deny" and "${method}" == "drop" and "${return}" == "FAIL" and "${tsgVersion}" < "23.01" and "${send_tcp_reset}" != "1" Set Variable {"method": "${method}","send_icmp_unreachable":${sendIcmpUnreachable}}
... ELSE IF "${send_tcp_reset}" == "1" and "${tsgVersion}" < "23.01" and "${return}" == "FAIL" Set Variable {"method": "reset","packet_capture":{"enable":0}}
@@ -1534,7 +1543,7 @@ CreatePolicysAndObjects END
# Run Keyword If "${returnAppIdObjects}"!="FAIL" and "${appIdObjects}" != "${EMPTY}" Remove From List ${appIdObjectIds} 0
log ${userRegionStr}
- ${policyJson} = Run Keyword If "${returnAppIdObjects}"!="FAIL" and "${appIdObjects}" != "None" Replace String ${policyJson} "appIdObjects": [null] "appIdObjects": ${appIdObjectIds}
+ ${policyJson} = Run Keyword If "${returnAppIdObjects}"!="FAIL" and "${appIdObjects}" != "None" Replace String ${policyJson} "appIdObjects": [null] "application":{"appIdObjectList":${appIdObjectIds}}
... ELSE Set Variable ${policyJson}
${policyJson} = Replace String ${policyJson} "userRegion": null "userRegion": ${userRegionStr}
@@ -1558,6 +1567,7 @@ CreatePolicysAndObjects ${policyJson} = Run Keyword If "${isEdit}" == "1" and "${returnIsEdit}" == "PASS" and "${editPolicyId}" != "${EMPTY}" Replace String ${policyJson} "policyId": null "policyId": ${editPolicyId}
... ELSE Set Variable ${policyJson}
${policyJson} = Replace String ${policyJson} [null] []
+ ${policyJson} = Replace String ${policyJson} ' ${EMPTY}
log ${policyJson}
${policyJson} json.loads ${policyJson}
log ${policyJson}
diff --git a/keyword/policys/process_policy_body.robot b/keyword/policys/process_policy_body.robot index 0d11ba9..011dae2 100644 --- a/keyword/policys/process_policy_body.robot +++ b/keyword/policys/process_policy_body.robot @@ -80,6 +80,10 @@ PolicyDataOperation ... ELSE Create Dictionary opAction=${opAction} returnData=${returnData} policyList=replace:policyList ${bodyJson} json.Dumps ${dict} ensure_ascii=False ${json} Replace String ${bodyJson} "replace:policyList" ${json} + Log To Console ${json} + ${json} Replace String ${json} "appIdObjects": [163, 109] "application":{"notFlag":0,"appIdObjectList":[{"objectId":109},{"objectId":163}]} + ${json} Replace String ${json} "destination": [] "destination":{"objectList":[]} + # ${json} Replace String ${json} "filterList": [] "application":{"notFlag":0,"appIdObjectList":[{"objectId":109},{"objectId":163}]} Log Policy_Request_Body-${json} [Return] ${json} @@ -277,6 +281,7 @@ ManageObjectV2 AnalysisObjectV2 ${policy} source ${sourceList} AnalysisObjectV2 ${policy} destination ${destinationList} AnalysisObjectV2 ${policy} filterList ${filterList} + ${sourceList} Create Dictionary objectList=${sourceList} Set To Dictionary ${returnDict} source=${sourceList} destination=${destinationList} filterList=${filterList} Log ${policy} diff --git a/keyword/system/administration/administering_access_tokens.robot b/keyword/system/administration/administering_access_tokens.robot index 324ecc3..f40853f 100644 --- a/keyword/system/administration/administering_access_tokens.robot +++ b/keyword/system/administration/administering_access_tokens.robot @@ -4,7 +4,6 @@ Library Collections Library RequestsLibrary Library DateTime Library String -Resource ${EXECDIR}/variable/incoming_common_variable.txt Resource ${EXECDIR}/variable/common_variable.txt Resource ${EXECDIR}/common/common.robot Resource ${EXECDIR}/common/api_request.robot diff --git a/keyword/system/iplibraries.robot b/keyword/system/iplibraries.robot index 269e01b..9ad12df 100644 --- a/keyword/system/iplibraries.robot +++ b/keyword/system/iplibraries.robot @@ -4,14 +4,13 @@ Library Collections Library RequestsLibrary
Library DateTime
Library String
-Resource ${EXECDIR}/variable/incoming_common_variable.txt
Resource ${EXECDIR}/variable/common_variable.txt
Resource ${EXECDIR}/keyword/common/common.robot
Library OperatingSystem
Library ${EXECDIR}/customlib/dict_data.py
Library ${EXECDIR}/customlib/judge_profilelist.py
*** Variables ***
-${iplibrariesUrl} /geolocation/dict
+${iplibrariesUrl} /global/geolocation/dict
${ipLibImportUrl} /geolocation/dict/batch
${EMPTY}
@@ -104,9 +103,9 @@ CreateIplibraries ... ELSE Set Variable ${endIp}
${ipLibraryJson} = Run Keyword If "${return}"!="FAIL" and "${endIp}" != "None" Replace String ${ipLibraryJson} "endIp": "1.1.1.1" "endIp": "${endIp}"
... ELSE Set Variable ${ipLibraryJson}
- Comment 替换vsysid
- ${ipLibraryJson} = Run Keyword If "${vsysId}"!="1" Replace String ${ipLibraryJson} "vsysId": 1 "vsysId": ${vsysId}
- ... ELSE Set Variable ${ipLibraryJson}
+ # Comment 替换vsysid
+ # ${ipLibraryJson} = Run Keyword If "${vsysId}"!="1" Replace String ${ipLibraryJson} "vsysId": 1 "vsysId": ${vsysId}
+ # ... ELSE Set Variable ${ipLibraryJson}
log ${ipLibraryJson}
${response} Run Keyword If "${opAction}"=="add" BasePostRequestForV2 ${iplibrariesUrl} ${ipLibraryJson} ${version}
... ELSE IF "${opAction}"=="update" BaseEditRequestForV2 ${iplibrariesUrl} ${ipLibraryJson} ${version}
diff --git a/keyword/system/schsedules.robot b/keyword/system/schsedules.robot index a888ce6..ea53965 100644 --- a/keyword/system/schsedules.robot +++ b/keyword/system/schsedules.robot @@ -5,7 +5,6 @@ Library Collections Library RequestsLibrary
Library DateTime
Library String
-Resource ${EXECDIR}/variable/incoming_common_variable.txt
Resource ${EXECDIR}/variable/common_variable.txt
Resource ${EXECDIR}/common/common.robot
Resource ${EXECDIR}/common/api_request.robot
diff --git a/keyword/system/tags.robot b/keyword/system/tags.robot index d3a704c..f57b899 100644 --- a/keyword/system/tags.robot +++ b/keyword/system/tags.robot @@ -5,7 +5,6 @@ Library Collections Library RequestsLibrary
Library DateTime
Library String
-Resource ${EXECDIR}/variable/incoming_common_variable.txt
Resource ${EXECDIR}/variable/common_variable.txt
Resource ${EXECDIR}/common/common.robot
Resource ${EXECDIR}/common/api_request.robot
diff --git a/keyword/system/trouble_shooting/packet_capture.robot b/keyword/system/trouble_shooting/packet_capture.robot index d987979..5bced62 100644 --- a/keyword/system/trouble_shooting/packet_capture.robot +++ b/keyword/system/trouble_shooting/packet_capture.robot @@ -4,7 +4,6 @@ Library Collections Library RequestsLibrary Library DateTime Library String -Resource ${EXECDIR}/variable/incoming_common_variable.txt Resource ${EXECDIR}/variable/common_variable.txt Resource ${EXECDIR}/keyword/common/common.robot Resource ${EXECDIR}/keyword/common/api_request.robot diff --git a/keyword/testin/testin_operation.robot b/keyword/testin/testin_operation.robot index 7258a34..6ed95bc 100644 --- a/keyword/testin/testin_operation.robot +++ b/keyword/testin/testin_operation.robot @@ -2,7 +2,6 @@ Library Collections Library String Library RequestsLibrary -Resource ${EXECDIR}/variable/incoming_common_variable.txt Resource ${EXECDIR}/variable/common_variable.txt Library Collections Resource ${EXECDIR}/common/common.robot diff --git a/keyword/verify/verify.robot b/keyword/verify/verify.robot index 59d7ebe..957a255 100644 --- a/keyword/verify/verify.robot +++ b/keyword/verify/verify.robot @@ -1,6 +1,5 @@ *** Settings ***
Resource ${EXECDIR}/comman/command.robot
-Resource ${EXECDIR}/variable/incoming_common_variable.txt
Resource ${EXECDIR}/variable/common_variable.txt
*** Variables ***
${policyIds} ${EMPTY}
|
