Skip to content

Commit

Permalink
Add nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
n3rada authored Aug 22, 2024
1 parent bcd258b commit f25ed44
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cvss40.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Vector {
return { ...order, ...Vector.METRICS[category] };
}, {});

// Nomenclature base constant
static BASE_NOMENCLATURE = "CVSS-B";

constructor(vectorString = "") {
// Initialize the metrics
const selected = {};
Expand Down Expand Up @@ -220,6 +223,29 @@ class Vector {
return eq1 + eq2 + eq3 + eq4 + eq5 + eq6;
}

/**
* Determines the CVSS nomenclature based on the metrics used in the vector.
* Refer to https://www.first.org/cvss/v4.0/specification-document
*
* @returns {string} - The CVSS nomenclature (e.g., "CVSS-B", "CVSS-BE", "CVSS-BT", "CVSS-BTE").
*/
get nomenclature() {
let nomenclature = Vector.BASE_NOMENCLATURE;

const hasThreatMetrics = Object.keys(Vector.METRICS.THREAT).some(key => this.metrics[key] !== "X");
const hasEnvironmentalMetrics = Object.keys(Vector.METRICS.ENVIRONMENTAL).some(key => this.metrics[key] !== "X");

if (hasThreatMetrics) {
nomenclature += "T";
}

if (hasEnvironmentalMetrics) {
nomenclature += "E";
}

return nomenclature;
}

/**
* Gets the effective value for a given CVSS metric.
*
Expand Down

0 comments on commit f25ed44

Please sign in to comment.