Fix a bug when creating test data; if a community contained the strin… (#14739)

* Fix a bug when creating test data; if a community contained the string 'snmp', it would cause test data to not be generated.

Add line start/end anchors, and search for specific SNMP commands, instead of a snmp<wildcard>, and a couple of other minor tweaks...

* Fix unwanted 'g'
This commit is contained in:
Nick Peelman
2023-04-16 14:42:26 -04:00
committed by GitHub
parent 519fc00367
commit 8a64526e34

View File

@@ -191,7 +191,7 @@ class ModuleTestHelper
$collection_output = preg_replace('/\033\[[\d;]+m/', '', $collection_output);
// extract snmp queries
$snmp_query_regex = '/SNMP\[.*snmp(?:bulk)?([a-z]+)\' .+(udp|tcp|tcp6|udp6):(?:\[[0-9a-f:]+\]|[^:]+):[0-9]+\' \'(.+)\']/';
$snmp_query_regex = '/^SNMP\[\'.*snmp(?:bulk)?(walk|get|getnext)\' .+\'(udp|tcp|tcp6|udp6):(?:\[[0-9a-f:]+\]|[^:]+):[0-9]+\' \'(.+)\'\]$/m';
preg_match_all($snmp_query_regex, $collection_output, $snmp_matches);
// extract mibs and group with oids