From 479482ebe111333772a6f959d1aea74e52dd95f8 Mon Sep 17 00:00:00 2001 From: Evan Adam Date: Mon, 23 Dec 2024 11:04:01 +0100 Subject: [PATCH] fix(tests): anonymization now keep integer in place and remove windows CR from each snmpwalk line Refs:CTOR-666 --- tests/scripts/slim_walk.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/scripts/slim_walk.pl b/tests/scripts/slim_walk.pl index a40810b68a..6a6dcc2348 100644 --- a/tests/scripts/slim_walk.pl +++ b/tests/scripts/slim_walk.pl @@ -28,7 +28,7 @@ # - device names # - loop # - floating values (eg sysLoad) -my $ignore_anon_regex = qr{^"?(lo|eth[\d]*|.* memory|.*Swap.*|.*Memory.*|tmpfs|systemStats|systemd-udevd|kdevtmpfs|.*centreontrapd.*|gorgone-.*|[C-Z]:\\.*|(/[\d\w_-]*){1,}|sd[a-z]\d*|loop\d+|\d*\.\d*)"?$}; +my $ignore_anon_regex = qr{^"?(lo|eth[\d]*|.* memory|.*Swap.*|.*Memory.*|tmpfs|systemStats|systemd-udevd|kdevtmpfs|.*centreontrapd.*|gorgone-.*|[C-Z]:\\.*|(/[\d\w_-]*){1,}|sd[a-z]\d*|loop\d+|\d*\.?\d*)"?$}; sub oid_matches { my ($given_oid, $list) = @_; @@ -66,7 +66,7 @@ sub extract_oids { my $fd; open($fd, '<', $file_to_parse) or die "Could not open $file_to_parse to get OIDs from."; for my $line (<$fd>) { -# Find all strings looking like OIDs + # Find all strings looking like OIDs if ($line =~ /.*['"](\.1\.[\.0-9]+)['"].*/) { print STDERR "Line $line contains an OID: '$1'\n" if (defined($debug)); push @oids, $1; @@ -192,6 +192,8 @@ sub usage { my $is_last_line_to_keep = 0; for my $line (<$walk_fd>) { chomp $line; + # remove all CR in the line + $line =~ s/\r//g; # If the line does not begin with an OID # If the last processed line has been retained, # Then append it to the last accepted line