aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Advisories.pm
diff options
context:
space:
mode:
authorDan Fandrich <danf@mageia.org>2024-03-08 18:33:47 -0800
committerDan Fandrich <danf@mageia.org>2024-03-08 23:55:05 -0800
commitde98902a85982351c7539672391de014252edde5 (patch)
treee6659a58712ffb9c7f99410d3f282ad23ff8dbbf /lib/MGA/Advisories.pm
parent3b4f039b1fc76a1f7cd87b55f74d76da1e9e8e09 (diff)
downloadmgaadvisories-de98902a85982351c7539672391de014252edde5.tar
mgaadvisories-de98902a85982351c7539672391de014252edde5.tar.gz
mgaadvisories-de98902a85982351c7539672391de014252edde5.tar.bz2
mgaadvisories-de98902a85982351c7539672391de014252edde5.tar.xz
mgaadvisories-de98902a85982351c7539672391de014252edde5.zip
Add 'showjson' command to output an advisory in OSV JSON
Open Source Vulnerability format is a standard for publishing vulnerabilities in Open Source projects and is defined at https://ossf.github.io/osv-schema/
Diffstat (limited to 'lib/MGA/Advisories.pm')
-rw-r--r--lib/MGA/Advisories.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index cbabd68..c8514fa 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -821,4 +821,27 @@ sub showadv {
print $advtxt;
}
+sub showadvjson {
+ my ($advdb, $adv) = @_;
+ if (!$advdb->{advisories}{$adv}) {
+ print STDERR "Cannot find advisory $adv\n";
+ return undef;
+ }
+ my $template = Template->new(
+ ENCODING => 'utf8',
+ INCLUDE_PATH => $config->{tmpl_dir},
+ EVAL_PERL => 1,
+ );
+ my $vars = {
+ config => $config,
+ advisory => $adv,
+ advdb => $advdb,
+ basename => \%basename,
+ tools => \%tools,
+ };
+ my $advtxt;
+ process_template($template, 'advisory', $vars, \$advtxt, 'json');
+ print $advtxt;
+}
+
1;