logo

cve-client

CLI-based client / toolbox for CVE.org
commit: 96e8ed2730994fd69d2adfdc11148609e4632b1f
parent 94ff768380a9d6d204b0b11404474b7d7567e546
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  2 Oct 2021 22:44:59 +0200

Gemtext option

Diffstat:

Mcve-client.pl22+++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/cve-client.pl b/cve-client.pl @@ -18,6 +18,7 @@ sub usage { print "usage: ap-fetch.pl [-r|-j] <CVE-ID>\n"; print " -r Raw output\n"; print " -j Pipe into jq(1)\n"; + print " -g Gemtext format\n"; print "Otherwise it tries to do a plain-text representation.\n"; exit 1; } @@ -52,10 +53,21 @@ sub print_cve { my $refs = $object->{'references'}->{'reference_data'}; foreach (@{$refs}) { - print "Reference Source: ", $_->{'refsource'}, "\n"; - print "- Name: ", $_->{'name'}, "\n" if $_->{'name'}; - print "- URL: ", $_->{'url'}, "\n" if $_->{'url'}; - print "\n"; + if (defined $options{g}) { + print "Reference Source: ", $_->{'refsource'}, "\n"; + + print "=> ", $_->{'url'} if $_->{'url'}; + if ($_->{'name'}) { + print " ", $_->{'name'}, "\n\n"; + } else { + print "\n\n"; + } + } else { + print "Reference Source: ", $_->{'refsource'}, "\n"; + print "- Name: ", $_->{'name'}, "\n" if $_->{'name'}; + print "- URL: ", $_->{'url'}, "\n" if $_->{'url'}; + print "\n"; + } } } else { print "Warning: No CVE references could be found!"; @@ -98,7 +110,7 @@ sub fetch_cve { } } -getopts("rj", \%options); +getopts("rjg", \%options); if ($#ARGV != 0) { usage; }