Skip to content

Commit b2a90f4

Browse files
committed
fix ci
1 parent 5e977c3 commit b2a90f4

File tree

6 files changed

+187
-132
lines changed

6 files changed

+187
-132
lines changed

build.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import dts from "bun-plugin-dts";
2-
31
const output = await Bun.build({
42
entrypoints: ["index.ts"],
53
outdir: "./dist",
64
target: "browser",
75
minify: false,
8-
plugins: [dts()],
96
define: {
107
global: "window",
118
},
@@ -22,7 +19,6 @@ const output2 = await Bun.build({
2219
outdir: "./dist_node",
2320
target: "node",
2421
minify: false,
25-
plugins: [dts()],
2622
define: {
2723
window: "undefined",
2824
},

bun.lockb

-10.7 KB
Binary file not shown.

dist/index.js

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -922,28 +922,28 @@ var maxSeverity = {
922922
};
923923

924924
// lib/util.ts
925-
var findMetric = function(abbr, cvssVersion) {
925+
function findMetric(abbr, cvssVersion) {
926926
const definitions3 = cvssVersion === "4.0" ? definitions2 : definitions;
927927
return definitions3.definitions.find((def) => def.abbr === abbr);
928-
};
929-
var findMetricValue = function(abbr, vectorObject) {
928+
}
929+
function findMetricValue(abbr, vectorObject) {
930930
const definition = findMetric(abbr, vectorObject.CVSS);
931931
let value = definition?.metrics.find((metric) => metric.abbr === vectorObject[definition.abbr]);
932932
return value;
933-
};
934-
var roundUpApprox = function(num, precision) {
933+
}
934+
function roundUpApprox(num, precision) {
935935
precision = Math.pow(10, precision);
936936
return Math.ceil(num * precision) / precision;
937-
};
938-
var roundUpExact = function(num) {
937+
}
938+
function roundUpExact(num) {
939939
const int_input = Math.round(num * 1e5);
940940
if (int_input % 1e4 === 0) {
941941
return int_input / 1e5;
942942
} else {
943943
return (Math.floor(int_input / 1e4) + 1) / 10;
944944
}
945-
};
946-
var getVectorObject = function(vector) {
945+
}
946+
function getVectorObject(vector) {
947947
const vectorArray = vector.split("/");
948948
const definitions3 = vector.includes("4.0") ? definitions2 : definitions;
949949
const vectorObject = definitions3.definitions.map((definition) => definition.abbr).reduce((acc, curr) => {
@@ -955,8 +955,8 @@ var getVectorObject = function(vector) {
955955
vectorObject[values[0]] = values[1];
956956
}
957957
return vectorObject;
958-
};
959-
var getCleanVectorString = function(vector) {
958+
}
959+
function getCleanVectorString(vector) {
960960
const vectorArray = vector.split("/");
961961
const cleanVectorArray = [];
962962
for (const entry of vectorArray) {
@@ -965,8 +965,8 @@ var getCleanVectorString = function(vector) {
965965
cleanVectorArray.push(entry);
966966
}
967967
return cleanVectorArray.join("/");
968-
};
969-
var getDetailedVectorObject = function(vector) {
968+
}
969+
function getDetailedVectorObject(vector) {
970970
const vectorArray = vector.split("/");
971971
const vectorObject = vectorArray.reduce((vectorObjectAccumulator, vectorItem, index) => {
972972
const values = vectorItem.split(":");
@@ -992,8 +992,8 @@ var getDetailedVectorObject = function(vector) {
992992
}
993993
}, { metrics: {}, CVSS: "" });
994994
return vectorObject;
995-
};
996-
var getRating = function(score) {
995+
}
996+
function getRating(score) {
997997
let rating = "None";
998998
if (score === 0) {
999999
rating = "None";
@@ -1007,8 +1007,8 @@ var getRating = function(score) {
10071007
rating = "Critical";
10081008
}
10091009
return rating;
1010-
};
1011-
var isVectorValid = function(vector) {
1010+
}
1011+
function isVectorValid(vector) {
10121012
const definitions3 = vector.includes("4.0") ? definitions2 : definitions;
10131013
const expression = definitions3.definitions.reduce((accumulator, currentValue, index) => {
10141014
const serializedAbbr = `${currentValue.abbr}:[${currentValue.metrics.reduce((accumulator2, currentValue2) => {
@@ -1045,8 +1045,8 @@ var isVectorValid = function(vector) {
10451045
}
10461046
}
10471047
return true;
1048-
};
1049-
var parseVectorObjectToString = function(cvssInput) {
1048+
}
1049+
function parseVectorObjectToString(cvssInput) {
10501050
if (typeof cvssInput === "string") {
10511051
return cvssInput;
10521052
}
@@ -1060,14 +1060,14 @@ var parseVectorObjectToString = function(cvssInput) {
10601060
}
10611061
vectorString = vectorString.slice(0, -1);
10621062
return vectorString;
1063-
};
1064-
var updateVectorValue = function(vector, metric, value) {
1063+
}
1064+
function updateVectorValue(vector, metric, value) {
10651065
const vectorObject = getVectorObject(vector);
10661066
vectorObject[metric] = value;
10671067
const vectorString = parseVectorObjectToString(vectorObject);
10681068
return getCleanVectorString(vectorString);
1069-
};
1070-
var getVersion = function(vector) {
1069+
}
1070+
function getVersion(vector) {
10711071
const version = vector.split("/");
10721072
if (version[0] === "CVSS:3.0") {
10731073
return "3.0";
@@ -1078,7 +1078,7 @@ var getVersion = function(vector) {
10781078
} else {
10791079
return "Error";
10801080
}
1081-
};
1081+
}
10821082
var util = {
10831083
roundUpExact,
10841084
roundUpApprox,
@@ -1095,7 +1095,7 @@ var util = {
10951095
};
10961096

10971097
// lib/score_3_0.ts
1098-
var getScore = function(vector) {
1098+
function getScore(vector) {
10991099
const vectorObject = util.getVectorObject(vector);
11001100
const scopeChanged = vectorObject.S === "C";
11011101
const ISCBase = calculateISCBase(vectorObject);
@@ -1107,8 +1107,8 @@ var getScore = function(vector) {
11071107
return roundUp(Math.min(1.08 * (ISC + exploitability), 10), 1, vector);
11081108
}
11091109
return roundUp(Math.min(ISC + exploitability, 10), 1, vector);
1110-
};
1111-
var getTemporalScore = function(vector) {
1110+
}
1111+
function getTemporalScore(vector) {
11121112
const vectorObject = util.getVectorObject(vector);
11131113
const baseScore = getScore(vector);
11141114
const eMetric = util.findMetricValue("E", vectorObject);
@@ -1118,14 +1118,14 @@ var getTemporalScore = function(vector) {
11181118
const rcMetric = util.findMetricValue("RC", vectorObject);
11191119
const reportConfidence = rcMetric ? rcMetric.numerical : 1;
11201120
return roundUp(baseScore * exploitCodeMaturity * remediationLevel * reportConfidence, 1, vector);
1121-
};
1122-
var calculateISCBase = function(vectorObject) {
1121+
}
1122+
function calculateISCBase(vectorObject) {
11231123
const cValue = util.findMetricValue("C", vectorObject).numerical;
11241124
const iValue = util.findMetricValue("I", vectorObject).numerical;
11251125
const aValue = util.findMetricValue("A", vectorObject).numerical;
11261126
return 1 - (1 - cValue) * (1 - iValue) * (1 - aValue);
1127-
};
1128-
var getEnvironmentalScore = function(vector) {
1127+
}
1128+
function getEnvironmentalScore(vector) {
11291129
const vectorObject = util.getVectorObject(vector);
11301130
const scopeChanged = vectorObject.MS === "X" ? vectorObject.S === "C" : vectorObject.MS === "C";
11311131
const modifiedISCBase = calculateISCModifiedBase(vectorObject);
@@ -1143,32 +1143,32 @@ var getEnvironmentalScore = function(vector) {
11431143
return roundUp(roundUp(Math.min(modifiedISC + modifiedExploitability, 10), 1, vector) * eValue * rlValue * rcValue, 1, vector);
11441144
}
11451145
return roundUp(roundUp(Math.min(1.08 * (modifiedISC + modifiedExploitability), 10), 1, vector) * eValue * rlValue * rcValue, 1, vector);
1146-
};
1147-
var calculateISC = function(iscBase, scopeChanged, vector) {
1146+
}
1147+
function calculateISC(iscBase, scopeChanged, vector) {
11481148
if (!scopeChanged)
11491149
return 6.42 * iscBase;
11501150
if (util.getVersion(vector) === "3.0") {
11511151
return 7.52 * (iscBase - 0.029) - 3.25 * Math.pow(iscBase - 0.02, 15);
11521152
}
11531153
return 7.52 * (iscBase - 0.029) - 3.25 * Math.pow(iscBase - 0.02, 15);
1154-
};
1155-
var calculateModifiedISC = function(iscBase, scopeChanged, vector) {
1154+
}
1155+
function calculateModifiedISC(iscBase, scopeChanged, vector) {
11561156
if (!scopeChanged)
11571157
return 6.42 * iscBase;
11581158
if (util.getVersion(vector) === "3.0") {
11591159
return 7.52 * (iscBase - 0.029) - 3.25 * Math.pow(iscBase - 0.02, 15);
11601160
}
11611161
return 7.52 * (iscBase - 0.029) - 3.25 * Math.pow(iscBase * 0.9731 - 0.02, 13);
1162-
};
1163-
var calculateExploitability = function(vectorObject, scopeChanged) {
1162+
}
1163+
function calculateExploitability(vectorObject, scopeChanged) {
11641164
const avValue = util.findMetricValue("AV", vectorObject).numerical;
11651165
const acValue = util.findMetricValue("AC", vectorObject).numerical;
11661166
const prMetrics = util.findMetricValue("PR", vectorObject).numerical;
11671167
const uiValue = util.findMetricValue("UI", vectorObject).numerical;
11681168
const prValue = scopeChanged ? prMetrics.changed : prMetrics.unchanged;
11691169
return 8.22 * avValue * acValue * prValue * uiValue;
1170-
};
1171-
var calculateISCModifiedBase = function(vectorObject) {
1170+
}
1171+
function calculateISCModifiedBase(vectorObject) {
11721172
let mcValue = util.findMetricValue("MC", vectorObject);
11731173
let miValue = util.findMetricValue("MI", vectorObject);
11741174
let maValue = util.findMetricValue("MA", vectorObject);
@@ -1182,8 +1182,8 @@ var calculateISCModifiedBase = function(vectorObject) {
11821182
if (!maValue || maValue.abbr === "X")
11831183
maValue = util.findMetricValue("A", vectorObject);
11841184
return Math.min(1 - (1 - mcValue.numerical * crValue) * (1 - miValue.numerical * irValue) * (1 - maValue.numerical * arValue), 0.915);
1185-
};
1186-
var calculateModifiedExploitability = function(vectorObject, scopeChanged) {
1185+
}
1186+
function calculateModifiedExploitability(vectorObject, scopeChanged) {
11871187
let mavValue = util.findMetricValue("MAV", vectorObject);
11881188
let macValue = util.findMetricValue("MAC", vectorObject);
11891189
let mprMetrics = util.findMetricValue("MPR", vectorObject);
@@ -1198,24 +1198,24 @@ var calculateModifiedExploitability = function(vectorObject, scopeChanged) {
11981198
muiValue = util.findMetricValue("UI", vectorObject);
11991199
const mprValue = scopeChanged ? mprMetrics.numerical.changed : mprMetrics.numerical.unchanged;
12001200
return 8.22 * mavValue.numerical * macValue.numerical * mprValue * muiValue.numerical;
1201-
};
1202-
var roundUp = function(num, precision, vector) {
1201+
}
1202+
function roundUp(num, precision, vector) {
12031203
if (util.getVersion(vector) === "3.0") {
12041204
return util.roundUpApprox(num, precision);
12051205
}
12061206
return util.roundUpExact(num);
1207-
};
1208-
var getImpactSubScore = function(vector) {
1207+
}
1208+
function getImpactSubScore(vector) {
12091209
const vectorObject = util.getVectorObject(vector);
12101210
const { S } = vectorObject;
12111211
const ISCBase = calculateISCBase(vectorObject);
12121212
return Number(calculateISC(ISCBase, S === "C", vector).toFixed(1));
1213-
};
1214-
var getExploitabilitySubScore = function(vector) {
1213+
}
1214+
function getExploitabilitySubScore(vector) {
12151215
const vectorObject = util.getVectorObject(vector);
12161216
const { S } = vectorObject;
12171217
return Number(calculateExploitability(vectorObject, S === "C").toFixed(1));
1218-
};
1218+
}
12191219
var score = {
12201220
getScore,
12211221
getTemporalScore,
@@ -1225,7 +1225,7 @@ var score = {
12251225
};
12261226

12271227
// lib/score_4_0.ts
1228-
var parseMetric = function(abbr, vectorObject) {
1228+
function parseMetric(abbr, vectorObject) {
12291229
const definition = util.findMetric(abbr, vectorObject.CVSS);
12301230
let value = util.findMetricValue(abbr, vectorObject);
12311231
if (vectorObject.CVSS === "4.0") {
@@ -1247,8 +1247,8 @@ var parseMetric = function(abbr, vectorObject) {
12471247
}
12481248
}
12491249
return value;
1250-
};
1251-
var eq3eq6CalculateLowerMacroVector = function(eqLevels) {
1250+
}
1251+
function eq3eq6CalculateLowerMacroVector(eqLevels) {
12521252
if (eqLevels.eq3 === "1" && eqLevels.eq6 === "1") {
12531253
return cvssLookup_global[`${eqLevels.eq1}${eqLevels.eq2}${parseInt(eqLevels.eq3) + 1}${eqLevels.eq4}${eqLevels.eq5}${eqLevels.eq6}`];
12541254
}
@@ -1264,8 +1264,8 @@ var eq3eq6CalculateLowerMacroVector = function(eqLevels) {
12641264
return eq3eq6NextLowerLeftMarcoVector > eq3eq6NextLowerRightMarcoVector ? eq3eq6NextLowerLeftMarcoVector : eq3eq6NextLowerRightMarcoVector;
12651265
}
12661266
return cvssLookup_global[`${eqLevels.eq1}${eqLevels.eq2}${parseInt(eqLevels.eq3) + 1}${eqLevels.eq4}${eqLevels.eq5}${parseInt(eqLevels.eq6) + 1}`];
1267-
};
1268-
var getScore2 = function(vector) {
1267+
}
1268+
function getScore2(vector) {
12691269
const vectorObj = util.getVectorObject(vector);
12701270
const metrics = {
12711271
AV: {},
@@ -1448,21 +1448,21 @@ var getScore2 = function(vector) {
14481448
vectorScore = 10;
14491449
}
14501450
return parseFloat(vectorScore.toFixed(1));
1451-
};
1452-
var getTemporalScore2 = function(vector) {
1451+
}
1452+
function getTemporalScore2(vector) {
14531453
throw new Error("This function is not supported for this cvss version");
14541454
return 0;
1455-
};
1456-
var getEnvironmentalScore2 = function(vector) {
1455+
}
1456+
function getEnvironmentalScore2(vector) {
14571457
throw new Error("This function is not supported for this cvss version");
14581458
return 0;
1459-
};
1460-
var getImpactSubScore2 = function(vector) {
1459+
}
1460+
function getImpactSubScore2(vector) {
14611461
throw new Error("This function is not supported for this cvss version");
1462-
};
1463-
var getExploitabilitySubScore2 = function(vector) {
1462+
}
1463+
function getExploitabilitySubScore2(vector) {
14641464
throw new Error("This function is not supported for this cvss version");
1465-
};
1465+
}
14661466
var score2 = {
14671467
getScore: getScore2,
14681468
getTemporalScore: getTemporalScore2,

0 commit comments

Comments
 (0)