logo

cve-client

CLI-based client / toolbox for CVE.org
commit: 000e4fad38b17589efa5940a2e5ff46945d00392
parent 61ae154833833e56c9928f33682aa82f85c2d2c1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 25 May 2022 18:55:16 +0200

Add support for vendor+product metadata

Diffstat:

Mcve-client30++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/cve-client b/cve-client @@ -32,13 +32,14 @@ sub HELP_MESSAGE { sub print_cve { my ($object, $cve_id) = @_; - print "CVE ID: ", $cve_id, "\n\n"; + print "CVE ID: ", $cve_id, "\n"; if ($object->{'error'} and $object->{'message'}) { print "Error (", $object->{'error'}, "): ", $object->{'message'}, "\n"; exit 1; } + # https://github.com/CVEProject/cve-schema/blob/master/schema/v4.0/ if ($object->{'data_version'} != "4.0") { print "Warning: Got unknown CVE format \"", $object->{'data_version'}, "\"\n"; @@ -49,6 +50,31 @@ sub print_cve { " instead of ", $cve_id, "\n"; } + print "TITLE: ", $object->{'CVE_data_meta'}->{'TITLE'}, "\n" + if $object->{'CVE_data_meta'}->{'TITLE'}; + + print "\n"; + + if ($object->{'affects'}->{'vendor'}) { + foreach (@{$object->{'affects'}->{'vendor'}->{'vendor_data'}}) { + print "Vendor Name: ", $_->{'vendor_name'}, "\n" + if $_->{'vendor_name'}; + + foreach (@{$_->{'product'}->{'product_data'}}) { + print "Product name: ", $_->{'product_name'}, "\n"; + print "Product versions: "; + + foreach (@{$_->{'version'}->{'version_data'}}) { + print $_->{'version_value'}, "; "; + } + + print "\n"; + } + } + } + + print "\n"; + if ($object->{'description'}->{'description_data'}) { my $descs = $object->{'description'}->{'description_data'}; @@ -129,5 +155,5 @@ if ($#ARGV < 0) { } for (@ARGV) { - fetch_cve($_) if $_ =~ /^CVE-\d{4}-\d+$/; + fetch_cve($_) if $_ =~ /^CVE-[0-9]{4}-[0-9]{4,19}$/; }