aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--lib/MGA/Advisories.pm15
-rwxr-xr-xmgaadv30
3 files changed, 39 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 1a67fee..1f08b35 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
- don't save status for unpublished advisories
- fix display of publication date
+- list command now accept filters to filter results
Version 0.8
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 0115438..9ebe35e 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -328,9 +328,18 @@ sub newadv {
}
sub listadv {
- my ($advdb) = @_;
- print map { "$_ . $advdb->{advisories}{$_}{subject}\n" }
- adv_sort($advdb, keys %{$advdb->{advisories}});
+ my ($advdb, @filter) = @_;
+ my @advlist = keys %{$advdb->{advisories}};
+ foreach my $f (@filter) {
+ my $l = $advdb->{by_type}{$f} || $advdb->{by_cve}{$f}
+ || $advdb->{by_rel}{$f} || $advdb->{by_media}{$f}
+ || $advdb->{by_src}{$f} || [];
+ my %z;
+ @z{@$l} = (1) x @$l;
+ @advlist = grep { $z{$_} } @advlist;
+ }
+ print map { "$_ . $advdb->{advisories}{$_}{subject}\n" }
+ adv_sort($advdb, @advlist);
}
sub showadv {
diff --git a/mgaadv b/mgaadv
index afbe8dd..e2ed080 100755
--- a/mgaadv
+++ b/mgaadv
@@ -21,9 +21,30 @@ END
run => \&listadv,
descr => 'List advisories',
usage => <<END,
-$0 list
+$0 list [filter...]
+
+Print the list of published advisories. Optionally you can filter the
+list with one or more filters. Possible filters are :
+- advisory type
+- distribution release
+- package name
+- CVE
+- media
+
+Examples :
+
+ list advisories for package wireshark :
+ \$ mgaadv list wireshark
+
+ list security advisories for package wireshark :
+ \$ mgaadv list security wireshark
+
+ list advisories for CVE CVE-2013-3560
+ \$ mgaadv list CVE-2013-3560
+
+ list advisories for Mageia 2 in media tainted :
+ \$ mgaadv list 2 tainted
-Print the list of published advisories
END
},
mksite => {
@@ -147,10 +168,11 @@ sub publish {
}
sub listadv {
- usageexit('usage', $_[0]) unless @_ == 1;
+ shift;
my %advdb;
$advdb{advisories} = MGA::Advisories::get_advisories();
- MGA::Advisories::listadv(\%advdb);
+ MGA::Advisories::sort_advisories(\%advdb) if @_;
+ MGA::Advisories::listadv(\%advdb, @_);
}
sub showadv {