diff options
| author | [email protected] <[email protected]> | 2024-04-18 11:36:26 +0630 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2024-04-18 11:36:26 +0630 |
| commit | 5c2c138eac914bfbedafe76a6151415a91967801 (patch) | |
| tree | 9e7921950f560936b002f94b305f523bf301b45f | |
| parent | 462f20054a04dac83845044a34291e948697fa7f (diff) | |
24.04 log校验修改
| -rw-r--r-- | getLog.py | 73 |
1 files changed, 38 insertions, 35 deletions
@@ -25,7 +25,7 @@ class GetLog(): "page_no": 1, "page_size": 20, "source": "security_event", - "fields": None, + "columns": None, "start_time": "", "end_time": "", "filter": "", @@ -36,11 +36,13 @@ class GetLog(): for i in range(ruleNum): policy_id = list(create_policies_ids[i].values())[0] fields = self.get_log_schema(token, "security_event", api_host, vsys_id) - log_condition_dict['fields'] = fields + log_condition_dict['columns'] = fields log_condition_dict['start_time'] = start_time log_condition_dict['end_time'] = end_time log_condition_dict['vsys_id'] = vsys_id log_condition_dict['log_type'] = 'security_event' + log_condition_dict['identifier_name'] = 'security-event-list' + log_condition_dict['execution_mode'] = 'oneshot' # 从conditions中获取object_type判断是否存在subscriberid if len(condition["obj_condition_1"]) > 0 and condition["obj_condition_1"][0]["attribute_name"] == "ATTR_SUBSCRIBER_ID": log_filter = f"subscriber_id= 'test23' AND has(security_rule_list,{policy_id})" @@ -51,6 +53,7 @@ class GetLog(): log_condition_dict['filter'] = log_condition_dict['filter'].replace(f"client_ip={test_pc_ip}", f"client_ip='{test_pc_ip}'") url = api_host + "/v1/log/query" # print(json.dumps(log_condition_dict)) + print(log_condition_dict) response = requests.post(url, headers=headers, json=log_condition_dict, verify=False) assert response.status_code == 200 log_list = json.loads(response.text) @@ -513,40 +516,40 @@ class GetLog(): # if __name__ == '__main__': # ipObject = get_log_by_condition() # time.sleep(3) -if __name__ == '__main__': - api_host = "http://192.168.44.3" - v = verify.Verify() - username = "admin" - password = "admin" - v.encryptPwd(password, api_host) - token = v.login(username, api_host) - l = GetLog() - sc_info = { - 'app_name_1': [ +# if __name__ == '__main__': +# api_host = "http://192.168.44.3" +# v = verify.Verify() +# username = "admin" +# password = "admin" +# v.encryptPwd(password, api_host) +# token = v.login(username, api_host) +# l = GetLog() +# sc_info = { +# 'app_name_1': [ - ], - 'health_check_method': 'none', - 'rule_id': 311524, - 'sf_dest_ip': '2.2.2.57', - 'sf_id': 2096, - 'sf_method': 'vxlan_g', - 'sff_id': 2090, - 'targeted_traffic': 'raw', - 'type': 1 - } - sc_metric = { - 'total_packets': 347, - 'total_packets_sent': 97, - 'total_packets_received': 250, - 'total_bytes': 339823, - 'total_bytes_sent': 5892, - 'total_bytes_received': 333931, - 'total_syn_pkt': 1 -} - assert_key = {} - start_time = "2023-12-11T08:16:46Z" - end_time = "2023-12-11T08:20:31Z" - l.get_sc_metric(token,start_time,end_time,sc_info,sc_metric,api_host) +# ], +# 'health_check_method': 'none', +# 'rule_id': 311524, +# 'sf_dest_ip': '2.2.2.57', +# 'sf_id': 2096, +# 'sf_method': 'vxlan_g', +# 'sff_id': 2090, +# 'targeted_traffic': 'raw', +# 'type': 1 +# } +# sc_metric = { +# 'total_packets': 347, +# 'total_packets_sent': 97, +# 'total_packets_received': 250, +# 'total_bytes': 339823, +# 'total_bytes_sent': 5892, +# 'total_bytes_received': 333931, +# 'total_syn_pkt': 1 +# } +# assert_key = {} +# start_time = "2023-12-11T08:16:46Z" +# end_time = "2023-12-11T08:20:31Z" +# l.get_sc_metric(token,start_time,end_time,sc_info,sc_metric,api_host) # test = GetLog() # log_dict = { # "common_recv_time": "1698299472", |
