commit: 61ae154833833e56c9928f33682aa82f85c2d2c1
parent e85bfed0d20391ad678abd7fff07eb1f4ff60097
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 13 Feb 2022 01:04:54 +0100
cve-client: Allow multiple CVEs at once
Diffstat:
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/cve-client b/cve-client
@@ -10,12 +10,18 @@ use Getopt::Std;
use LWP::UserAgent;
use JSON::MaybeXS;
+$Getopt::Std::STANDARD_HELP_VERSION = 1;
+
my $json = JSON::MaybeXS->new(utf8 => 1);
my %options = ();
-sub usage {
- print "usage: ap-fetch.pl [-r|-j|-g] <CVE-ID>\n";
+sub VERSION_MESSAGE {
+ print "cve-client 0.0.1\n";
+}
+
+sub HELP_MESSAGE {
+ print "usage: cve-client [-r|-j|-g] <CVE-IDs ...>\n";
print " -r Raw output\n";
print " -j Pipe into jq(1)\n";
print " -g Gemtext format\n";
@@ -48,7 +54,7 @@ sub print_cve {
foreach (@{$descs}) {
print "Description Language: ", $_->{'lang'}, "\n";
- print "Description:\n", $_->{'value'}, "\n\n";
+ print "Description:\n", $_->{'value'}, "\n\n";
}
} else {
print "Warning: No CVE description could be found!";
@@ -69,8 +75,8 @@ sub print_cve {
}
} else {
print "Reference Source: ", $_->{'refsource'}, "\n";
- print "- Name: ", $_->{'name'}, "\n" if $_->{'name'};
- print "- URL: ", $_->{'url'}, "\n" if $_->{'url'};
+ print "- Name: ", $_->{'name'}, "\n" if $_->{'name'};
+ print "- URL: ", $_->{'url'}, "\n" if $_->{'url'};
print "\n";
}
}
@@ -117,10 +123,11 @@ sub fetch_cve {
getopts("rjg", \%options);
-if ($#ARGV != 0) { usage; }
+if ($#ARGV < 0) {
+ HELP_MESSAGE;
+ exit 1;
+}
-if ($ARGV[0] =~ /^CVE-\d{4}-\d+$/) {
- fetch_cve($ARGV[0]);
-} else {
- usage();
+for (@ARGV) {
+ fetch_cve($_) if $_ =~ /^CVE-\d{4}-\d+$/;
}