line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1836
|
use v5.10; |
|
2
|
|
|
|
|
7
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package CPAN::Audit::Filter; |
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
25
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
633
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "1.001"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=encoding utf8 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
CPAN::Audit::Filter - manage the reports / CVEs to ignore |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use CPAN::Audit::Filter; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $filter = CPAN::Audit::Filter->new( exclude => $array_ref ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $query = CPAN::Audit::Query->new(...); |
22
|
|
|
|
|
|
|
my $advisories = $query->advisories_for( $distname, $version_range ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
foreach my $advisory ( $advisories->@* ) { |
25
|
|
|
|
|
|
|
next if $filter->excludes($advisory); |
26
|
|
|
|
|
|
|
... |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 Class methods |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over 4 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * new( exclude => ARRAYREF ) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The values in the array ref for C are uppercased before |
38
|
|
|
|
|
|
|
they are stored. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
3
|
|
|
3
|
1
|
8836
|
my($class, %params) = @_; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
12
|
my $self = bless {}, $class; |
46
|
3
|
|
100
|
|
|
17
|
$params{exclude} //= []; |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
6
|
my %excludes = map { uc($_) => 1 } @{ $params{exclude} }; |
|
1
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
6
|
|
49
|
3
|
|
|
|
|
8
|
$self->{excludes} = \%excludes; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
6
|
$self->{ignored} = {}; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
21
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Instance methods |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item * excludes( $advisory ) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns true if this instance excludes either the ID or any of the |
66
|
|
|
|
|
|
|
CVEs for ADVISORY, a hash as returned by L. This |
67
|
|
|
|
|
|
|
hash has these keys: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
id - a string, such as Some-Module-001 |
70
|
|
|
|
|
|
|
cves - an array reference of CVE strings, such as CVE-2022-001 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The values extracted from the hash are uppercased before use. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub excludes { |
77
|
2
|
|
|
2
|
1
|
4226
|
my($self, $advisory) = @_; |
78
|
|
|
|
|
|
|
|
79
|
2
|
50
|
|
|
|
3
|
return 0 unless keys %{$self->{excludes}}; |
|
2
|
|
|
|
|
8
|
|
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
4
|
my @ids = map { uc } grep { defined } ($advisory->{id}, @{$advisory->{cves}}); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
5
|
foreach my $id ( @ids ) { |
84
|
2
|
100
|
|
|
|
6
|
next unless $self->{excludes}{$id}; |
85
|
1
|
|
|
|
|
3
|
$self->{ignored}{$id}++; |
86
|
1
|
|
|
|
|
3
|
return 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
3
|
return 0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * ignored_count |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Return the count of the advisories that were ignored. Each ID or CVE |
95
|
|
|
|
|
|
|
value only counts once. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
2
|
|
|
2
|
1
|
692
|
sub ignored_count { scalar keys %{$_[0]->{ignored}} } |
|
2
|
|
|
|
|
10
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright (C) 2022 Graham TerMarsch |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
108
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |