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