-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemo.html
137 lines (131 loc) · 5.85 KB
/
demo.html
1
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Vuln/Vects | Demo</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<!-- Font Awesome CSS -->
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css"
integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">
<!-- Compiled source for Vuln/Vects -->
<script type="text/javascript" src="bundle/vuln-vects.js"></script>
<script type="text/javascript">
/**
* Updates the score label associated with the text field with the specified ID.
*
* @param id {str} the ID of the text field
*/
function updateScoreLabel(id) {
// Grab target text field.
var textField = $(`#${id}`);
// Attempt to parse vector.
try {
var score = VulnVects.parseCvssVector(textField.val());
var roundedScore = Math.round(score._overallScore * 10) / 10;
var label = $(`#${id}_label`);
label.html(roundedScore);
if (roundedScore === 0) { // Set background colour appropriately.
label.css('background', '#71BC78');
} else if (roundedScore > 0 && roundedScore < 4) {
label.css('background', '#FFFF99');
} else if (roundedScore >= 4 && roundedScore < 7) {
label.css('background', '#FED8B1');
} else if (roundedScore >= 7 && roundedScore < 9) {
label.css('background', '#CD5C5C');
} else if (roundedScore >= 9) {
label.css('background', '#A45953');
}
} catch (e) {
// Show error message.
alert('Invalid CVSS vector provided. Message: "' + e.message + '"');
}
}
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 mb-5 mt-5 text-center">
<img src="logo.svg">
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<p>
Lorem
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Example</h2>
<p>
The following example shows the calculation of an overall score from a CVSS v2.0 vector.
</p>
<div class="input-group mb-3">
<input id="vectorField1" value="CVSS2#AV:A/AC:L/Au:M/C:C/I:P/A:C" type="text" class="form-control">
<div class="input-group-append">
<label id="vectorField1_label" class="input-group-text" for="vectorField1">0.0</label>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary" onclick="updateScoreLabel('vectorField1');"
type="button">Calculate</button>
</div>
</div>
<p>
The next example shows the calculation of an overall score from a CVSS v3.0/1 vector.
</p>
<div class="input-group mb-3">
<input id="vectorField2" value="CVSS:3.0/AV:A/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L" type="text"
class="form-control">
<div class="input-group-append">
<label id="vectorField2_label" class="input-group-text" for="vectorField2">0.0</label>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary" onclick="updateScoreLabel('vectorField2');"
type="button">Calculate</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<h2>Usage</h2>
<p>
Usage is extremely straightforward. Simply import the script into your HTML file:
</p>
<pre><code>
<script src="node_modules/vuln-vects/dist/vuln-vects.js"></script>
</code></pre>
<p>
Now, you can calculate the numeric score from a CVSS vector easily. Score will be calculated using
an appropriate algorithm depending on the CVSS vector version detected by the library.
</p>
<pre><code>
<script>
$(document).ready(function() {
console.log(VulnVects.parseCvssVector('CVSS2#AV:A/AC:L/Au:M/C:C/I:P/A:C'));
console.log(VulnVects.parseCvssVector('CVSS:3.0/AV:A/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L'));
});
</script>
</code></pre>
</div>
</div>
<div class="row">
<div class="col-md-12 mb-5 text-center text-muted">
<small>Built by <a href="https://breachlock.com" target="_blank">BreachLock Inc.</a></small>
</div>
</div>
</div>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js"
integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js"
integrity="sha384-+YQ4JLhjyBLPDQt//I+STsc9iw4uQqACwlvpslubQzn4u2UU2UFM80nGisd026JF"
crossorigin="anonymous"></script>
</body>
</html>