aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-17 20:48:45 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-17 20:48:45 +0000
commit472cd881bd9d799ef3680ed0c65a40ca2007ac2b (patch)
tree60e0bac5f90f920b8fedc7aae2205cb0f49e65de
parent7c4c1d3a5c991114d9d951cb550756fa314689f5 (diff)
downloadmgaadvisories-472cd881bd9d799ef3680ed0c65a40ca2007ac2b.tar
mgaadvisories-472cd881bd9d799ef3680ed0c65a40ca2007ac2b.tar.gz
mgaadvisories-472cd881bd9d799ef3680ed0c65a40ca2007ac2b.tar.bz2
mgaadvisories-472cd881bd9d799ef3680ed0c65a40ca2007ac2b.tar.xz
mgaadvisories-472cd881bd9d799ef3680ed0c65a40ca2007ac2b.zip
Add support for filters on list command
Possible filters are : - advisory type - distribution release - package name - CVE - media
-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 {