From 4c22e3906096bc1029dfdc7875abdfb0c259dc22 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Wed, 2 Feb 2011 20:50:57 +0000 Subject: Implement support for comments in CPE files. Sort CVE list in reverse order. git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@16040 e39458fd-73e7-0310-bf30-c45bca0a0e42 --- bin/compare-nvd-cve | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'bin/compare-nvd-cve') diff --git a/bin/compare-nvd-cve b/bin/compare-nvd-cve index 5a27ccccdb..cfbc3b5048 100755 --- a/bin/compare-nvd-cve +++ b/bin/compare-nvd-cve @@ -18,6 +18,7 @@ open (my $fh, "<", "data/CPE/aliases") || die; my $lastcpe = ""; while (<$fh>) { chomp; + s/#.*$//; # Remove comments unless ($_) { $lastcpe = ""; next; @@ -43,6 +44,7 @@ sub cpe_expand_alias { open($fh, "<", "data/CPE/list") || die; while (<$fh>) { chomp; + s/#.*$//; # Remove comments my ($binpkg, $cpe) = split(/;/); $cpe = cpe_expand_alias($cpe); # $cpe = "unknown-$binpkg" unless $cpe; @@ -59,7 +61,9 @@ while (<$fh>) { chomp; $cve = $1 if (m/^(CVE-\S+)\s*/); s/^(\s+)\[\S+\] /$1/; # Trim away distribution name - if (m/^\s+- (\S+)\S*/ && ! m//) { + if ( m/^\s+- (\S+)\S*/ + && ! m// + ) { my $srcpkg = $1; if (exists $cvemap{$cve}) { push(@{$cvemap{$cve}}, $srcpkg); @@ -79,10 +83,14 @@ for my $cvelist # "nvdcve-2.0-2010.xml", # "nvdcve-2.0-2009.xml", # "nvdcve-2.0-2008.xml", +# "nvdcve-2.0-2007.xml", +# "nvdcve-2.0-2006.xml", +# "nvdcve-2.0-2005.xml", +# "nvdcve-2.0-2004.xml", ) { print "Loading $cvelist\n" if $debug; my $ref = XMLin("../../" . $cvelist); - for my $cve (sort keys %{$ref->{entry}}) { + for my $cve (sort {$b cmp $a} keys %{$ref->{entry}}) { print "Checking $cve\n" if $debug; my $entry = $ref->{entry}->{$cve}; -- cgit v1.2.3