@@ -400,11 +400,14 @@ def test_ap_waf_policy_multi_logs(
400
400
src_syslog_yaml = f"{ TEST_DATA } /ap-waf/syslog.yaml"
401
401
src_syslog_yaml_additional = f"{ TEST_DATA } /ap-waf/syslog-1.yaml"
402
402
log_loc = f"/var/log/messages"
403
+ src_log_yaml_escape = f"{ TEST_DATA } /ap-waf/logconf-esc.yaml"
404
+ log_esc_name = create_ap_logconf_from_yaml (kube_apis .custom_objects , src_log_yaml_escape , test_namespace )
403
405
create_items_from_yaml (kube_apis , src_syslog_yaml , test_namespace )
404
406
create_items_from_yaml (kube_apis , src_syslog_yaml_additional , test_namespace )
405
407
syslog_dst1 = f"syslog-svc.{ test_namespace } "
406
408
syslog_dst2 = f"syslog-svc-1.{ test_namespace } "
407
- syslog_pods = kube_apis .v1 .list_namespaced_pod (test_namespace , label_selector = "app in (syslog, syslog-1)" ).items
409
+ syslog_pod = kube_apis .v1 .list_namespaced_pod (test_namespace , label_selector = "app=syslog" ).items
410
+ syslog_esc_pod = kube_apis .v1 .list_namespaced_pod (test_namespace , label_selector = "app=syslog-1" ).items
408
411
print (f"Create waf policy" )
409
412
create_ap_multilog_waf_policy_from_yaml (
410
413
kube_apis .custom_objects ,
@@ -414,7 +417,7 @@ def test_ap_waf_policy_multi_logs(
414
417
True ,
415
418
True ,
416
419
ap_pol_name ,
417
- [log_name , log_name ],
420
+ [log_name , log_esc_name ],
418
421
[f"syslog:server={ syslog_dst1 } :514" ,f"syslog:server={ syslog_dst2 } :514" ]
419
422
)
420
423
wait_before_test ()
@@ -440,27 +443,38 @@ def test_ap_waf_policy_multi_logs(
440
443
headers = {"host" : virtual_server_setup .vs_host },
441
444
)
442
445
print (response .text )
443
- log_contents = [ "" , "" ]
446
+ log_contents = ""
444
447
retry = 0
445
- for i in range (2 ):
446
- while "ASM:attack_type" not in log_contents [i ] and retry <= 30 :
447
- log_contents [i ] = get_file_contents (
448
- kube_apis .v1 , log_loc , syslog_pods [i ].metadata .name , test_namespace
449
- )
450
- retry += 1
451
- wait_before_test (1 )
452
- print (f"Security log not updated, retrying... #{ retry } " )
448
+ while "ASM:attack_type" not in log_contents and retry <= 30 :
449
+ log_contents = get_file_contents (
450
+ kube_apis .v1 , log_loc , syslog_pod [0 ].metadata .name , test_namespace
451
+ )
452
+ retry += 1
453
+ wait_before_test (1 )
454
+ print (log_contents )
455
+ print (f"Security log not updated, retrying... #{ retry } " )
456
+
457
+ log_esc_contents = ""
458
+ retry = 0
459
+ while "attack_type" not in log_esc_contents and retry <= 30 :
460
+ log_esc_contents = get_file_contents (
461
+ kube_apis .v1 , log_loc , syslog_esc_pod [0 ].metadata .name , test_namespace
462
+ )
463
+ retry += 1
464
+ wait_before_test (1 )
465
+ print (log_esc_contents )
466
+ print (f"Security log not updated, retrying... #{ retry } " )
453
467
454
468
delete_policy (kube_apis .custom_objects , "waf-policy" , test_namespace )
455
469
self .restore_default_vs (kube_apis , virtual_server_setup )
456
470
457
471
assert_invalid_responses (response )
458
472
459
- for log_cont in log_contents :
460
- assert f'ASM:attack_type="Non-browser Client,Abuse of Functionality,Cross Site Scripting (XSS) "' in log_cont
461
- assert f'severity="Critical "' in log_cont
462
- assert f'request_status="blocked "' in log_cont
463
- assert f'outcome="REJECTED" ' in log_cont
473
+ assert f'ASM:attack_type="Non-browser Client,Abuse of Functionality,Cross Site Scripting (XSS)"' in log_contents
474
+ assert f'severity="Critical "' in log_contents
475
+ assert f'request_status="blocked "' in log_contents
476
+ assert f'outcome="REJECTED "' in log_contents
477
+ assert f'"my_attack_type": "[Non-browser Client ' in log_esc_contents
464
478
465
479
@pytest .mark .skip_for_nginx_oss
466
480
@pytest .mark .appprotect
0 commit comments