cvss_rating 0.5.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/cvss_rating.gemspec +1 -0
- data/lib/cvss3_rating.rb +12 -9
- data/lib/cvss_rating/cvss3_formulas.rb +84 -97
- data/lib/cvss_rating/cvss3_vectors.rb +542 -550
- data/lib/cvss_rating/float.rb +6 -0
- data/lib/cvss_rating/version.rb +2 -2
- data/test/cvss2_rating_test.rb +6 -1
- data/test/cvss3_rating_test.rb +5 -4
- metadata +17 -2
@@ -1,551 +1,543 @@
|
|
1
1
|
module Cvss3Vectors
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
self.mui = mui
|
545
|
-
|
546
|
-
self.mc = mc
|
547
|
-
self.mi = mi
|
548
|
-
self.ma = ma
|
549
|
-
end
|
550
|
-
|
551
|
-
end
|
2
|
+
attr_reader :av, :ac, :ui, :sc, :ci, :ai, :ii, :ex, :rl, :rc, :pr, :ar, :cr, :ir
|
3
|
+
|
4
|
+
VECTORS = {
|
5
|
+
'cvss' => 'cvss3=',
|
6
|
+
'av' => 'av=',
|
7
|
+
'ac' => 'ac=',
|
8
|
+
'ui' => 'ui=',
|
9
|
+
's' => 'sc=',
|
10
|
+
'c' => 'ci=',
|
11
|
+
'i' => 'ii=',
|
12
|
+
'a' => 'ai=',
|
13
|
+
'e' => 'ex=',
|
14
|
+
'rl' => 'rl=',
|
15
|
+
'rc' => 'rc=',
|
16
|
+
'pr' => 'pr=',
|
17
|
+
'cr' => 'cr=',
|
18
|
+
'ir' => 'ir=',
|
19
|
+
'ar' => 'ar=',
|
20
|
+
'mav' => 'mav=',
|
21
|
+
'mac' => 'mac=',
|
22
|
+
'ms' => 'ms=',
|
23
|
+
'mpr' => 'mpr=',
|
24
|
+
'mui' => 'mui=',
|
25
|
+
'mc' => 'mc=',
|
26
|
+
'mi' => 'mi=',
|
27
|
+
'ma' => 'ma='
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
def parse(vector)
|
31
|
+
string = vector.split('/')
|
32
|
+
len = string.length
|
33
|
+
|
34
|
+
init
|
35
|
+
|
36
|
+
@originalkey = vector
|
37
|
+
|
38
|
+
string.each do |section|
|
39
|
+
tmp = section.split(':')
|
40
|
+
send(VECTORS[tmp[0].downcase].to_sym, tmp[1])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_key
|
45
|
+
@key = format('AV:%s/AC:%s/PR:%s/UI:%s/C:%s/I:%s/A:%s', av, ac, pr, ui, ci, ii, ai)
|
46
|
+
|
47
|
+
@key += format('/E:%s', ex) unless @ex.nil?
|
48
|
+
@key += format('/RL:%s', rl) unless @rl.nil?
|
49
|
+
@key += format('/RC:%s', rc) unless @rc.nil?
|
50
|
+
|
51
|
+
@key += format('/CR:%s', cr) unless @cr.nil?
|
52
|
+
@key += format('/IR:%s', ir) unless @ir.nil?
|
53
|
+
@key += format('/AR:%s', ar) unless @ar.nil?
|
54
|
+
|
55
|
+
@key += format('/MAV:%s', mav) unless @mav.nil?
|
56
|
+
@key += format('/MAC:%s', mac) unless @mac.nil?
|
57
|
+
@key += format('/MPR:%s', mpr) unless @mpr.nil?
|
58
|
+
@key += format('/MUI:%s', mui) unless @mui.nil?
|
59
|
+
@key += format('/MS:%s', ms) unless @ms.nil?
|
60
|
+
|
61
|
+
@key += format('/MC:%s', mc) unless @mc.nil?
|
62
|
+
@key += format('/MI:%s', mi) unless @mi.nil?
|
63
|
+
@key += format('/MA:%s', ma) unless @ma.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
def key
|
67
|
+
set_key
|
68
|
+
@key
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_key(vector, value)
|
72
|
+
get_key = eval('::Cvss3::Metrics::' + vector + '_KEY')[(eval('::Cvss3::Metrics::' + vector).select { |_k, v| v == value }).keys[0]]
|
73
|
+
end
|
74
|
+
|
75
|
+
def cvss3=(cvss3)
|
76
|
+
raise 'Bad CVSS 3.0 Vector String' if cvss3 != '3.0'
|
77
|
+
end
|
78
|
+
|
79
|
+
def av=(av)
|
80
|
+
@av = case av
|
81
|
+
when 'physical', 'P'
|
82
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:physical]
|
83
|
+
when 'local', 'L'
|
84
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:local]
|
85
|
+
when 'adjacent network', 'A'
|
86
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:adjacent_network]
|
87
|
+
when 'network', 'N'
|
88
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:network]
|
89
|
+
else
|
90
|
+
raise 'Bad Argument'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def av
|
95
|
+
av = get_key('ATTACK_VECTOR', @av) unless @av.nil?
|
96
|
+
end
|
97
|
+
|
98
|
+
def ac=(ac)
|
99
|
+
@ac = case ac
|
100
|
+
when 'high', 'H'
|
101
|
+
::Cvss3::Metrics::ATTACK_COMPLEXITY[:high]
|
102
|
+
when 'low', 'L'
|
103
|
+
::Cvss3::Metrics::ATTACK_COMPLEXITY[:low]
|
104
|
+
else
|
105
|
+
raise 'Bad Argument'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def ac
|
110
|
+
ac = get_key('ATTACK_COMPLEXITY', @ac) unless @ac.nil?
|
111
|
+
end
|
112
|
+
|
113
|
+
def ui=(ui)
|
114
|
+
@ui = case ui
|
115
|
+
when 'none', 'N'
|
116
|
+
::Cvss3::Metrics::USER_INTERACTION[:none]
|
117
|
+
when 'required', 'R'
|
118
|
+
::Cvss3::Metrics::USER_INTERACTION[:required]
|
119
|
+
else
|
120
|
+
raise 'Bad Argument'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def ui
|
125
|
+
ui = get_key('USER_INTERACTION', @ui) unless @ui.nil?
|
126
|
+
end
|
127
|
+
|
128
|
+
def pr=(pr)
|
129
|
+
@pr = case pr
|
130
|
+
when 'none', 'N'
|
131
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:none]
|
132
|
+
when 'low', 'L'
|
133
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:low]
|
134
|
+
when 'high', 'H'
|
135
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:high]
|
136
|
+
else
|
137
|
+
raise 'Bad Argument'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def pr
|
142
|
+
if @sc == 'changed'
|
143
|
+
pr = get_key('PRIVILEGE_REQUIRED_CHANGED', @pr) unless @pr.nil?
|
144
|
+
else
|
145
|
+
pr = get_key('PRIVILEGE_REQUIRED', @pr) unless @pr.nil?
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def sc=(sc)
|
150
|
+
@sc = case sc
|
151
|
+
when 'changed', 'C'
|
152
|
+
'changed'
|
153
|
+
when 'unchanged', 'U'
|
154
|
+
'unchanged'
|
155
|
+
else
|
156
|
+
raise 'Bad Argument'
|
157
|
+
end
|
158
|
+
|
159
|
+
if @sc == 'changed'
|
160
|
+
tmp = case get_key('PRIVILEGE_REQUIRED', @pr).nil? ? get_key('PRIVILEGE_REQUIRED_CHANGED', @pr) : get_key('PRIVILEGE_REQUIRED', @pr)
|
161
|
+
when 'none', 'N',
|
162
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:none]
|
163
|
+
when 'low', 'L'
|
164
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:low]
|
165
|
+
when 'high', 'H'
|
166
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:high]
|
167
|
+
@pr = tmp unless tmp.nil?
|
168
|
+
end
|
169
|
+
else
|
170
|
+
self.pr = get_key('PRIVILEGE_REQUIRED', @pr).nil? ? get_key('PRIVILEGE_REQUIRED_CHANGED', @pr) : get_key('PRIVILEGE_REQUIRED', @pr)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def sc
|
175
|
+
sc = ::Cvss3::Metrics::SCOPE_KEY[@sc.to_sym] unless @sc.nil?
|
176
|
+
end
|
177
|
+
|
178
|
+
def ci=(ci)
|
179
|
+
@ci = case ci
|
180
|
+
when 'none', 'N'
|
181
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
182
|
+
when 'low', 'L'
|
183
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
184
|
+
when 'high', 'H'
|
185
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
186
|
+
else
|
187
|
+
raise 'Bad Argument'
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def ci
|
192
|
+
ci = get_key('CIA_IMPACT', @ci) unless @ci.nil?
|
193
|
+
end
|
194
|
+
|
195
|
+
def ii=(ii)
|
196
|
+
@ii = case ii
|
197
|
+
when 'none', 'N'
|
198
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
199
|
+
when 'low', 'L'
|
200
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
201
|
+
when 'high', 'H'
|
202
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
203
|
+
else
|
204
|
+
raise 'Bad Argument'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def ii
|
209
|
+
ii = get_key('CIA_IMPACT', @ii) unless @ii.nil?
|
210
|
+
end
|
211
|
+
|
212
|
+
def ai=(ai)
|
213
|
+
@ai = case ai
|
214
|
+
when 'none', 'N'
|
215
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
216
|
+
when 'low', 'L'
|
217
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
218
|
+
when 'high', 'H'
|
219
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
220
|
+
else
|
221
|
+
raise 'Bad Argument'
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def ai
|
226
|
+
ai = get_key('CIA_IMPACT', @ai) unless @ai.nil?
|
227
|
+
end
|
228
|
+
|
229
|
+
def mav=(mav)
|
230
|
+
@mav = case mav
|
231
|
+
when 'physical', 'P'
|
232
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:physical]
|
233
|
+
when 'local', 'L'
|
234
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:local]
|
235
|
+
when 'adjacent network', 'A'
|
236
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:adjacent_network]
|
237
|
+
when 'network', 'N'
|
238
|
+
::Cvss3::Metrics::ATTACK_VECTOR[:network]
|
239
|
+
when 'not_defined', 'ND'
|
240
|
+
nil
|
241
|
+
else
|
242
|
+
raise 'Bad Argument'
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def mav(raw = false)
|
247
|
+
if raw
|
248
|
+
@mav ||= @av
|
249
|
+
else
|
250
|
+
mav = get_key('ATTACK_VECTOR', @mav) unless @mav.nil?
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def mac=(mac)
|
255
|
+
@mac = case mac
|
256
|
+
when 'high', 'H'
|
257
|
+
::Cvss3::Metrics::ATTACK_COMPLEXITY[:high]
|
258
|
+
when 'low', 'L'
|
259
|
+
::Cvss3::Metrics::ATTACK_COMPLEXITY[:low]
|
260
|
+
when 'not_defined', 'ND'
|
261
|
+
nil
|
262
|
+
else
|
263
|
+
raise 'Bad Argument'
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def mac(raw = false)
|
268
|
+
if raw
|
269
|
+
@mac ||= @ac
|
270
|
+
else
|
271
|
+
mac = get_key('ATTACK_COMPLEXITY', @mac) unless @mac.nil?
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def mui=(mui)
|
276
|
+
@mui = case mui
|
277
|
+
when 'none', 'N'
|
278
|
+
::Cvss3::Metrics::USER_INTERACTION[:none]
|
279
|
+
when 'required', 'R'
|
280
|
+
::Cvss3::Metrics::USER_INTERACTION[:required]
|
281
|
+
when 'not_defined', 'ND'
|
282
|
+
nil
|
283
|
+
else
|
284
|
+
raise 'Bad Argument'
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def mui(raw = false)
|
289
|
+
if raw
|
290
|
+
@mui ||= @ui
|
291
|
+
else
|
292
|
+
mui = get_key('USER_INTERACTION', @mui) unless @mui.nil?
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def mpr=(mpr)
|
297
|
+
@mpr = case mpr
|
298
|
+
when 'none', 'N'
|
299
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:none]
|
300
|
+
when 'low', 'L'
|
301
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:low]
|
302
|
+
when 'high', 'H'
|
303
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED[:high]
|
304
|
+
when 'not_defined', 'ND'
|
305
|
+
nil
|
306
|
+
else
|
307
|
+
raise 'Bad Argument'
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def mpr(raw = false)
|
312
|
+
if raw
|
313
|
+
@mpr ||= @pr
|
314
|
+
else
|
315
|
+
if @ms == 'changed'
|
316
|
+
mpr = get_key('PRIVILEGE_REQUIRED_CHANGED', @mpr) unless @mpr.nil?
|
317
|
+
else
|
318
|
+
mpr = get_key('PRIVILEGE_REQUIRED', @mpr) unless @mpr.nil?
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def ms=(ms)
|
324
|
+
@ms = case ms
|
325
|
+
when 'changed', 'C'
|
326
|
+
'changed'
|
327
|
+
when 'unchanged', 'U'
|
328
|
+
'unchanged'
|
329
|
+
when 'not_defined', 'ND'
|
330
|
+
nil
|
331
|
+
else
|
332
|
+
raise 'Bad Argument'
|
333
|
+
end
|
334
|
+
|
335
|
+
if @ms == 'changed'
|
336
|
+
@mpr = case get_key('PRIVILEGE_REQUIRED', mpr(true)).nil? ? get_key('PRIVILEGE_REQUIRED_CHANGED', mpr(true)) : get_key('PRIVILEGE_REQUIRED', mpr(true))
|
337
|
+
when 'none', 'N',
|
338
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:none]
|
339
|
+
when 'low', 'L'
|
340
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:low]
|
341
|
+
when 'high', 'H'
|
342
|
+
::Cvss3::Metrics::PRIVILEGE_REQUIRED_CHANGED[:high]
|
343
|
+
else
|
344
|
+
raise 'Bad Argument'
|
345
|
+
end
|
346
|
+
else
|
347
|
+
self.mpr = get_key('PRIVILEGE_REQUIRED', mpr(true)).nil? ? get_key('PRIVILEGE_REQUIRED_CHANGED', mpr(true)) : get_key('PRIVILEGE_REQUIRED', mpr(true))
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def ms(raw = false)
|
352
|
+
if raw
|
353
|
+
@ms ||= @sc
|
354
|
+
else
|
355
|
+
if @ms.nil?
|
356
|
+
ms = ::Cvss3::Metrics::SCOPE_KEY[@sc.to_sym] unless @sc.nil?
|
357
|
+
else
|
358
|
+
ms = ::Cvss3::Metrics::SCOPE_KEY[@ms.to_sym] unless @ms.nil?
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def mc=(mc)
|
364
|
+
@mc = case mc
|
365
|
+
when 'none', 'N'
|
366
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
367
|
+
when 'low', 'L'
|
368
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
369
|
+
when 'high', 'H'
|
370
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
371
|
+
when 'not_defined', 'ND'
|
372
|
+
nil
|
373
|
+
else
|
374
|
+
raise 'Bad Argument'
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def mc(raw = false)
|
379
|
+
if raw
|
380
|
+
@mv ||= @ci
|
381
|
+
else
|
382
|
+
mc = get_key('CIA_IMPACT', @mc) unless @mc.nil?
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def mi=(mi)
|
387
|
+
@mi = case mi
|
388
|
+
when 'none', 'N'
|
389
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
390
|
+
when 'low', 'L'
|
391
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
392
|
+
when 'high', 'H'
|
393
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
394
|
+
when 'not_defined', 'ND'
|
395
|
+
nil
|
396
|
+
else
|
397
|
+
raise 'Bad Argument'
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
def mi(raw = false)
|
402
|
+
if raw
|
403
|
+
@mi ||= @ii
|
404
|
+
else
|
405
|
+
mi = get_key('CIA_IMPACT', @mi) unless @mi.nil?
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
def ma=(ma)
|
410
|
+
@ma = case ma
|
411
|
+
when 'none', 'N'
|
412
|
+
::Cvss3::Metrics::CIA_IMPACT[:none]
|
413
|
+
when 'low', 'L'
|
414
|
+
::Cvss3::Metrics::CIA_IMPACT[:low]
|
415
|
+
when 'high', 'H'
|
416
|
+
::Cvss3::Metrics::CIA_IMPACT[:high]
|
417
|
+
when 'not_defined', 'ND'
|
418
|
+
nil
|
419
|
+
else
|
420
|
+
raise 'Bad Argument'
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
def ma(raw = false)
|
425
|
+
if raw
|
426
|
+
@ma ||= @ai
|
427
|
+
else
|
428
|
+
ma = get_key('CIA_IMPACT', @ma) unless @ma.nil?
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def ex=(ex)
|
433
|
+
@ex = case ex
|
434
|
+
when 'unproven', 'U' then ::Cvss3::Metrics::EXPLOITABILITY[:unproven]
|
435
|
+
when 'proof-of-concept', 'P', 'POC' then ::Cvss3::Metrics::EXPLOITABILITY[:poc]
|
436
|
+
when 'functional', 'F' then ::Cvss3::Metrics::EXPLOITABILITY[:functional]
|
437
|
+
when 'high', 'H' then ::Cvss3::Metrics::EXPLOITABILITY[:high]
|
438
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::EXPLOITABILITY[:not_defined]
|
439
|
+
else
|
440
|
+
raise 'Bad Argument'
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
def ex
|
445
|
+
ex = get_key('EXPLOITABILITY', @ex) unless @ex.nil?
|
446
|
+
end
|
447
|
+
|
448
|
+
def rl=(rl)
|
449
|
+
@rl = case rl
|
450
|
+
when 'official-fix', 'O' then ::Cvss3::Metrics::REMEDIATION_LEVEL[:official]
|
451
|
+
when 'temporary-fix', 'T', 'TF' then ::Cvss3::Metrics::REMEDIATION_LEVEL[:temporary]
|
452
|
+
when 'workaround', 'W' then ::Cvss3::Metrics::REMEDIATION_LEVEL[:workaround]
|
453
|
+
when 'unavailable', 'U' then ::Cvss3::Metrics::REMEDIATION_LEVEL[:unavailable]
|
454
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::REMEDIATION_LEVEL[:not_defined]
|
455
|
+
else
|
456
|
+
raise 'Bad Argument'
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
def rl
|
461
|
+
rl = get_key('REMEDIATION_LEVEL', @rl) unless @rl.nil?
|
462
|
+
end
|
463
|
+
|
464
|
+
def rc=(rc)
|
465
|
+
@rc = case rc
|
466
|
+
when 'unknown', 'U' then ::Cvss3::Metrics::REPORT_CONFIDENCE[:unknown]
|
467
|
+
when 'reasonable', 'R' then ::Cvss3::Metrics::REPORT_CONFIDENCE[:reasonable]
|
468
|
+
when 'confirmed', 'C' then ::Cvss3::Metrics::REPORT_CONFIDENCE[:confirmed]
|
469
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::REPORT_CONFIDENCE[:not_defined]
|
470
|
+
else
|
471
|
+
raise 'Bad Argument'
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def rc
|
476
|
+
rc = get_key('REPORT_CONFIDENCE', @rc) unless @av.nil?
|
477
|
+
end
|
478
|
+
|
479
|
+
def cr=(cr)
|
480
|
+
@cr = case cr
|
481
|
+
when 'low', 'L' then ::Cvss3::Metrics::CIA_REQUIREMENT[:low]
|
482
|
+
when 'medium', 'M' then ::Cvss3::Metrics::CIA_REQUIREMENT[:medium]
|
483
|
+
when 'high', 'H' then ::Cvss3::Metrics::CIA_REQUIREMENT[:high]
|
484
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::CIA_REQUIREMENT[:not_defined]
|
485
|
+
else
|
486
|
+
raise 'Bad Argument'
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
def cr
|
491
|
+
cr = get_key('CIA_REQUIREMENT', @cr) unless @cr.nil?
|
492
|
+
end
|
493
|
+
|
494
|
+
def ir=(ir)
|
495
|
+
@ir = case ir
|
496
|
+
when 'low', 'L' then ::Cvss3::Metrics::CIA_REQUIREMENT[:low]
|
497
|
+
when 'medium', 'M' then ::Cvss3::Metrics::CIA_REQUIREMENT[:medium]
|
498
|
+
when 'high', 'H' then ::Cvss3::Metrics::CIA_REQUIREMENT[:high]
|
499
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::CIA_REQUIREMENT[:not_defined]
|
500
|
+
else
|
501
|
+
raise 'Bad Argument'
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
def ir
|
506
|
+
ir = get_key('CIA_REQUIREMENT', @ir) unless @ir.nil?
|
507
|
+
end
|
508
|
+
|
509
|
+
def ar=(ar)
|
510
|
+
@ar = case ar
|
511
|
+
when 'low', 'L' then ::Cvss3::Metrics::CIA_REQUIREMENT[:low]
|
512
|
+
when 'medium', 'M' then ::Cvss3::Metrics::CIA_REQUIREMENT[:medium]
|
513
|
+
when 'high', 'H' then ::Cvss3::Metrics::CIA_REQUIREMENT[:high]
|
514
|
+
when 'not defined', 'ND', 'X' then ::Cvss3::Metrics::CIA_REQUIREMENT[:not_defined]
|
515
|
+
else
|
516
|
+
raise 'Bad Argument'
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
def ar
|
521
|
+
ar = get_key('CIA_REQUIREMENT', @ar) unless @ar.nil?
|
522
|
+
end
|
523
|
+
|
524
|
+
def init(ex = 'ND', rl = 'ND', rc = 'ND', _cd = 'ND', _td = 'ND', cr = 'ND', ir = 'ND', ar = 'ND',
|
525
|
+
mav = 'ND', mac = 'ND', mpv = 'ND', mui = 'ND', mc = 'ND', mi = 'ND', ma = 'ND', ms = 'ND')
|
526
|
+
self.ex = ex
|
527
|
+
self.rl = rl
|
528
|
+
self.rc = rc
|
529
|
+
|
530
|
+
self.cr = cr
|
531
|
+
self.ir = ir
|
532
|
+
self.ar = ar
|
533
|
+
|
534
|
+
self.mav = mav
|
535
|
+
self.mac = mac
|
536
|
+
self.mpr = mpv
|
537
|
+
self.mui = mui
|
538
|
+
|
539
|
+
self.mc = mc
|
540
|
+
self.mi = mi
|
541
|
+
self.ma = ma
|
542
|
+
end
|
543
|
+
end
|