| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::CVSS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
200004
|
use feature ':5.10'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
131
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
6
|
1
|
|
|
1
|
|
358
|
use utf8; |
|
|
1
|
|
|
|
|
293
|
|
|
|
1
|
|
|
|
|
5
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
615
|
use Getopt::Long qw(GetOptionsFromArray :config gnu_compat); |
|
|
1
|
|
|
|
|
13508
|
|
|
|
1
|
|
|
|
|
3
|
|
|
9
|
1
|
|
|
1
|
|
668
|
use Pod::Usage qw(pod2usage); |
|
|
1
|
|
|
|
|
80630
|
|
|
|
1
|
|
|
|
|
82
|
|
|
10
|
1
|
|
|
1
|
|
9
|
use Carp (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
17
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use JSON::PP (); |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
14
|
|
|
12
|
1
|
|
|
1
|
|
631
|
use Data::Dumper (); |
|
|
1
|
|
|
|
|
7714
|
|
|
|
1
|
|
|
|
|
46
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
602
|
use CVSS (); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
1256
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = $CVSS::VERSION; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %options = (format => 'json'); |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
0
|
0
|
0
|
|
0
|
sub _print { print(($_[0] || '') . (defined $options{null} ? "\0" : "\n")) } |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub cli_error { |
|
23
|
0
|
|
|
0
|
1
|
0
|
my ($error) = @_; |
|
24
|
0
|
|
|
|
|
0
|
$error =~ s/ at .* line \d+.*//; |
|
25
|
0
|
|
|
|
|
0
|
print STDERR "ERROR: $error\n"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub run { |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
1
|
195507
|
my ($class, @args) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
2
|
50
|
|
|
|
17
|
GetOptionsFromArray( |
|
33
|
|
|
|
|
|
|
\@args, \%options, qw( |
|
34
|
|
|
|
|
|
|
help|h |
|
35
|
|
|
|
|
|
|
man |
|
36
|
|
|
|
|
|
|
v |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
vector-string=s |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
severity |
|
41
|
|
|
|
|
|
|
score |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
base-score |
|
44
|
|
|
|
|
|
|
base-severity |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
temporal-score |
|
47
|
|
|
|
|
|
|
temporal-severity |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
environmental-score |
|
50
|
|
|
|
|
|
|
environmental-severity |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
exploitability-score |
|
53
|
|
|
|
|
|
|
impact-score |
|
54
|
|
|
|
|
|
|
modified-impact-score |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
null|0 |
|
57
|
|
|
|
|
|
|
format=s |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
json |
|
60
|
|
|
|
|
|
|
xml |
|
61
|
|
|
|
|
|
|
) |
|
62
|
|
|
|
|
|
|
) or pod2usage(-verbose => 0); |
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
50
|
|
|
|
3274
|
pod2usage(-exitstatus => 0, -verbose => 2) if defined $options{man}; |
|
65
|
2
|
50
|
|
|
|
7
|
pod2usage(-exitstatus => 0, -verbose => 0) if defined $options{help}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
6
|
if (defined $options{v}) { |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
(my $progname = $0) =~ s/.*\///; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
say <<"VERSION"; |
|
72
|
|
|
|
|
|
|
$progname version $VERSION |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Copyright 2023-2024, Giuseppe Di Terlizzi |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This program is part of the "CVSS" distribution and is free software; |
|
77
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the same terms as Perl itself. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Complete documentation for $progname can be found using 'man $progname' |
|
80
|
|
|
|
|
|
|
or on the internet at . |
|
81
|
|
|
|
|
|
|
VERSION |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
return 0; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
5
|
my ($vector_string) = @args; |
|
88
|
|
|
|
|
|
|
|
|
89
|
2
|
50
|
|
|
|
6
|
pod2usage(-verbose => 1) if !$vector_string; |
|
90
|
|
|
|
|
|
|
|
|
91
|
2
|
50
|
|
|
|
11
|
$options{format} = 'json' if defined $options{json}; |
|
92
|
2
|
100
|
|
|
|
7
|
$options{format} = 'xml' if defined $options{xml}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
2
|
50
|
|
|
|
5
|
$options{'base-severity'} = 1 if defined $options{severity}; |
|
95
|
2
|
50
|
|
|
|
7
|
$options{'base-score'} = 1 if defined $options{score}; |
|
96
|
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
3
|
my $cvss = eval { CVSS->from_vector_string($vector_string) }; |
|
|
2
|
|
|
|
|
16
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
2
|
50
|
|
|
|
6
|
if ($@) { |
|
100
|
0
|
|
|
|
|
0
|
cli_error($@); |
|
101
|
0
|
|
|
|
|
0
|
return 1; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
2
|
50
|
|
|
|
6
|
if ($options{'base-severity'}) { |
|
105
|
0
|
|
|
|
|
0
|
_print $cvss->base_severity; |
|
106
|
0
|
|
|
|
|
0
|
return 0; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
2
|
50
|
|
|
|
6
|
if ($options{'base-score'}) { |
|
110
|
0
|
|
|
|
|
0
|
_print $cvss->base_score; |
|
111
|
0
|
|
|
|
|
0
|
return 0; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
50
|
|
|
|
5
|
if ($cvss->version <= 3.1) { |
|
115
|
|
|
|
|
|
|
|
|
116
|
2
|
50
|
|
|
|
8
|
if ($options{'environmental-score'}) { |
|
117
|
0
|
|
|
|
|
0
|
_print $cvss->environmental_score; |
|
118
|
0
|
|
|
|
|
0
|
return 0; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
2
|
50
|
|
|
|
3
|
if ($options{'environmental-severity'}) { |
|
122
|
0
|
|
|
|
|
0
|
_print $cvss->environmental_severity; |
|
123
|
0
|
|
|
|
|
0
|
return 0; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
2
|
50
|
|
|
|
4
|
if ($options{'temporal-score'}) { |
|
127
|
0
|
|
|
|
|
0
|
_print $cvss->temporal_score; |
|
128
|
0
|
|
|
|
|
0
|
return 0; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
2
|
50
|
|
|
|
4
|
if ($options{'temporal-severity'}) { |
|
132
|
0
|
|
|
|
|
0
|
_print $cvss->temporal_severity; |
|
133
|
0
|
|
|
|
|
0
|
return 0; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
2
|
50
|
|
|
|
5
|
if ($options{'impact-score'}) { |
|
137
|
0
|
|
|
|
|
0
|
_print $cvss->impact_score; |
|
138
|
0
|
|
|
|
|
0
|
return 0; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
2
|
50
|
|
|
|
3
|
if ($options{'exploitability-score'}) { |
|
142
|
0
|
|
|
|
|
0
|
_print $cvss->exploitability_score; |
|
143
|
0
|
|
|
|
|
0
|
return 0; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
2
|
50
|
|
|
|
5
|
if ($options{'modified-impact-score'}) { |
|
147
|
0
|
|
|
|
|
0
|
_print $cvss->modified_impact_score; |
|
148
|
0
|
|
|
|
|
0
|
return 0; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
2
|
100
|
|
|
|
6
|
if ($options{format} eq 'json') { |
|
154
|
1
|
|
|
|
|
8
|
print JSON::PP->new->canonical->pretty(1)->convert_blessed(1)->encode($cvss); |
|
155
|
1
|
|
|
|
|
806
|
return 0; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
1
|
50
|
|
|
|
4
|
if ($options{format} eq 'xml') { |
|
159
|
1
|
|
|
|
|
5
|
print $cvss->to_xml; |
|
160
|
1
|
|
|
|
|
9
|
return 0; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
__END__ |