1
1
<h1 align =" center " >cvss.js by <a href =" https://turingpoint.eu " target =" _blank " >turingpoint.</a ></h1 >
2
2
<p >
3
- <img alt =" Version " src =" https://img.shields.io/badge/version-1.4.5 -blue.svg?cacheSeconds=2592000 " />
3
+ <img alt =" Version " src =" https://img.shields.io/badge/version-1.4.6 -blue.svg?cacheSeconds=2592000 " />
4
4
<a href =" # " target =" _blank " >
5
5
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
6
6
</a >
@@ -20,9 +20,9 @@ yarn add @turingpointde/cvss.js
20
20
Import the library to use it in your code:
21
21
22
22
``` js
23
- const CVSS = require (" @turingpointde/cvss.js" );
23
+ const CVSS = require (' @turingpointde/cvss.js' );
24
24
// or
25
- import CVSS from " @turingpointde/cvss.js" ;
25
+ import CVSS from ' @turingpointde/cvss.js' ;
26
26
```
27
27
28
28
You can also use the library directly from the ** CDN** (instead of yarn or npm):
@@ -37,28 +37,30 @@ After importing the library, the CVSS function must first be called with the vec
37
37
38
38
``` js
39
39
// Vector only with base score
40
- const vector1 = CVSS (" CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L" );
40
+ const vector1 = CVSS (' CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L' );
41
41
// Vector with temporal score
42
- const vector2 = CVSS (" CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/E:U/RL:T/RC:R" );
42
+ const vector2 = CVSS (
43
+ ' CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/E:U/RL:T/RC:R' ,
44
+ );
43
45
// Vector with environmental score
44
46
const vector3 = CVSS (
45
- " CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N/CR:M/IR:H/AR:M/MAV:N/MAC:H/MPR:L/MUI:N/MS:C/MC:N/MI:L/MA:L"
47
+ ' CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N/CR:M/IR:H/AR:M/MAV:N/MAC:H/MPR:L/MUI:N/MS:C/MC:N/MI:L/MA:L' ,
46
48
);
47
49
```
48
50
49
51
It is possible to pass in an object as well
50
52
51
53
``` js
52
54
const vectorObject = {
53
- CVSS : " 3.0" ,
54
- AV : " N " ,
55
- AC : " H " ,
56
- PR : " H " ,
57
- UI : " R " ,
58
- S : " U " ,
59
- C : " H " ,
60
- I : " N " ,
61
- A : " N "
55
+ CVSS : ' 3.0' ,
56
+ AV : ' N ' ,
57
+ AC : ' H ' ,
58
+ PR : ' H ' ,
59
+ UI : ' R ' ,
60
+ S : ' U ' ,
61
+ C : ' H ' ,
62
+ I : ' N ' ,
63
+ A : ' N ' ,
62
64
};
63
65
64
66
console .log (CVSS (vectorObject).vector ); // "CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:H/I:N/A:N"
@@ -69,7 +71,7 @@ To get the scores, simply call the respective function.
69
71
``` js
70
72
// Create a vector
71
73
const vector = CVSS (
72
- " CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N/E:P/RL:O/CR:M/IR:H/AR:M/MAV:N/MAC:H/MPR:L/MUI:N/MS:C/MC:N/MI:L/MA:L"
74
+ ' CVSS:3.0/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N/E:P/RL:O/CR:M/IR:H/AR:M/MAV:N/MAC:H/MPR:L/MUI:N/MS:C/MC:N/MI:L/MA:L' ,
73
75
);
74
76
75
77
console .log (vector .getScore ()); // 3.6
@@ -80,7 +82,7 @@ console.log(vector.getEnvironmentalScore()); // 5.1
80
82
Sometimes it is useful to get a qualitative rating of a score
81
83
82
84
``` js
83
- const vector = CVSS (" CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L" );
85
+ const vector = CVSS (' CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L' );
84
86
85
87
console .log (vector .getRating ()); // Medium
86
88
console .log (vector .getTemporalRating ()); // Medium
@@ -90,7 +92,7 @@ console.log(vector.getEnvironmentalRating()); // Low
90
92
A few useful variables/functions to work with the vectors:
91
93
92
94
``` js
93
- const vector = CVSS (" CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L" );
95
+ const vector = CVSS (' CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L' );
94
96
95
97
console .log (vector .isValid ); // true
96
98
console .log (vector .vector ); // CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:N/I:L/A:L
@@ -101,7 +103,7 @@ The following functions are suitable for displaying the vector in a human-readab
101
103
102
104
``` js
103
105
const vector = CVSS (
104
- " CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/E:U/RL:T/RC:R/MAC:X/MUI:X/MA:X/MI:X"
106
+ ' CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/E:U/RL:T/RC:R/MAC:X/MUI:X/MA:X/MI:X' ,
105
107
);
106
108
107
109
console .log (vector .getVectorObject ()); // { CVSS: "3.0", AV: "N", AC: "H", PR: "L", UI: "R", S: "C", C: "L", I: "L", A: "L", E: "U", RL: "T", RC: "R", CR: "X", IR: "X", AR: "X", MAV: "X", MAC: "X", MPR: "X", MUI: "X", MS: "X" , MC: "X", MI: "X", MA: "X" }
0 commit comments