From 49d509d62f79062e8d09a8108a8aef20417e691a Mon Sep 17 00:00:00 2001 From: n3rada <72791564+n3rada@users.noreply.github.com> Date: Fri, 30 Aug 2024 17:09:54 +0200 Subject: [PATCH 1/6] Update README.md --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f9ce75b..aa1cd42 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # CVSS v4.0 calculator +The CVSS v4.0 Calculator is built based on the Common Vulnerability Scoring System (CVSS) version 4.0 [Specification Document](https://www.first.org/cvss/v4.0/specification-document). This document serves as the authoritative reference for understanding how to calculate the severity of vulnerabilities. -Deployed: https://redhatproductsecurity.github.io/cvss-v4-calculator/ \ No newline at end of file +This project is a web-based application that calculates the CVSS score for a given vulnerability. The core logic is implemented using JavaScript classes that encapsulate the CVSS metrics, scoring calculations, and vector string manipulations: + +- The `Vector` class handles the CVSS vector string and the associated metrics. It is the backbone of the application's logic, providing methods to update and validate the vector string, compute equivalent classes, and derive metrics values. +- The `CVSS40` class is responsible for calculating the CVSS v4.0 score. It interacts with an instance of the `Vector` class to derive the score and determine the severity level. + +The application is live and can be accessed at [CVSS v4.0 Calculator](https://redhatproductsecurity.github.io/cvss-v4-calculator/). + +## License +This project is licensed under the BSD-2-Clause License. See the [LICENSE](./LICENSE) file for more information. From 8dd3c59befef434ee8d10462111e00f6b2439b07 Mon Sep 17 00:00:00 2001 From: n3rada <72791564+n3rada@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:11:03 +0200 Subject: [PATCH 2/6] Update `severityBreakdown` for issue #33 --- cvss40.js | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/cvss40.js b/cvss40.js index 0e134a7..ddd7408 100644 --- a/cvss40.js +++ b/cvss40.js @@ -297,7 +297,8 @@ class Vector { */ get severityBreakdown() { const macroVector = this.equivalentClasses; - + + // Define the descriptions and their corresponding indices in the equivalent classes string const macroVectorDetails = { "Exploitability": 0, "Complexity": 1, @@ -306,20 +307,37 @@ class Vector { "Exploitation": 4, "Security requirements": 5 }; - - const macroVectorValues = { + + // Lookup table for macrovectors with three possible values + const macroVectorValuesThreeOptions = { "0": "High", "1": "Medium", - "2": "Low", - "3": "None" + "2": "Low" }; - - // Constructing the detailed breakdown + + // Lookup table for macrovectors with two possible values + const macroVectorValuesTwoOptions = { + "0": "High", + "1": "Low" + }; + + // Define which macrovectors have three values and which have two + const threeValueMacrovectors = [0, 2, 3, 4]; // Indices for macrovectors 1, 3, 4, 5 (0-based index) + const twoValueMacrovectors = [1, 5]; // Indices for macrovectors 2 and 6 (0-based index) + + // Construct the detailed breakdown return Object.fromEntries( - Object.entries(macroVectorDetails).map(([description, index]) => [ - description, - macroVectorValues[macroVector[index]] - ]) + Object.entries(macroVectorDetails).map(([description, index]) => { + const currentValue = macroVector[index]; + // Use the appropriate lookup table based on the macrovector + const lookupTable = threeValueMacrovectors.includes(index) + ? macroVectorValuesThreeOptions + : macroVectorValuesTwoOptions; + return [ + description, + lookupTable[currentValue] + ]; + }) ); } From 98a8370413199fac6101d3df8907baed917c7c32 Mon Sep 17 00:00:00 2001 From: n3rada <72791564+n3rada@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:10:09 +0000 Subject: [PATCH 3/6] Adapting to FIRST commits --- index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5c9a801..548d135 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@ - CVSS v4.0 calculator + Common Vulnerability Scoring System Version 4.0 Calculator @@ -41,7 +41,8 @@