cvss_cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +8 -0
- data/cvss3_1.yaml +398 -0
- data/cvss_cli.gemspec +42 -0
- data/exe/cvss +15 -0
- data/lib/cvss_cli/cvss.rb +264 -0
- data/lib/cvss_cli/metric.rb +53 -0
- data/lib/cvss_cli/metric_group.rb +67 -0
- data/lib/cvss_cli/value.rb +15 -0
- data/lib/cvss_cli/version.rb +5 -0
- data/lib/cvss_cli.rb +104 -0
- data/sig/cvss_cli.rbs +4 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 586a1192e87c8d2d0048cf5dceecdb4eab527f2fd6ee20ab598d0bd36ba1c910
|
4
|
+
data.tar.gz: d644c2c712c14b49ada11f8a39dbe5483c3bb1d1645804b08aabe4d991e192d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4753ac27b59aa74b91ddace53c3d4e90d6ec2cf2ca5b6c331b9d886daca9105606074481e9cbb6e3efac0c29a95b8f3a00031360a0b538832f7738f367be036a
|
7
|
+
data.tar.gz: db1e33b6dff5225ceb222381ac9282ec57df88566975e11dd7f6e0854e06e0ac755dfc2f31ec8ac3f564c202cd2ada6ffd8045fca50d4561f126c33b47d9f47b
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cvss_cli (0.1.0)
|
5
|
+
clipboard (~> 1.3, >= 1.3.6)
|
6
|
+
colorize (~> 0.8.1)
|
7
|
+
ffi (~> 1.15, >= 1.15.5)
|
8
|
+
thor (~> 1.2, >= 1.2.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
clipboard (1.3.6)
|
14
|
+
colorize (0.8.1)
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
ffi (1.15.5)
|
17
|
+
rake (13.0.6)
|
18
|
+
rspec (3.11.0)
|
19
|
+
rspec-core (~> 3.11.0)
|
20
|
+
rspec-expectations (~> 3.11.0)
|
21
|
+
rspec-mocks (~> 3.11.0)
|
22
|
+
rspec-core (3.11.0)
|
23
|
+
rspec-support (~> 3.11.0)
|
24
|
+
rspec-expectations (3.11.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.11.0)
|
27
|
+
rspec-mocks (3.11.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.11.0)
|
30
|
+
rspec-support (3.11.0)
|
31
|
+
thor (1.2.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
x86_64-linux
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
cvss_cli!
|
38
|
+
rake (~> 13.0)
|
39
|
+
rspec (~> 3.0)
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
2.3.12
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 ferdl
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# CvssCli
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cvss_cli`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add cvss_cli
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install cvss_cli
|
16
|
+
|
17
|
+
CvssCli needs a working directory to persist cvss strings between multiple invocations.
|
18
|
+
Set the environment variable CVSS_CLI_PATH, e.g. via
|
19
|
+
|
20
|
+
$ echo "export CVSS_CLI_PATH=\"$HOME/.cvss_cli\"" >> ~/.bashrc
|
21
|
+
|
22
|
+
The cvss3_1.yaml containing all the metrics, their descriptions, etc. also needs to be placed there,
|
23
|
+
so copy it into this folder.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
|
28
|
+
See `cvss help` for more information.
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cvss_cli.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/cvss3_1.yaml
ADDED
@@ -0,0 +1,398 @@
|
|
1
|
+
metric_groups:
|
2
|
+
base:
|
3
|
+
av:
|
4
|
+
name: Attack Vector (AV)
|
5
|
+
desc: This metric reflects the context by which vulnerability exploitation is possible. The Base Score increases the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable component.
|
6
|
+
values:
|
7
|
+
n:
|
8
|
+
name: Network (N)
|
9
|
+
desc: The vulnerable component is bound to the network stack and the set of possible attackers extends beyond the other options listed, up to and including the entire Internet. Such a vulnerability is often termed 'remotely exploitable' and can be thought of as an attack being exploitable at the protocol level one or more network hops away (e.g., across one or more routers).
|
10
|
+
numerical: 0.85
|
11
|
+
a:
|
12
|
+
name: Adjacent (A)
|
13
|
+
desc: The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN to an administrative network zone).
|
14
|
+
numerical: 0.62
|
15
|
+
l:
|
16
|
+
name: Local (L)
|
17
|
+
desc: "The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities. Either: the attacker exploits the vulnerability by accessing the target system locally (e.g., keyboard, console), or remotely (e.g., SSH); or the attacker relies on User Interaction by another person to perform actions required to exploit the vulnerability (e.g., tricking a legitimate user into opening a malicious document)."
|
18
|
+
numerical: 0.55
|
19
|
+
p:
|
20
|
+
name: Physical (P)
|
21
|
+
desc: The attack requires the attacker to physically touch or manipulate the vulnerable component. Physical interaction may be brief or persistent.
|
22
|
+
numerical: 0.2
|
23
|
+
ac:
|
24
|
+
name: Attack Complexity (AC)
|
25
|
+
desc: This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability. Such conditions may require the collection of more information about the target or computational exceptions. The assessment of this metric excludes any requirements for user interaction in order to exploit the vulnerability. If a specific configuration is required for an attack to succeed, the Base metrics should be scored assuming the vulnerable component is in that configuration.
|
26
|
+
values:
|
27
|
+
l:
|
28
|
+
name: Low (L)
|
29
|
+
desc: Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success against the vulnerable component.
|
30
|
+
numerical: 0.77
|
31
|
+
h:
|
32
|
+
name: High (H)
|
33
|
+
desc: "A successful attack depends on conditions beyond the attacker's control. That is, a successful attack cannot be accomplished at will, but requires the attacker to invest in some measurable amount of effort in preparation or execution against the vulnerable component before a successful attack can be expected. For example, a successful attack may require an attacker to: gather knowledge about the environment in which the vulnerable target/component exists; prepare the target environment to improve exploit reliability; or inject themselves into the logical network path between the target and the resource requested by the victim in order to read and/or modify network communications (e.g., a man in the middle attack)."
|
34
|
+
numerical: 0.44
|
35
|
+
pr:
|
36
|
+
name: Privileges Required (PR)
|
37
|
+
desc: This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.
|
38
|
+
values:
|
39
|
+
n:
|
40
|
+
name: None (N)
|
41
|
+
desc: The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files to carry out an attack.
|
42
|
+
numerical: 0.85
|
43
|
+
numerical_changed: 0.85
|
44
|
+
l:
|
45
|
+
name: Low (L)
|
46
|
+
desc: The attacker is authorized with (i.e., requires) privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges may have the ability to cause an impact only to non-sensitive resources.
|
47
|
+
numerical: 0.62
|
48
|
+
numerical_changed: 0.68
|
49
|
+
h:
|
50
|
+
name: High (H)
|
51
|
+
desc: The attacker is authorized with (i.e., requires) privileges that provide significant (e.g., administrative) control over the vulnerable component that could affect component-wide settings and files.
|
52
|
+
numerical: 0.27
|
53
|
+
numerical_changed: 0.5
|
54
|
+
ui:
|
55
|
+
name: User Interaction (UI)
|
56
|
+
desc: This metric captures the requirement for a user, other than the attacker, to participate in the successful compromise the vulnerable component. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
|
57
|
+
values:
|
58
|
+
n:
|
59
|
+
name: None (N)
|
60
|
+
desc: The vulnerable system can be exploited without any interaction from any user.
|
61
|
+
numerical: 0.85
|
62
|
+
r:
|
63
|
+
name: Required (R)
|
64
|
+
desc: Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited.
|
65
|
+
numerical: 0.62
|
66
|
+
s:
|
67
|
+
name: Scope (S)
|
68
|
+
desc: Does a successful attack impact a component other than the vulnerable component? If so, the Base Score increases and the Confidentiality, Integrity and Authentication metrics should be scored relative to the impacted component.
|
69
|
+
values:
|
70
|
+
u:
|
71
|
+
name: Unchanged (U)
|
72
|
+
desc: An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.
|
73
|
+
c:
|
74
|
+
name: Changed (C)
|
75
|
+
desc: An exploited vulnerability can affect resources beyond the security scope managed by the security authority of the vulnerable component. In this case, the vulnerable component and the impacted component are different and managed by different security authorities.
|
76
|
+
c:
|
77
|
+
name: Confidentiality (C)
|
78
|
+
desc: This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
|
79
|
+
values:
|
80
|
+
n:
|
81
|
+
name: None (N)
|
82
|
+
desc: There is no loss of confidentiality within the impacted component.
|
83
|
+
numerical: 0
|
84
|
+
l:
|
85
|
+
name: Low (L)
|
86
|
+
desc: There is some loss of confidentiality. Access to some restricted information is obtained, but the attacker does not have control over what information is obtained, or the amount or kind of loss is limited. The information disclosure does not cause a direct, serious loss to the impacted component.
|
87
|
+
numerical: 0.22
|
88
|
+
h:
|
89
|
+
name: High (H)
|
90
|
+
desc: There is total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact.
|
91
|
+
numerical: 0.56
|
92
|
+
i:
|
93
|
+
name: Integrity (I)
|
94
|
+
desc: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.
|
95
|
+
values:
|
96
|
+
n:
|
97
|
+
name: None (N)
|
98
|
+
desc: There is no loss of integrity within the impacted component.
|
99
|
+
numerical: 0
|
100
|
+
l:
|
101
|
+
name: Low (L)
|
102
|
+
desc: Modification of data is possible, but the attacker does not have control over the consequence of a modification, or the amount of modification is limited. The data modification does not have a direct, serious impact on the impacted component.
|
103
|
+
numerical: 0.22
|
104
|
+
h:
|
105
|
+
name: High (H)
|
106
|
+
desc: There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.
|
107
|
+
numerical: 0.56
|
108
|
+
a:
|
109
|
+
name: Availability (A)
|
110
|
+
desc: This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. It refers to the loss of availability of the impacted component itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of an impacted component.
|
111
|
+
values:
|
112
|
+
n:
|
113
|
+
name: None (N)
|
114
|
+
desc: There is no impact to availability within the impacted component.
|
115
|
+
numerical: 0
|
116
|
+
l:
|
117
|
+
name: Low (L)
|
118
|
+
desc: Performance is reduced or there are interruptions in resource availability. Even if repeated exploitation of the vulnerability is possible, the attacker does not have the ability to completely deny service to legitimate users. The resources in the impacted component are either partially available all of the time, or fully available only some of the time, but overall there is no direct, serious consequence to the impacted component.
|
119
|
+
numerical: 0.22
|
120
|
+
h:
|
121
|
+
name: High (H)
|
122
|
+
desc: There is total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).
|
123
|
+
numerical: 0.56
|
124
|
+
temporal:
|
125
|
+
e:
|
126
|
+
name: Exploit Code Maturity (E)
|
127
|
+
desc: This metric measures the likelihood of the vulnerability being attacked, and is typically based on the current state of exploit techniques, exploit code availability, or active, 'in-the-wild' exploitation.
|
128
|
+
values:
|
129
|
+
x:
|
130
|
+
name: Not Defined (X)
|
131
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Temporal Score, i.e., it has the same effect on scoring as assigning High.
|
132
|
+
numerical: 1
|
133
|
+
u:
|
134
|
+
name: Unproven (U)
|
135
|
+
desc: No exploit code is available, or an exploit is theoretical.
|
136
|
+
numerical: 0.91
|
137
|
+
p:
|
138
|
+
name: Proof-of-Concept (P)
|
139
|
+
desc: Proof-of-concept exploit code is available, or an attack demonstration is not practical for most systems. The code or technique is not functional in all situations and may require substantial modification by a skilled attacker.
|
140
|
+
numerical: 0.94
|
141
|
+
f:
|
142
|
+
name: Functional (F)
|
143
|
+
desc: Functional exploit code is available. The code works in most situations where the vulnerability exists.
|
144
|
+
numerical: 0.97
|
145
|
+
h:
|
146
|
+
name: High (H)
|
147
|
+
desc: Functional autonomous code exists, or no exploit is required (manual trigger) and details are widely available. Exploit code works in every situation, or is actively being delivered via an autonomous agent (such as a worm or virus). Network-connected systems are likely to encounter scanning or exploitation attempts. Exploit development has reached the level of reliable, widely-available, easy-to-use automated tools.
|
148
|
+
numerical: 1
|
149
|
+
rl:
|
150
|
+
name: Remediation Level (RL)
|
151
|
+
desc: The Remediation Level of a vulnerability is an important factor for prioritization. The typical vulnerability is unpatched when initially published. Workarounds or hotfixes may offer interim remediation until an official patch or upgrade is issued. Each of these respective stages adjusts the temporal score downwards, reflecting the decreasing urgency as remediation becomes final.
|
152
|
+
values:
|
153
|
+
x:
|
154
|
+
name: Not Defined (X)
|
155
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Temporal Score, i.e., it has the same effect on scoring as assigning Unavailable.
|
156
|
+
numerical: 1
|
157
|
+
o:
|
158
|
+
name: Official Fix (O)
|
159
|
+
desc: A complete vendor solution is available. Either the vendor has issued an official patch, or an upgrade is available.
|
160
|
+
numerical: 0.95
|
161
|
+
t:
|
162
|
+
name: Temporary Fix (T)
|
163
|
+
desc: There is an official but temporary fix available. This includes instances where the vendor issues a temporary hotfix, tool, or workaround.
|
164
|
+
numerical: 0.96
|
165
|
+
w:
|
166
|
+
name: Workaround (W)
|
167
|
+
desc: There is an unofficial, non-vendor solution available. In some cases, users of the affected technology will create a patch of their own or provide steps to work around or otherwise mitigate the vulnerability.
|
168
|
+
numerical: 0.97
|
169
|
+
u:
|
170
|
+
name: Unavailable (U)
|
171
|
+
desc: There is either no solution available or it is impossible to apply.
|
172
|
+
numerical: 1
|
173
|
+
rc:
|
174
|
+
name: Report Confidence (RC)
|
175
|
+
desc: This metric measures the degree of confidence in the existence of the vulnerability and the credibility of the known technical details. Sometimes only the existence of vulnerabilities are publicized, but without specific details. For example, an impact may be recognized as undesirable, but the root cause may not be known. The vulnerability may later be corroborated by research which suggests where the vulnerability may lie, though the research may not be certain. Finally, a vulnerability may be confirmed through acknowledgement by the author or vendor of the affected technology. The urgency of a vulnerability is higher when a vulnerability is known to exist with certainty. This metric also suggests the level of technical knowledge available to would-be attackers.
|
176
|
+
values:
|
177
|
+
x:
|
178
|
+
name: Not Defined (X)
|
179
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Temporal Score, i.e., it has the same effect on scoring as assigning Confirmed.
|
180
|
+
numerical: 1
|
181
|
+
u:
|
182
|
+
name: Unknown (U)
|
183
|
+
desc: There are reports of impacts that indicate a vulnerability is present. The reports indicate that the cause of the vulnerability is unknown, or reports may differ on the cause or impacts of the vulnerability. Reporters are uncertain of the true nature of the vulnerability, and there is little confidence in the validity of the reports or whether a static Base score can be applied given the differences described. An example is a bug report which notes that an intermittent but non-reproducible crash occurs, with evidence of memory corruption suggesting that denial of service, or possible more serious impacts, may result.
|
184
|
+
numerical: 0.92
|
185
|
+
r:
|
186
|
+
name: Reasonable (R)
|
187
|
+
desc: Significant details are published, but researchers either do not have full confidence in the root cause, or do not have access to source code to fully confirm all of the interactions that may lead to the result. Reasonable confidence exists, however, that the bug is reproducible and at least one impact is able to be verified (Proof-of-concept exploits may provide this). An example is a detailed write-up of research into a vulnerability with an explanation (possibly obfuscated or 'left as an exercise to the reader') that gives assurances on how to reproduce the results.
|
188
|
+
numerical: 0.96
|
189
|
+
c:
|
190
|
+
name: Confirmed (C)
|
191
|
+
desc: Detailed reports exist, or functional reproduction is possible (functional exploits may provide this). Source code is available to independently verify the assertions of the research, or the author or vendor of the affected code has confirmed the presence of the vulnerability.
|
192
|
+
numerical: 1
|
193
|
+
environmental:
|
194
|
+
cr:
|
195
|
+
name: Confidentiality Requirement (CR)
|
196
|
+
desc: These metrics enable the analyst to customize the CVSS score depending on the importance of the Confidentiality of the affected IT asset to a user’s organization, relative to other impacts. This metric modifies the environmental score by reweighting the Modified Confidentiality impact metric versus the other modified impacts.
|
197
|
+
values:
|
198
|
+
x:
|
199
|
+
name: Not Defined (X)
|
200
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Environmental Score, i.e., it has the same effect on scoring as assigning Medium.
|
201
|
+
numerical: 1
|
202
|
+
l:
|
203
|
+
name: Low (L)
|
204
|
+
desc: Loss of Confidentiality is likely to have only a limited adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
205
|
+
numerical: 0.5
|
206
|
+
m:
|
207
|
+
name: Medium (M)
|
208
|
+
desc: Assigning this value to the metric will not influence the score.
|
209
|
+
numerical: 1
|
210
|
+
h:
|
211
|
+
name: High (H)
|
212
|
+
desc: Loss of Confidentiality is likely to have a catastrophic adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
213
|
+
numerical: 1.5
|
214
|
+
ir:
|
215
|
+
name: Integrity Requirement (IR)
|
216
|
+
desc: These metrics enable the analyst to customize the CVSS score depending on the importance of the Integrity of the affected IT asset to a user’s organization, relative to other impacts. This metric modifies the environmental score by reweighting the Modified Integrity impact metric versus the other modified impacts.
|
217
|
+
values:
|
218
|
+
x:
|
219
|
+
name: Not Defined (X)
|
220
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Environmental Score, i.e., it has the same effect on scoring as assigning Medium.
|
221
|
+
numerical: 1
|
222
|
+
l:
|
223
|
+
name: Low (L)
|
224
|
+
desc: Loss of Integrity is likely to have only a limited adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
225
|
+
numerical: 0.5
|
226
|
+
m:
|
227
|
+
name: Medium (M)
|
228
|
+
desc: Assigning this value to the metric will not influence the score.
|
229
|
+
numerical: 1
|
230
|
+
h:
|
231
|
+
name: High (H)
|
232
|
+
desc: Loss of Integrity is likely to have a catastrophic adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
233
|
+
numerical: 1.5
|
234
|
+
ar:
|
235
|
+
name: Availability Requirement (AR)
|
236
|
+
desc: These metrics enable the analyst to customize the CVSS score depending on the importance of the Availability of the affected IT asset to a user’s organization, relative to other impacts. This metric modifies the environmental score by reweighting the Modified Availability impact metric versus the other modified impacts.
|
237
|
+
values:
|
238
|
+
x:
|
239
|
+
name: Not Defined (X)
|
240
|
+
desc: Assigning this value indicates there is insufficient information to choose one of the other values, and has no impact on the overall Environmental Score, i.e., it has the same effect on scoring as assigning Medium.
|
241
|
+
numerical: 1
|
242
|
+
l:
|
243
|
+
name: Low (L)
|
244
|
+
desc: Loss of Availability is likely to have only a limited adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
245
|
+
numerical: 0.5
|
246
|
+
m:
|
247
|
+
name: Medium (M)
|
248
|
+
desc: Assigning this value to the metric will not influence the score.
|
249
|
+
numerical: 1
|
250
|
+
h:
|
251
|
+
name: High (H)
|
252
|
+
desc: Loss of Availability is likely to have a catastrophic adverse effect on the organization or individuals associated with the organization (e.g., employees, customers).
|
253
|
+
numerical: 1.5
|
254
|
+
mav:
|
255
|
+
name: Modified Attack Vector (MAV)
|
256
|
+
desc: This metric reflects the context by which vulnerability exploitation is possible. The Environmental Score increases the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable component.
|
257
|
+
values:
|
258
|
+
x:
|
259
|
+
name: Not Defined (X)
|
260
|
+
desc: The value assigned to the corresponding Base metric is used.
|
261
|
+
n:
|
262
|
+
name: Network (N)
|
263
|
+
desc: The vulnerable component is bound to the network stack and the set of possible attackers extends beyond the other options listed, up to and including the entire Internet. Such a vulnerability is often termed 'remotely exploitable' and can be thought of as an attack being exploitable at the protocol level one or more network hops away.
|
264
|
+
numerical: 0.85
|
265
|
+
a:
|
266
|
+
name: Adjacent Network (A)
|
267
|
+
desc: The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN).
|
268
|
+
numerical: 0.62
|
269
|
+
l:
|
270
|
+
name: Local (L)
|
271
|
+
desc: "The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities. Either: the attacker exploits the vulnerability by accessing the target system locally (e.g., keyboard, console), or remotely (e.g., SSH); or the attacker relies on User Interaction by another person to perform actions required to exploit the vulnerability (e.g., tricking a legitimate user into opening a malicious document)."
|
272
|
+
numerical: 0.55
|
273
|
+
p:
|
274
|
+
name: Physical (P)
|
275
|
+
desc: The attack requires the attacker to physically touch or manipulate the vulnerable component. Physical interaction may be brief or persistent.
|
276
|
+
numerical: 0.2
|
277
|
+
mac:
|
278
|
+
name: Modified Attack Complexity (MAC)
|
279
|
+
desc: This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability. Such conditions may require the collection of more information about the target or computational exceptions. The assessment of this metric excludes any requirements for user interaction in order to exploit the vulnerability. If a specific configuration is required for an attack to succeed, the Base metrics should be scored assuming the vulnerable component is in that configuration.
|
280
|
+
values:
|
281
|
+
x:
|
282
|
+
name: Not Defined (X)
|
283
|
+
desc: The value assigned to the corresponding Base metric is used.
|
284
|
+
l:
|
285
|
+
name: Low (L)
|
286
|
+
desc: Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success against the vulnerable component.
|
287
|
+
numerical: 0.77
|
288
|
+
h:
|
289
|
+
name: High (H)
|
290
|
+
desc: "A successful attack depends on conditions beyond the attacker's control. That is, a successful attack cannot be accomplished at will, but requires the attacker to invest in some measurable amount of effort in preparation or execution against the vulnerable component before a successful attack can be expected. For example, a successful attack may require an attacker to: gather knowledge about the environment in which the vulnerable target/component exists; prepare the target environment to improve exploit reliability; or inject themselves into the logical network path between the target and the resource requested by the victim in order to read and/or modify network communications (e.g., a man in the middle attack)."
|
291
|
+
numerical: 0.44
|
292
|
+
mpr:
|
293
|
+
name: Modified Privileges Required (MPR)
|
294
|
+
desc: This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.
|
295
|
+
values:
|
296
|
+
x:
|
297
|
+
name: Not Defined (X)
|
298
|
+
desc: The value assigned to the corresponding Base metric is used.
|
299
|
+
n:
|
300
|
+
name: None (N)
|
301
|
+
desc: The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files to carry out an attack.
|
302
|
+
numerical: 0.85
|
303
|
+
numerical_changed: 0.85
|
304
|
+
l:
|
305
|
+
name: Low (L)
|
306
|
+
desc: The attacker is authorized with (i.e., requires) privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges may have the ability to cause an impact only to non-sensitive resources.
|
307
|
+
numerical: 0.62
|
308
|
+
numerical_changed: 0.68
|
309
|
+
h:
|
310
|
+
name: High (H)
|
311
|
+
desc: The attacker is authorized with (i.e., requires) privileges that provide significant (e.g., administrative) control over the vulnerable component that could affect component-wide settings and files.
|
312
|
+
numerical: 0.27
|
313
|
+
numerical_changed: 0.5
|
314
|
+
mui:
|
315
|
+
name: Modified User Interaction (MUI)
|
316
|
+
desc: This metric captures the requirement for a user, other than the attacker, to participate in the successful compromise the vulnerable component. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
|
317
|
+
values:
|
318
|
+
x:
|
319
|
+
name: Not Defined (X)
|
320
|
+
desc: The value assigned to the corresponding Base metric is used.
|
321
|
+
n:
|
322
|
+
name: None (N)
|
323
|
+
desc: The vulnerable system can be exploited without any interaction from any user.
|
324
|
+
numerical: 0.85
|
325
|
+
r:
|
326
|
+
name: Required (R)
|
327
|
+
desc: Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited.
|
328
|
+
numerical: 0.62
|
329
|
+
ms:
|
330
|
+
name: Modified Scope (MS)
|
331
|
+
desc: Does a successful attack impact a component other than the vulnerable component? If so, the Base Score increases and the Confidentiality, Integrity and Authentication metrics should be scored relative to the impacted component.
|
332
|
+
values:
|
333
|
+
x:
|
334
|
+
name: Not Defined (X)
|
335
|
+
desc: The value assigned to the corresponding Base metric is used.
|
336
|
+
u:
|
337
|
+
name: Unchanged (U)
|
338
|
+
desc: An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.
|
339
|
+
c:
|
340
|
+
name: Changed (C)
|
341
|
+
desc: An exploited vulnerability can affect resources beyond the security scope managed by the security authority of the vulnerable component. In this case, the vulnerable component and the impacted component are different and managed by different security authorities.
|
342
|
+
mc:
|
343
|
+
name: Modified Confidentiality (MC)
|
344
|
+
desc: This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
|
345
|
+
values:
|
346
|
+
x:
|
347
|
+
name: Not Defined (X)
|
348
|
+
desc: The value assigned to the corresponding Base metric is used.
|
349
|
+
n:
|
350
|
+
name: None (N)
|
351
|
+
desc: There is no loss of confidentiality within the impacted component.
|
352
|
+
numerical: 0
|
353
|
+
l:
|
354
|
+
name: Low (L)
|
355
|
+
desc: There is some loss of confidentiality. Access to some restricted information is obtained, but the attacker does not have control over what information is obtained, or the amount or kind of loss is limited. The information disclosure does not cause a direct, serious loss to the impacted component.
|
356
|
+
numerical: 0.22
|
357
|
+
h:
|
358
|
+
name: High (H)
|
359
|
+
desc: There is total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact.
|
360
|
+
numerical: 0.56
|
361
|
+
mi:
|
362
|
+
name: Modified Integrity (MI)
|
363
|
+
desc: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.
|
364
|
+
values:
|
365
|
+
x:
|
366
|
+
name: Not Defined (X)
|
367
|
+
desc: The value assigned to the corresponding Base metric is used.
|
368
|
+
n:
|
369
|
+
name: None (N)
|
370
|
+
desc: There is no loss of integrity within the impacted component.
|
371
|
+
numerical: 0
|
372
|
+
l:
|
373
|
+
name: Low (L)
|
374
|
+
desc: Modification of data is possible, but the attacker does not have control over the consequence of a modification, or the amount of modification is limited. The data modification does not have a direct, serious impact on the impacted component.
|
375
|
+
numerical: 0.22
|
376
|
+
h:
|
377
|
+
name: High (H)
|
378
|
+
desc: There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.
|
379
|
+
numerical: 0.56
|
380
|
+
ma:
|
381
|
+
name: Modified Availability (MA)
|
382
|
+
desc: This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. It refers to the loss of availability of the impacted component itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of an impacted component.
|
383
|
+
values:
|
384
|
+
x:
|
385
|
+
name: Not Defined (X)
|
386
|
+
desc: The value assigned to the corresponding Base metric is used.
|
387
|
+
n:
|
388
|
+
name: None (N)
|
389
|
+
desc: There is no impact to availability within the impacted component.
|
390
|
+
numerical: 0
|
391
|
+
l:
|
392
|
+
name: Low (L)
|
393
|
+
desc: Performance is reduced or there are interruptions in resource availability. Even if repeated exploitation of the vulnerability is possible, the attacker does not have the ability to completely deny service to legitimate users. The resources in the impacted component are either partially available all of the time, or fully available only some of the time, but overall there is no direct, serious consequence to the impacted component.
|
394
|
+
numerical: 0.22
|
395
|
+
h:
|
396
|
+
name: High (H)
|
397
|
+
desc: There is total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).
|
398
|
+
numerical: 0.56
|
data/cvss_cli.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/cvss_cli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "cvss_cli"
|
7
|
+
spec.version = CvssCli::VERSION
|
8
|
+
spec.authors = ["Martin Haunschmid, Daniel Haider"]
|
9
|
+
spec.email = ["contact@martinhaunschmid.com"]
|
10
|
+
|
11
|
+
spec.summary = "CLI Tool to calculate CVSS Scores"
|
12
|
+
spec.description = "A simple CLI Tool to calculate CVSS Scores"
|
13
|
+
spec.homepage = "https://github.com/martinhaunschmid/cvss.cli"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/martinhaunschmid/cvss.cli"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
# Uncomment to register a new dependency of your gem
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
34
|
+
|
35
|
+
spec.add_runtime_dependency 'thor', '~> 1.2', '>= 1.2.1'
|
36
|
+
spec.add_runtime_dependency 'colorize', '~> 0.8.1'
|
37
|
+
spec.add_runtime_dependency "clipboard", '~> 1.3', '>= 1.3.6'
|
38
|
+
spec.add_runtime_dependency "ffi", '~> 1.15', '>= 1.15.5'
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
data/exe/cvss
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "cvss_cli"
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
if ENV['CVSS_CLI_PATH'].nil?
|
6
|
+
puts 'CVSS_CLI_PATH not set. Please set this environment variable in order to use cvss_cli.'.red
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
unless File.exist?(File.join(ENV['CVSS_CLI_PATH'], "cvss3_1.yaml"))
|
11
|
+
puts "cvss3_1.yaml not found. Please copy it to #{File.join(ENV['CVSS_CLI_PATH'])}".red
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
CvssCli::CLI.start
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require 'cvss_cli/metric_group'
|
2
|
+
|
3
|
+
module CvssCli
|
4
|
+
class Cvss
|
5
|
+
|
6
|
+
attr_reader :groups, :metrics
|
7
|
+
|
8
|
+
def initialize(cvss_string = nil)
|
9
|
+
@groups = Hash.new
|
10
|
+
@metrics = Hash.new
|
11
|
+
|
12
|
+
file = YAML.load_file(File.join(ENV['CVSS_CLI_PATH'], "cvss3_1.yaml"))
|
13
|
+
file['metric_groups'].each do |name, metric_group|
|
14
|
+
group = MetricGroup.new(name, metric_group)
|
15
|
+
@groups[name] = group
|
16
|
+
@metrics.merge!(group.metrics)
|
17
|
+
end
|
18
|
+
|
19
|
+
parse_cvss_string(cvss_string) unless cvss_string.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_metric(metric, value)
|
23
|
+
if value != 'NIL'
|
24
|
+
@metrics[metric.downcase].set_value(value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def clear
|
29
|
+
@metrics.values.each do |metric|
|
30
|
+
metric.clear_value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_status(full = false)
|
35
|
+
@groups.values.each do |group|
|
36
|
+
print_group(group, full)
|
37
|
+
end
|
38
|
+
print_score
|
39
|
+
print_cvss
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_score
|
43
|
+
score = calculate_base_score
|
44
|
+
if @groups['temporal'].any_metric_set?
|
45
|
+
score = calculate_temporal_score(score)
|
46
|
+
end
|
47
|
+
if @groups['environmental'].any_metric_set?
|
48
|
+
score = calculate_environmental_score
|
49
|
+
end
|
50
|
+
score
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_rating(score)
|
54
|
+
if score != roundup(score)
|
55
|
+
raise RuntimeError.new "Called with invalid value. Please round up your score to the smallest number, specified to 1 decimal place, that is equal to or higher than its input"
|
56
|
+
end
|
57
|
+
|
58
|
+
if score < 0 or score > 10
|
59
|
+
raise RuntimeError.new "Score must be betweeen 0 and 10."
|
60
|
+
end
|
61
|
+
|
62
|
+
if score == 0.0
|
63
|
+
'None'
|
64
|
+
elsif score >= 0.1 and score <= 3.9
|
65
|
+
'Low'
|
66
|
+
elsif score >= 4.0 and score <= 6.9
|
67
|
+
'Medium'
|
68
|
+
elsif score >= 7.0 and score <= 8.9
|
69
|
+
'High'
|
70
|
+
elsif score >= 9.0 and score <= 10
|
71
|
+
'Critical'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_s
|
76
|
+
s = ""
|
77
|
+
@groups.values.each do |group|
|
78
|
+
s += group.get_cvss_string
|
79
|
+
end
|
80
|
+
"CVSS:3.1/" + s.delete_suffix('/')
|
81
|
+
end
|
82
|
+
|
83
|
+
def parse_cvss_string(cvss_string)
|
84
|
+
s = cvss_string.delete_prefix('CVSS:3.1/')
|
85
|
+
s.split('/').each do |pair|
|
86
|
+
metric = pair.split(':')[0]
|
87
|
+
value = pair.split(':')[1]
|
88
|
+
set_metric(metric, value)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def print_score
|
95
|
+
score = get_score
|
96
|
+
|
97
|
+
unless score.nil?
|
98
|
+
rating = get_rating(score)
|
99
|
+
score_string = "#{score} (#{rating})"
|
100
|
+
|
101
|
+
case rating
|
102
|
+
when "Low"
|
103
|
+
score_string = score_string.light_yellow
|
104
|
+
when "Medium"
|
105
|
+
score_string = score_string.yellow
|
106
|
+
when "High"
|
107
|
+
score_string = score_string.light_red
|
108
|
+
when "Critical"
|
109
|
+
score_string = score_string.red.underline
|
110
|
+
end
|
111
|
+
puts score_string
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def print_cvss
|
116
|
+
cvss_string = self.to_s.gsub("NIL", "NIL".light_black.italic)
|
117
|
+
puts cvss_string
|
118
|
+
end
|
119
|
+
|
120
|
+
def print_group(group, full)
|
121
|
+
if group.any_metric_set?
|
122
|
+
puts group.name.capitalize.underline
|
123
|
+
|
124
|
+
if full
|
125
|
+
group.metrics.values.each do |metric|
|
126
|
+
left_side = metric.name.ljust(group.print_size)
|
127
|
+
|
128
|
+
vals = []
|
129
|
+
metric.values.values.each do |v|
|
130
|
+
if v.name == metric.get_value&.name
|
131
|
+
vals << v.name.white
|
132
|
+
else
|
133
|
+
vals << v.name.light_black
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
right_side = vals.join(', ')
|
138
|
+
puts "#{left_side} | #{right_side}"
|
139
|
+
end
|
140
|
+
else
|
141
|
+
group.metrics.values.each do |metric|
|
142
|
+
puts "#{metric.name.ljust(group.print_size)} | #{metric.get_value&.name}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
puts ""
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def calculate_base_score
|
151
|
+
unless groups['base'].all_metrics_set?
|
152
|
+
return nil
|
153
|
+
end
|
154
|
+
|
155
|
+
c = get_numerical_value 'c'
|
156
|
+
i = get_numerical_value 'i'
|
157
|
+
a = get_numerical_value 'a'
|
158
|
+
av = get_numerical_value 'av'
|
159
|
+
ac = get_numerical_value 'ac'
|
160
|
+
ui = get_numerical_value 'ui'
|
161
|
+
scope_changed = (get_value 's') == 'c'
|
162
|
+
|
163
|
+
pr = scope_changed ? (get_numerical_changed_value 'pr') : (get_numerical_value 'pr')
|
164
|
+
iss = 1 - ((1 - c) * (1 - i) * (1 - a))
|
165
|
+
|
166
|
+
impact = scope_changed ? (7.52 * (iss - 0.029) - 3.25 * (iss - 0.02) ** 15) : (6.42 * iss)
|
167
|
+
exploitability = 8.22 * av * ac * pr * ui
|
168
|
+
|
169
|
+
if impact <= 0
|
170
|
+
0
|
171
|
+
elsif scope_changed
|
172
|
+
roundup([1.08 * (impact + exploitability), 10].min)
|
173
|
+
else
|
174
|
+
roundup([(impact + exploitability), 10].min)
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
def calculate_temporal_score(base_score)
|
180
|
+
if groups['temporal'].any_metric_set?
|
181
|
+
e = get_numerical_value 'e'
|
182
|
+
rl = get_numerical_value 'rl'
|
183
|
+
rc = get_numerical_value 'rc'
|
184
|
+
roundup(base_score * e * rl * rc)
|
185
|
+
else
|
186
|
+
base_score
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def calculate_environmental_score
|
191
|
+
mc = get_modified_numerical_value('mc', 'c')
|
192
|
+
mi = get_modified_numerical_value('mi', 'i')
|
193
|
+
ma = get_modified_numerical_value('ma', 'a')
|
194
|
+
mav = get_modified_numerical_value('mav', 'av')
|
195
|
+
mac = get_modified_numerical_value('mac', 'ac')
|
196
|
+
mui = get_modified_numerical_value('mui', 'ui')
|
197
|
+
|
198
|
+
e = get_numerical_value 'e'
|
199
|
+
rl = get_numerical_value 'rl'
|
200
|
+
rc = get_numerical_value 'rc'
|
201
|
+
|
202
|
+
cr = get_numerical_value('cr')
|
203
|
+
ir = get_numerical_value('ir')
|
204
|
+
ar = get_numerical_value('ar')
|
205
|
+
|
206
|
+
ms = (get_value 'ms')
|
207
|
+
|
208
|
+
if !ms.nil? and ms != 'x'
|
209
|
+
scope_changed = (get_value 'ms') == 'c'
|
210
|
+
else
|
211
|
+
scope_changed = (get_value 's') == 'c'
|
212
|
+
end
|
213
|
+
|
214
|
+
mpr = scope_changed ? (get_modified_numerical_changed_value 'mpr', 'pr') : (get_modified_numerical_value 'mpr', 'pr')
|
215
|
+
|
216
|
+
miss = [1 - ((1 - cr * mc) * (1 - ir * mi) * (1 - ar * ma)), 0.915].min
|
217
|
+
|
218
|
+
impact = scope_changed ? (7.52 * (miss - 0.029) - 3.25 * (miss * 0.9731 - 0.02) ** 13) : (6.42 * miss)
|
219
|
+
exploitability = 8.22 * mav * mac * mpr * mui
|
220
|
+
|
221
|
+
if impact <= 0
|
222
|
+
0
|
223
|
+
elsif scope_changed
|
224
|
+
roundup(roundup([1.08 * (impact + exploitability), 10].min) * e * rl * rc)
|
225
|
+
else
|
226
|
+
roundup(roundup([(impact + exploitability), 10].min) * e * rl * rc)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def get_value(metric_key)
|
231
|
+
@metrics[metric_key].get_value&.key
|
232
|
+
end
|
233
|
+
|
234
|
+
def get_numerical_value(metric_key)
|
235
|
+
@metrics[metric_key].get_numerical_value
|
236
|
+
end
|
237
|
+
|
238
|
+
def get_numerical_changed_value(metric_key)
|
239
|
+
@metrics[metric_key].get_numerical_changed_value
|
240
|
+
end
|
241
|
+
|
242
|
+
def get_modified_numerical_value(modified_metric_key, metric_key)
|
243
|
+
if @metrics[modified_metric_key].get_value&.key != 'x'
|
244
|
+
@metrics[modified_metric_key].get_numerical_value
|
245
|
+
else
|
246
|
+
@metrics[metric_key].get_numerical_value
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def get_modified_numerical_changed_value(modified_metric_key, metric_key)
|
251
|
+
if @metrics[modified_metric_key].get_value&.key != 'x'
|
252
|
+
@metrics[modified_metric_key].get_numerical_changed_value
|
253
|
+
else
|
254
|
+
@metrics[metric_key].get_numerical_changed_value
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def roundup(v)
|
259
|
+
v.ceil(1)
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'cvss_cli/value'
|
2
|
+
|
3
|
+
module CvssCli
|
4
|
+
class Metric
|
5
|
+
|
6
|
+
attr_reader :key, :name, :desc, :values, :value
|
7
|
+
|
8
|
+
def initialize(key, name, desc, values)
|
9
|
+
@key = key
|
10
|
+
@name = name
|
11
|
+
@desc = desc
|
12
|
+
@value = nil # todo or add default value?
|
13
|
+
@values = Hash.new
|
14
|
+
values.each do |key, value|
|
15
|
+
@values[key] = Value.new(key, value['name'], value['desc'], value['numerical'], value['numerical_changed'])
|
16
|
+
@value = key if key == 'x' # set default value to Not Defined (X) if the metric has such a value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_value(value)
|
21
|
+
if @values.keys.include? value.downcase
|
22
|
+
#puts "Setting #{@name}: #{value.upcase}"
|
23
|
+
@value = value.downcase
|
24
|
+
else
|
25
|
+
puts "Value #{value.upcase} not valid for metric #{@name}. Valid values are: #{(@values.values.collect { |v| v.key.upcase }).join(', ')}".red
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_value
|
30
|
+
return nil if @value.nil?
|
31
|
+
@values[@value]
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_numerical_value
|
35
|
+
return nil if @value.nil?
|
36
|
+
@values[@value].numerical
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_numerical_changed_value
|
40
|
+
return nil if @value.nil?
|
41
|
+
@values[@value].numerical_changed
|
42
|
+
end
|
43
|
+
|
44
|
+
def clear_value
|
45
|
+
if @values.values.map { |v| v.key }.include? 'x'
|
46
|
+
@value = 'x'
|
47
|
+
else
|
48
|
+
@value = nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'cvss_cli/metric'
|
2
|
+
|
3
|
+
module CvssCli
|
4
|
+
class MetricGroup
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
attr_reader :metrics
|
8
|
+
|
9
|
+
def initialize(name, metrics)
|
10
|
+
@name = name
|
11
|
+
@metrics = Hash.new
|
12
|
+
|
13
|
+
metrics.each do |key, metric|
|
14
|
+
@metrics[key] = Metric.new(key, metric['name'], metric['desc'], metric['values'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def calculate_score(base_score = nil)
|
19
|
+
case @name
|
20
|
+
when "base"
|
21
|
+
calculate_base_score
|
22
|
+
when "temporal"
|
23
|
+
calculate_temporal_score(base_score)
|
24
|
+
when "environmental"
|
25
|
+
calculate_environmental_score
|
26
|
+
else
|
27
|
+
raise NotImplementedError "invalid group name #{@name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_cvss_string
|
32
|
+
string = ""
|
33
|
+
@metrics.values.each do |metric|
|
34
|
+
if metric.value.nil? or metric.value == 'x'
|
35
|
+
if print_nil_values
|
36
|
+
string += "#{metric.key}:".upcase + "NIL"
|
37
|
+
string += "/"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
string += "#{metric.key}:#{metric.value}".upcase
|
41
|
+
string += "/"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
string
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_size
|
48
|
+
@metrics.values.map { |m| m.name.size }.max
|
49
|
+
end
|
50
|
+
|
51
|
+
def any_metric_set?
|
52
|
+
@metrics.values.any? { |m| !m.value.nil? and m.value != 'x' and m.value != 'NIL' }
|
53
|
+
end
|
54
|
+
|
55
|
+
def all_metrics_set?
|
56
|
+
!@metrics.values.any? { |m| m.value.nil? }
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def print_nil_values
|
62
|
+
# metrics whose values are nil are only printed in the base group
|
63
|
+
@name == "base"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CvssCli
|
2
|
+
class Value
|
3
|
+
|
4
|
+
attr_reader :key, :name, :desc, :numerical, :numerical_changed
|
5
|
+
|
6
|
+
def initialize(key, name, desc, numerical, numerical_changed)
|
7
|
+
@key = key
|
8
|
+
@name = name
|
9
|
+
@desc = desc
|
10
|
+
@numerical = numerical
|
11
|
+
@numerical_changed = numerical_changed
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/cvss_cli.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cvss_cli/version"
|
4
|
+
require "cvss_cli"
|
5
|
+
require 'cvss_cli/cvss'
|
6
|
+
require "thor"
|
7
|
+
require 'yaml'
|
8
|
+
require 'colorize'
|
9
|
+
require 'net/http'
|
10
|
+
require 'json'
|
11
|
+
require 'clipboard'
|
12
|
+
|
13
|
+
module CvssCli
|
14
|
+
class CLI < Thor
|
15
|
+
|
16
|
+
file_name = File.join(ENV['CVSS_CLI_PATH'], 'cvss_string')
|
17
|
+
cvss_string = File.exist?(file_name) ? File.open(File.join(ENV['CVSS_CLI_PATH'], 'cvss_string')).read : nil
|
18
|
+
@@cvss = Cvss.new(cvss_string)
|
19
|
+
|
20
|
+
@@cvss.metrics.values.each do |metric|
|
21
|
+
desc "#{metric.key} [score]", "#{metric.name}"
|
22
|
+
define_method :"#{metric.key}" do |v = nil|
|
23
|
+
if v.nil?
|
24
|
+
puts metric.desc
|
25
|
+
puts ""
|
26
|
+
|
27
|
+
metric.values.values.each do |value|
|
28
|
+
puts "#{value.name}:"
|
29
|
+
puts "#{value.desc}"
|
30
|
+
puts ""
|
31
|
+
end
|
32
|
+
else
|
33
|
+
metric.set_value(v)
|
34
|
+
write_file
|
35
|
+
invoke :status, []
|
36
|
+
invoke :copy, []
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "copy", "Copy current CVSS string to clipboard"
|
42
|
+
def copy()
|
43
|
+
Clipboard.copy @@cvss
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "load cvss_string", "Load the given CVSS string"
|
47
|
+
def load(cvss_string)
|
48
|
+
@@cvss.clear
|
49
|
+
@@cvss.parse_cvss_string(cvss_string)
|
50
|
+
write_file
|
51
|
+
invoke :status, [], full: true
|
52
|
+
invoke :copy, [], []
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "clear", "Clears the current CVSS string"
|
56
|
+
def clear()
|
57
|
+
@@cvss.clear
|
58
|
+
write_file
|
59
|
+
invoke :status, []
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "status", "Show a visual representation of the current CVSS string"
|
63
|
+
method_option :full, aliases: '-f', desc: 'Show all values of metrics, not only the currently selected one.'
|
64
|
+
def status()
|
65
|
+
@@cvss.print_status(options[:full])
|
66
|
+
invoke :copy, [], []
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "cve cve_string", "Loads the CVSS score of the given CVE string"
|
70
|
+
def cve(cve_string)
|
71
|
+
cvss_string = get_cvss_string_from_cve(cve_string)
|
72
|
+
invoke :load, [cvss_string] if cvss_string
|
73
|
+
end
|
74
|
+
|
75
|
+
no_commands do
|
76
|
+
def write_file
|
77
|
+
open(File.join(ENV['CVSS_CLI_PATH'], 'cvss_string'), 'w') do |f|
|
78
|
+
f << @@cvss
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_cvss_string_from_cve(cve)
|
83
|
+
uri = URI("https://services.nvd.nist.gov/rest/json/cve/1.0/#{cve}")
|
84
|
+
response = Net::HTTP.get(uri)
|
85
|
+
result = JSON.parse(response)
|
86
|
+
if result['result']
|
87
|
+
result['result']['CVE_Items'].each do |cve_item|
|
88
|
+
if cve_item['impact'] && cve_item['impact']['baseMetricV3'] && cve_item['impact']['baseMetricV3']['cvssV3']
|
89
|
+
cvssv3 = cve_item['impact']['baseMetricV3']['cvssV3']
|
90
|
+
if cvssv3['version'].strip == "3.1"
|
91
|
+
return cvssv3['vectorString']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
else
|
96
|
+
puts "Unable to find CVE.".red
|
97
|
+
return
|
98
|
+
end
|
99
|
+
puts "Could not find CVSS3.1 score for given CVE.".red
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
data/sig/cvss_cli.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cvss_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Haunschmid, Daniel Haider
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.2.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.2.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: colorize
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.1
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.8.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: clipboard
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.3'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.6
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.3'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.3.6
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: ffi
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.15'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.15.5
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.15'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.15.5
|
101
|
+
description: A simple CLI Tool to calculate CVSS Scores
|
102
|
+
email:
|
103
|
+
- contact@martinhaunschmid.com
|
104
|
+
executables:
|
105
|
+
- cvss
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- ".rspec"
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- cvss3_1.yaml
|
116
|
+
- cvss_cli.gemspec
|
117
|
+
- exe/cvss
|
118
|
+
- lib/cvss_cli.rb
|
119
|
+
- lib/cvss_cli/cvss.rb
|
120
|
+
- lib/cvss_cli/metric.rb
|
121
|
+
- lib/cvss_cli/metric_group.rb
|
122
|
+
- lib/cvss_cli/value.rb
|
123
|
+
- lib/cvss_cli/version.rb
|
124
|
+
- sig/cvss_cli.rbs
|
125
|
+
homepage: https://github.com/martinhaunschmid/cvss.cli
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata:
|
129
|
+
homepage_uri: https://github.com/martinhaunschmid/cvss.cli
|
130
|
+
source_code_uri: https://github.com/martinhaunschmid/cvss.cli
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 2.6.0
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubygems_version: 3.3.12
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: CLI Tool to calculate CVSS Scores
|
150
|
+
test_files: []
|