@@ -30,7 +30,7 @@ def eval_snmpv3(fw_obj: SophosFirewall,
3030
3131 for i in range (1 ,3 ):
3232 try :
33- result = fw_obj .get_tag_with_filter (xml_tag = "SNMPv3User" , key = "Username" , value = expected ["Username" ])
33+ result = fw_obj .get_tag_with_filter (xml_tag = "SNMPv3User" , key = "Username" , value = expected ["Username" ], operator = "=" )
3434 except SophosFirewallZeroRecords :
3535 result = None
3636 break
@@ -61,21 +61,25 @@ def eval_snmpv3(fw_obj: SophosFirewall,
6161
6262 # Changes for v22
6363 if result :
64- if result ["Response" ]["@APIVersion" ][:2 ] >= "22" :
64+ if int ( result ["Response" ]["@APIVersion" ][:2 ]) >= 22 :
6565 # Remove Name key since it did not exist pre-v22
6666 actual .pop ("Name" )
67- # Rename "AuthorizedHosts " to "AuthorizedHostsIpv4" in expected
68- expected [ "AuthorizedHostsIpv4 " ] = expected .pop ("AuthorizedHosts " )
67+ # Rename "AuthorizedHostsIpv4 " to "AuthorizedHosts" to in actual
68+ actual [ "AuthorizedHosts " ] = actual .pop ("AuthorizedHostsIpv4 " )
6969 # Convert SendTraps and AcceptQueries from "Enabled/Disabled" to True/False
7070 expected ["SendTraps" ] = "true" if expected ["SendTraps" ] == "Enabled" else "false"
7171 expected ["AcceptQueries" ] = "true" if expected ["AcceptQueries" ] == "Enabled" else "false"
7272
73-
7473 output = []
7574 for key in expected :
7675 status = "AUDIT_PASS"
7776 if key in actual :
78- if not expected [key ] == actual [key ]:
77+ if key == "AuthorizedHosts" :
78+ if not expected [key ].get (fw_obj .region ) == actual [key ]:
79+ status = "AUDIT_FAIL"
80+ result_dict ["audit_result" ] = "FAIL"
81+ result_dict ["fail_ct" ] += 1
82+ elif not expected [key ] == actual [key ]:
7983 status = "AUDIT_FAIL"
8084 result_dict ["audit_result" ] = "FAIL"
8185 result_dict ["fail_ct" ] += 1
@@ -88,7 +92,7 @@ def eval_snmpv3(fw_obj: SophosFirewall,
8892 result_dict ["fail_ct" ] += 1
8993
9094 if key == "AuthorizedHosts" and not actual .get (key ) == "None" and status == "AUDIT_FAIL" :
91- actual_output = '\n ' .join (format_diff (unified_diff (sorted (expected [key ]), sorted (actual .get (key )), n = 1000000000 )))
95+ actual_output = '\n ' .join (format_diff (unified_diff (sorted (expected [key ]. get ( fw_obj . region ) ), sorted (actual .get (key )), n = 1000000000 )))
9296 elif key == "AuthorizedHosts" and not actual .get (key ) == "None" and status == "AUDIT_PASS" :
9397 actual_output = '\n ' .join (actual .get (key ))
9498 else :
@@ -98,7 +102,7 @@ def eval_snmpv3(fw_obj: SophosFirewall,
98102 "SNMPv3" ,
99103 "System > Administration > SNMP" ,
100104 key ,
101- '\n ' .join (expected [key ]) if key == "AuthorizedHosts" else expected [key ],
105+ '\n ' .join (expected [key ]. get ( fw_obj . region ) ) if key == "AuthorizedHosts" else expected [key ],
102106 actual_output ,
103107 html_status (status )
104108 ])
0 commit comments