2020-06-16 15:10:02 +08:00
|
|
|
*** Settings ***
|
2020-06-16 18:13:05 +08:00
|
|
|
Test Teardown DeletePolicyAndObjectAndProfile ${policyIds} ${objectIds} ${profiles}
|
2020-06-16 15:10:02 +08:00
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
|
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
2020-06-18 16:29:17 +08:00
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Object.robot
|
2020-06-24 17:37:09 +08:00
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Log.robot
|
2020-06-16 16:52:32 +08:00
|
|
|
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
|
2020-06-18 16:29:17 +08:00
|
|
|
Library json
|
2020-06-28 14:10:24 +08:00
|
|
|
Library DateTime
|
2020-06-16 18:13:05 +08:00
|
|
|
*** Variables ***
|
2020-06-18 16:29:17 +08:00
|
|
|
@{policyIds}
|
2020-06-16 18:13:05 +08:00
|
|
|
@{profiles}
|
2020-06-16 15:10:02 +08:00
|
|
|
*** Test Cases ***
|
|
|
|
|
Policy-Get-v1-00001
|
|
|
|
|
${policy} Create Dictionary policyType=tsg_security action=deny
|
|
|
|
|
... pageNo=1 pageSize=10
|
|
|
|
|
${rescode} ${response} QueryPolicies ${policy} v1
|
|
|
|
|
${policyIds} Create List
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Log ${rescode} ${response}
|
|
|
|
|
Policy-Get-v2-00001
|
|
|
|
|
${policy} Create Dictionary policyType=tsg_security action=deny
|
|
|
|
|
... pageNo=1 pageSize=10
|
|
|
|
|
${rescode} ${response} QueryPolicies ${policy} v2
|
|
|
|
|
${policyIds} Create List
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Log ${rescode} ${response}
|
|
|
|
|
Policy-Post-v1-00001
|
|
|
|
|
${policy} Create Dictionary policyId=1 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName1 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1 effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v1
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00001
|
|
|
|
|
${policy} Create Dictionary policyId=1 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName1 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1 effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v1-00002
|
|
|
|
|
${policy} Create Dictionary policyId=1 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName1 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1 effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
|
|
|
|
|
${policy1} Create Dictionary policyId=2 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName2 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
|
|
|
|
|
${policy2} Create Dictionary policyId=3 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName3 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=0
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
@{policyList} Create List ${policy} ${policy1} ${policy2}
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policyList} v1
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00002
|
|
|
|
|
${policy} Create Dictionary policyId=1 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName1 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1 effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
|
|
|
|
|
${policy1} Create Dictionary policyId=2 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName2 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=1
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
|
|
|
|
|
${policy2} Create Dictionary policyId=3 policyType=tsg_security
|
|
|
|
|
... policyName=wx-policyName3 action=allow doBlacklist=0
|
|
|
|
|
... doLog=0 isValid=0
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
@{policyList} Create List ${policy} ${policy1} ${policy2}
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policyList} v2
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v1-00003
|
|
|
|
|
Comment 创建fqdn
|
|
|
|
|
${objectDict} Create Dictionary objectType=fqdn isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId}
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_SecurityPolicy-v1-00003 policyType=tsg_security
|
|
|
|
|
... policyDesc=autotest userTags=
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"SSL","method":"drop"}
|
|
|
|
|
... referenceObject=${objectId}|TSG_FIELD_SSL_CN&TSG_FIELD_SSL_SAN
|
|
|
|
|
... isValid=${1} appObjectIdArray=3
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v1
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00004
|
|
|
|
|
#${testClentID} ${testClentSubID}
|
|
|
|
|
Comment 创建fqdn
|
|
|
|
|
${objectDict} Create Dictionary objectType=fqdn isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId}
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_SecurityPolicy-v2-00004 policyType=tsg_security
|
|
|
|
|
... policyDesc=autotest
|
|
|
|
|
... action=deny #effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"SSL","method":"drop"}
|
|
|
|
|
... filterList=${objectId}:TSG_FIELD_SSL_CN
|
|
|
|
|
... isValid=${1} appIdObjects=3
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00005
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId2} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId2},${objectIds}
|
|
|
|
|
Log To Console Create url Object
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_SecurityPolicy-v2-00005 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId2}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
2020-06-16 16:52:32 +08:00
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00006
|
|
|
|
|
[Tags] reflection
|
|
|
|
|
${caseName} set variable WX_ActiveDefencePolicy-Reflection-V2-00006
|
|
|
|
|
${target_ip} set variable 10.3.22.139
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
2020-06-16 18:13:05 +08:00
|
|
|
${response} BasePostRequest /v1/policy/profile/reflector body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","addrType":4,"ipList":["10.3.22.11"],"reflectorType":"dns","isValid":1,"profileDesc":"autotest"}]}
|
2020-06-16 16:52:32 +08:00
|
|
|
${reflector_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
2020-06-16 18:13:05 +08:00
|
|
|
${response} BasePostRequest /v1/policy/profile/reflector/payload body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","reflectorType":"dns","payload":"zasBAAABAAAAAAAABHRlc3QDY29tAAD/AAE=","isValid":1,"profileDesc":""}]}
|
2020-06-16 16:52:32 +08:00
|
|
|
#${response} BasePostRequest /policy/profile/reflector/payload body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","reflectorPayload":"dns","payload":"zasBAAABAAAAAAAABHRlc3QDY29tAAD/AAE=","isValid":1,"profileDesc":""}]}
|
|
|
|
|
${payload_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
Comment 创建策略reflection
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
... userRegion={"method":"reflection","reflector_type":"DNS","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"payload_profile_id":${payload_profile_id},"reflector_profile_id":${reflector_profile_id}}
|
|
|
|
|
... isValid=1
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policyDict} v2
|
2020-06-16 18:13:05 +08:00
|
|
|
${profile} Create Dictionary typeUrl=reflector profileIds=${reflector_profile_id}
|
|
|
|
|
${profile1} Create Dictionary typeUrl=reflector/payload profileIds=${payload_profile_id}
|
|
|
|
|
Append To List ${profiles} ${profile} ${profile1}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
2020-06-16 19:40:59 +08:00
|
|
|
Log ${rescode} ${policyIds} ${objectIds}
|
|
|
|
|
Policy-Post-v2-00007
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建IP1
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.67|192.168.41.67|0/0
|
|
|
|
|
${rescode} ${objectId2} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId2}
|
|
|
|
|
Log To Console Create IP Object2
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
Comment 创建url1
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*google.com.com
|
|
|
|
|
${rescode} ${objectId4} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId4},${objectIds}
|
|
|
|
|
Log To Console Create url Object4
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00007 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
|
|
|
|
Comment 更新安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_UpdatePolicy-v2-00007 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest policyId=${updatePolicyId}
|
|
|
|
|
... action=monitor
|
|
|
|
|
... userRegion={"protocol":"HTTP","traffic_forward":{"enable":1}}
|
|
|
|
|
... source=${objectId2}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId4}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} UpdatePolicies 1 ${policy} v2 update
|
|
|
|
|
Policy-Post-v2-00008
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00008 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${policy1} Copy Dictionary ${policy} true
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
|
|
|
|
Comment 更新安全策略
|
|
|
|
|
Set To Dictionary ${policy1} policyId=${updatePolicyId}
|
|
|
|
|
${rescode} UpdatePolicies 1 ${policy1} v2 disable
|
|
|
|
|
Policy-Post-v2-00009
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00009 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${0} appIdObjects=2
|
|
|
|
|
${policy1} Copy Dictionary ${policy} true
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
|
|
|
|
Comment 更新安全策略
|
|
|
|
|
Set To Dictionary ${policy1} policyId=${updatePolicyId}
|
2020-06-18 16:29:17 +08:00
|
|
|
${rescode} UpdatePolicies 1 ${policy1} v2 enable
|
|
|
|
|
Policy-Post-v2-00010
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00010 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${0} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
|
|
|
|
Comment 更新安全策略
|
|
|
|
|
${policy} Create Dictionary policyId=${updatePolicyId}
|
|
|
|
|
${rescode} UpdatePolicies 1 ${policy} v2 enable
|
|
|
|
|
Policy-Post-v2-00011
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
|
|
|
|
Comment 更新安全策略
|
|
|
|
|
${policy} Create Dictionary policyId=${updatePolicyId}
|
|
|
|
|
${rescode} UpdatePolicies 1 ${policy} v2 disable
|
|
|
|
|
Policy-Post-v1-00012
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObjects ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object
|
|
|
|
|
Comment 更新IP
|
|
|
|
|
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
|
|
|
|
|
${rescode} UpdateObjects ${1} ${objectDict} disable
|
|
|
|
|
Log To Console Create IP Object
|
|
|
|
|
Policy-Post-v1-00013
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${0}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObjects ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object
|
|
|
|
|
${params} Create Dictionary objectId=${objectId1} itemType=ip
|
|
|
|
|
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
|
|
|
|
|
Log To Console ${itemIds}
|
|
|
|
|
Comment 更新IP
|
2020-06-23 18:15:03 +08:00
|
|
|
FOR ${item} IN @{itemList}
|
|
|
|
|
Set To Dictionary ${item} clientIp1 192.168.41.67
|
|
|
|
|
Set To Dictionary ${item} clientIp2 192.168.41.67
|
|
|
|
|
Remove From Dictionary ${item} isInitialize
|
|
|
|
|
Set To Dictionary ${item} serverIp1 192.168.41.68
|
|
|
|
|
Set To Dictionary ${item} serverIp2 192.168.41.68
|
2020-06-18 16:29:17 +08:00
|
|
|
END
|
|
|
|
|
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
|
|
|
|
|
... updateItemList=${itemList}
|
|
|
|
|
${rescode} UpdateObjects ${1} ${objectDict} update
|
|
|
|
|
Log To Console Create IP Object
|
|
|
|
|
Policy-Post-v1-00014
|
|
|
|
|
Comment 创建urls
|
|
|
|
|
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,
|
|
|
|
|
${objectDict2} Create Dictionary objectType=url isValid=${1} addItemList=*google.com
|
|
|
|
|
${objectDict} Create List ${objectDict1} ${objectDict2}
|
|
|
|
|
${rescode} ${objectIds} AddObjects ${1} ${objectDict}
|
|
|
|
|
Policy-Post-v1-00015
|
|
|
|
|
Comment 创建urls
|
|
|
|
|
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,*google.com
|
|
|
|
|
${rescode} ${objectIds} AddObjects ${1} ${objectDict1}
|
|
|
|
|
${params} Create Dictionary objectId=${objectIds} itemType=url
|
|
|
|
|
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
|
|
|
|
|
Log To Console ${itemIds}
|
|
|
|
|
Comment 修改urls
|
|
|
|
|
${updateList} Create List *baidu.com* *baidu1.com*
|
|
|
|
|
Set To Dictionary ${itemList}[0] keywordArray ${updateList}
|
|
|
|
|
${objectDict} Create Dictionary objectId=${objectIds} objectType=url
|
|
|
|
|
... addItemList=putty.com
|
|
|
|
|
... updateItemList=${itemList}[0]
|
|
|
|
|
... deleteItemIds=${itemIds}[1]
|
2020-06-18 18:40:39 +08:00
|
|
|
${rescode} UpdateObjects ${1} ${objectDict} update
|
|
|
|
|
Policy-Delete-v1-00016
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
Comment 删除安全策略
|
2020-06-23 18:15:03 +08:00
|
|
|
${rescode} DeletePolicy1 ${policyIds[0]['policyIds']} tsg_security
|
2020-06-18 18:40:39 +08:00
|
|
|
${policyIds} Create List
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
Policy-Delete-v1-00017
|
|
|
|
|
Comment 创建IP
|
|
|
|
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
|
|
|
|
... isInitialize=0
|
|
|
|
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
|
|
|
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId1}
|
|
|
|
|
Log To Console Create IP Object1
|
|
|
|
|
Comment 创建url
|
|
|
|
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
|
|
|
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
|
|
|
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
|
|
|
|
Log To Console Create url Object3
|
|
|
|
|
|
|
|
|
|
Comment 创建安全策略
|
|
|
|
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
|
|
|
|
... policyDesc=wx-autotest
|
|
|
|
|
... action=deny effectiveRange={}
|
|
|
|
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
|
|
|
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
|
|
|
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
|
|
|
|
... isValid=${1} appIdObjects=2
|
|
|
|
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
|
|
|
|
Log ${rescode}
|
|
|
|
|
Comment 删除安全策略
|
|
|
|
|
${rescode} DeletePolicies ${policyIds}
|
|
|
|
|
${policyIds} Create List
|
2020-06-19 19:13:50 +08:00
|
|
|
Log ${rescode}
|
|
|
|
|
Policy-Import-v1-00018
|
|
|
|
|
Comment 导入json
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
2020-06-29 10:32:36 +08:00
|
|
|
${rescode} ImportPolicy uploadFiles tsg_security_imp.json tsg_security
|
2020-06-19 19:13:50 +08:00
|
|
|
Policy-Export-v1-00019
|
|
|
|
|
Comment 导 出json
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${response} ExportPolicy tsg_security ${EMPTY} ${EMPTY}
|
2020-06-23 18:15:03 +08:00
|
|
|
WriteFile downloads download.json ${response}
|
|
|
|
|
Policy-Verify-v1-00020
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 创建对象
|
|
|
|
|
${ipValue} Create Dictionary clientIp=192.168.41.67 clientPort=${1} serverIp=192.168.41.67 serverPort=${1}
|
|
|
|
|
... addrType=${4} protocol=${6}
|
|
|
|
|
${ipObj} Create Dictionary attributeType=ip tableName=TSG_OBJ_IP_ADDR protocol=HTTP attributeName=ip
|
|
|
|
|
... attributeValue=${ipValue}
|
|
|
|
|
${stringValue} Create Dictionary string=*baidu.com
|
|
|
|
|
${stringObj} Create Dictionary attributeType=string tableName=TSG_OBJ_URL protocol=HTTP attributeName=url
|
|
|
|
|
... attributeValue=${stringValue}
|
|
|
|
|
${appIdValue} Create Dictionary string=http.
|
|
|
|
|
${appIdObj} Create Dictionary attributeType=string protocol=HTTP attributeName=app_id
|
|
|
|
|
... attributeValue=${appIdValue}
|
|
|
|
|
${attributes} Create List ${ipObj} ${stringObj} ${appIdObj}
|
|
|
|
|
${verifySession} Create Dictionary attributes=${attributes}
|
|
|
|
|
${verifyList} Create Dictionary policyType=tsg_security verifySession=${verifySession}
|
|
|
|
|
${rescode} ${resData} VerifyPolicies ${verifyList}
|
|
|
|
|
Policy-Verify-v1-00021
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 创建对象
|
|
|
|
|
${ipObj} Create Dictionary attributeType=ip tableName=TSG_OBJ_IP_ADDR protocol=HTTP attributeName=ip
|
|
|
|
|
... attributeValue={"clientIp":"192.168.41.67","clientPort":1,"serverIp":"192.168.41.67","serverPort":1,"addrType":4,"protocol":6}
|
|
|
|
|
${stringValue} Create Dictionary string=*baidu.com
|
|
|
|
|
${stringObj} Create Dictionary attributeType=string tableName=TSG_OBJ_URL protocol=HTTP attributeName=url
|
|
|
|
|
... attributeValue=${stringValue}
|
|
|
|
|
${appIdValue} Create Dictionary string=http.
|
|
|
|
|
${appIdObj} Create Dictionary attributeType=string protocol=HTTP attributeName=app_id
|
|
|
|
|
... attributeValue=${appIdValue}
|
|
|
|
|
${attributes} Create List ${ipObj} ${stringObj} ${appIdObj}
|
|
|
|
|
${verifySession} Create Dictionary attributes=${attributes}
|
|
|
|
|
${verifyList} Create Dictionary policyType=tsg_security verifySession=${verifySession}
|
|
|
|
|
${rescode} ${resData} VerifyPolicies ${verifyList}
|
|
|
|
|
Policy-Verify-v1-00022
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 创建对象
|
|
|
|
|
${ipObj} Create Dictionary attributeType=ip tableName=TSG_OBJ_IP_ADDR protocol=HTTP attributeName=ip
|
|
|
|
|
... attributeValue={"clientIp":"192.168.41.67","clientPort":1,"serverIp":"192.168.41.67","serverPort":1,"addrType":4,"protocol":6}
|
|
|
|
|
${stringObj} Create Dictionary attributeType=string tableName=TSG_OBJ_URL protocol=HTTP attributeName=url
|
|
|
|
|
... attributeValue={'string':'*baidu.com'}
|
|
|
|
|
${appIdValue} Create Dictionary string=http.
|
|
|
|
|
${appIdObj} Create Dictionary attributeType=string protocol=HTTP attributeName=app_id
|
|
|
|
|
... attributeValue=${appIdValue}
|
|
|
|
|
${attributes} Create List ${ipObj} ${stringObj} ${appIdObj}
|
|
|
|
|
${verifySession} Create Dictionary attributes=${attributes}
|
|
|
|
|
${verifyList} Create Dictionary policyType=tsg_security verifySession=${verifySession}
|
|
|
|
|
${rescode} ${resData} VerifyPolicies ${verifyList}
|
|
|
|
|
|
|
|
|
|
Policy-Verify-v1-00023
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 创建对象
|
|
|
|
|
${ipObj} Create Dictionary attributeType=ip tableName=TSG_OBJ_IP_ADDR protocol=HTTP attributeName=ip
|
|
|
|
|
... attributeValue=192.168.41.67|1|192.168.41.67|1|4|6
|
|
|
|
|
${stringObj} Create Dictionary attributeType=string tableName=TSG_OBJ_URL protocol=HTTP attributeName=url
|
|
|
|
|
... attributeValue=*baidu.com
|
|
|
|
|
${appIdObj} Create Dictionary attributeType=string protocol=HTTP attributeName=app_id
|
|
|
|
|
... attributeValue=http.
|
|
|
|
|
${signatureObj} Create Dictionary attributeType=signature protocol=HTTP attributeName=req_body
|
|
|
|
|
... attributeValue=Content-Type|application/json
|
|
|
|
|
${attributes} Create List ${ipObj} ${stringObj} ${appIdObj} ${signatureObj}
|
|
|
|
|
${verifySession} Create Dictionary attributes=${attributes}
|
|
|
|
|
${verifyList} Create Dictionary policyType=tsg_security verifySession=${verifySession}
|
2020-06-24 17:37:09 +08:00
|
|
|
${rescode} ${resData} VerifyPolicies ${verifyList}
|
|
|
|
|
Policy-log-v1-00024
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 查询schema
|
|
|
|
|
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
|
|
|
|
|
${queryFieldList} Create List
|
|
|
|
|
FOR ${field} IN @{fields}
|
|
|
|
|
${return} ${doc} Run Keyword And Ignore Error Get From Dictionary ${field} doc
|
|
|
|
|
Continue For Loop If "${return}"=="FAIL"
|
|
|
|
|
${return} ${allow_query} Run Keyword And Ignore Error Get From Dictionary ${doc} allow_query
|
|
|
|
|
Continue For Loop If "${allow_query}"=="false" or "${return}"=="FAIL"
|
|
|
|
|
${fieldDict} Create Dictionary name=${field['name']} type=${field['type']}
|
|
|
|
|
Append To List ${queryFieldList} ${fieldDict}
|
|
|
|
|
END
|
|
|
|
|
Log ${queryFieldList}
|
|
|
|
|
Policy-log-v1-00025
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 查询schema
|
|
|
|
|
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
|
|
|
|
|
|
|
|
|
|
${filters} Get From Dictionary ${schema_query} filters
|
|
|
|
|
Log ${filters}
|
|
|
|
|
Policy-log-v1-00026
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 查询schema
|
|
|
|
|
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
|
2020-06-24 18:07:07 +08:00
|
|
|
Comment 处理schema,构造查询条件
|
|
|
|
|
${params} Create Dictionary pageSize=${10} logType=security_event_log
|
|
|
|
|
... start_common_recv_time=2020-06-01 00:00:00
|
|
|
|
|
... end_common_recv_time=2020-06-24 00:00:00
|
|
|
|
|
... fields=common_log_id|long,http_url|string,common_client_ip|string,common_client_port|int,common_server_ip|string,common_server_port|int
|
|
|
|
|
... conditions=common_server_port|int|in|${80}^${8080}
|
|
|
|
|
... orderBy=common_server_ip|true
|
|
|
|
|
... common_log_ids=162273027957354498
|
|
|
|
|
${resData} QueryLogs ${params} list
|
|
|
|
|
Policy-log-v1-00027
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 查询schema
|
|
|
|
|
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
|
|
|
|
|
Comment 处理schema,构造查询条件
|
2020-06-24 17:37:09 +08:00
|
|
|
${params} Create Dictionary pageSize=${10} logType=security_event_log
|
|
|
|
|
... start_common_recv_time=2020-06-01 00:00:00
|
|
|
|
|
... end_common_recv_time=2020-06-24 00:00:00
|
|
|
|
|
... fields=common_log_id|long,http_url|string,common_client_ip|string,common_client_port|int,common_server_ip|string,common_server_port|int
|
|
|
|
|
... conditions=common_server_port|int|in|${80}^${8080}
|
|
|
|
|
... orderBy=common_server_ip|true
|
2020-06-24 18:07:07 +08:00
|
|
|
... common_log_ids=162273027957354498
|
2020-06-28 14:10:24 +08:00
|
|
|
${resData} QueryLogs ${params} count
|
|
|
|
|
Policy-log-v1-00028
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Comment 查询schema
|
|
|
|
|
${schema_query} ${schema_type} ${default_columns} ${fields} GetLogSchema security_event_log
|
|
|
|
|
Comment 处理schema,构造查询条件
|
|
|
|
|
${params} Create Dictionary pageSize=${10} logType=security_event_log
|
|
|
|
|
... start_common_recv_time=2020-06-01 00:00:00
|
|
|
|
|
... end_common_recv_time=2020-06-24 00:00:00
|
|
|
|
|
... fields=common_log_id|long|ID,http_url|string|地址,common_client_ip|string|客户端IP,common_client_port|int|客户端端口,common_server_ip|string|服务端IP,common_server_port|int|服务端端口
|
|
|
|
|
... conditions=common_server_port|int|in|${80}^${8080}
|
|
|
|
|
... orderBy=common_server_ip|true
|
|
|
|
|
... common_log_ids=162273027957354498
|
2020-06-28 17:35:34 +08:00
|
|
|
${resData} QueryLogs ${params} batch
|
|
|
|
|
Policy-Delete-v1-00029
|
|
|
|
|
Comment 创建urls
|
|
|
|
|
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,
|
|
|
|
|
${objectDict2} Create Dictionary objectType=url isValid=${1} addItemList=*google.com
|
|
|
|
|
${objectDict} Create List ${objectDict1} ${objectDict2}
|
|
|
|
|
${rescode} ${objectIds} AddObjects ${1} ${objectDict}
|
|
|
|
|
${objectIds} Evaluate list(map(int, re.split('[,]', '${objectIds}'))) re
|
|
|
|
|
${rescode} DeleteObjects ${objectIds}
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
Policy-Import-v1-00030
|
|
|
|
|
Comment 导入txt
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${rescode} ImportObject uploadFiles url.txt url ${EMPTY} ${EMPTY}
|
|
|
|
|
Policy-Import-v1-00031
|
|
|
|
|
Comment 导入csv
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${rescode} ImportObject uploadFiles url.csv url ${EMPTY} ${EMPTY}
|
|
|
|
|
Policy-Import-v1-00032
|
|
|
|
|
Comment 导入csv
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${rescode} ImportObject uploadFiles IP.csv ip endpoint ${EMPTY}
|
|
|
|
|
Policy-Export-v1-00032
|
|
|
|
|
Comment 导 出json
|
|
|
|
|
${objectIds} Set Variable ${EMPTY}
|
|
|
|
|
${response} ExportObject ip endpoint ${EMPTY} ${EMPTY}
|