@@ -922,28 +922,28 @@ var maxSeverity = {
922
922
} ;
923
923
924
924
// lib/util.ts
925
- var findMetric = function ( abbr , cvssVersion ) {
925
+ function findMetric ( abbr , cvssVersion ) {
926
926
const definitions3 = cvssVersion === "4.0" ? definitions2 : definitions ;
927
927
return definitions3 . definitions . find ( ( def ) => def . abbr === abbr ) ;
928
- } ;
929
- var findMetricValue = function ( abbr , vectorObject ) {
928
+ }
929
+ function findMetricValue ( abbr , vectorObject ) {
930
930
const definition = findMetric ( abbr , vectorObject . CVSS ) ;
931
931
let value = definition ?. metrics . find ( ( metric ) => metric . abbr === vectorObject [ definition . abbr ] ) ;
932
932
return value ;
933
- } ;
934
- var roundUpApprox = function ( num , precision ) {
933
+ }
934
+ function roundUpApprox ( num , precision ) {
935
935
precision = Math . pow ( 10 , precision ) ;
936
936
return Math . ceil ( num * precision ) / precision ;
937
- } ;
938
- var roundUpExact = function ( num ) {
937
+ }
938
+ function roundUpExact ( num ) {
939
939
const int_input = Math . round ( num * 1e5 ) ;
940
940
if ( int_input % 1e4 === 0 ) {
941
941
return int_input / 1e5 ;
942
942
} else {
943
943
return ( Math . floor ( int_input / 1e4 ) + 1 ) / 10 ;
944
944
}
945
- } ;
946
- var getVectorObject = function ( vector ) {
945
+ }
946
+ function getVectorObject ( vector ) {
947
947
const vectorArray = vector . split ( "/" ) ;
948
948
const definitions3 = vector . includes ( "4.0" ) ? definitions2 : definitions ;
949
949
const vectorObject = definitions3 . definitions . map ( ( definition ) => definition . abbr ) . reduce ( ( acc , curr ) => {
@@ -955,8 +955,8 @@ var getVectorObject = function(vector) {
955
955
vectorObject [ values [ 0 ] ] = values [ 1 ] ;
956
956
}
957
957
return vectorObject ;
958
- } ;
959
- var getCleanVectorString = function ( vector ) {
958
+ }
959
+ function getCleanVectorString ( vector ) {
960
960
const vectorArray = vector . split ( "/" ) ;
961
961
const cleanVectorArray = [ ] ;
962
962
for ( const entry of vectorArray ) {
@@ -965,8 +965,8 @@ var getCleanVectorString = function(vector) {
965
965
cleanVectorArray . push ( entry ) ;
966
966
}
967
967
return cleanVectorArray . join ( "/" ) ;
968
- } ;
969
- var getDetailedVectorObject = function ( vector ) {
968
+ }
969
+ function getDetailedVectorObject ( vector ) {
970
970
const vectorArray = vector . split ( "/" ) ;
971
971
const vectorObject = vectorArray . reduce ( ( vectorObjectAccumulator , vectorItem , index ) => {
972
972
const values = vectorItem . split ( ":" ) ;
@@ -992,8 +992,8 @@ var getDetailedVectorObject = function(vector) {
992
992
}
993
993
} , { metrics : { } , CVSS : "" } ) ;
994
994
return vectorObject ;
995
- } ;
996
- var getRating = function ( score ) {
995
+ }
996
+ function getRating ( score ) {
997
997
let rating = "None" ;
998
998
if ( score === 0 ) {
999
999
rating = "None" ;
@@ -1007,8 +1007,8 @@ var getRating = function(score) {
1007
1007
rating = "Critical" ;
1008
1008
}
1009
1009
return rating ;
1010
- } ;
1011
- var isVectorValid = function ( vector ) {
1010
+ }
1011
+ function isVectorValid ( vector ) {
1012
1012
const definitions3 = vector . includes ( "4.0" ) ? definitions2 : definitions ;
1013
1013
const expression = definitions3 . definitions . reduce ( ( accumulator , currentValue , index ) => {
1014
1014
const serializedAbbr = `${ currentValue . abbr } :[${ currentValue . metrics . reduce ( ( accumulator2 , currentValue2 ) => {
@@ -1045,8 +1045,8 @@ var isVectorValid = function(vector) {
1045
1045
}
1046
1046
}
1047
1047
return true ;
1048
- } ;
1049
- var parseVectorObjectToString = function ( cvssInput ) {
1048
+ }
1049
+ function parseVectorObjectToString ( cvssInput ) {
1050
1050
if ( typeof cvssInput === "string" ) {
1051
1051
return cvssInput ;
1052
1052
}
@@ -1060,14 +1060,14 @@ var parseVectorObjectToString = function(cvssInput) {
1060
1060
}
1061
1061
vectorString = vectorString . slice ( 0 , - 1 ) ;
1062
1062
return vectorString ;
1063
- } ;
1064
- var updateVectorValue = function ( vector , metric , value ) {
1063
+ }
1064
+ function updateVectorValue ( vector , metric , value ) {
1065
1065
const vectorObject = getVectorObject ( vector ) ;
1066
1066
vectorObject [ metric ] = value ;
1067
1067
const vectorString = parseVectorObjectToString ( vectorObject ) ;
1068
1068
return getCleanVectorString ( vectorString ) ;
1069
- } ;
1070
- var getVersion = function ( vector ) {
1069
+ }
1070
+ function getVersion ( vector ) {
1071
1071
const version = vector . split ( "/" ) ;
1072
1072
if ( version [ 0 ] === "CVSS:3.0" ) {
1073
1073
return "3.0" ;
@@ -1078,7 +1078,7 @@ var getVersion = function(vector) {
1078
1078
} else {
1079
1079
return "Error" ;
1080
1080
}
1081
- } ;
1081
+ }
1082
1082
var util = {
1083
1083
roundUpExact,
1084
1084
roundUpApprox,
@@ -1095,7 +1095,7 @@ var util = {
1095
1095
} ;
1096
1096
1097
1097
// lib/score_3_0.ts
1098
- var getScore = function ( vector ) {
1098
+ function getScore ( vector ) {
1099
1099
const vectorObject = util . getVectorObject ( vector ) ;
1100
1100
const scopeChanged = vectorObject . S === "C" ;
1101
1101
const ISCBase = calculateISCBase ( vectorObject ) ;
@@ -1107,8 +1107,8 @@ var getScore = function(vector) {
1107
1107
return roundUp ( Math . min ( 1.08 * ( ISC + exploitability ) , 10 ) , 1 , vector ) ;
1108
1108
}
1109
1109
return roundUp ( Math . min ( ISC + exploitability , 10 ) , 1 , vector ) ;
1110
- } ;
1111
- var getTemporalScore = function ( vector ) {
1110
+ }
1111
+ function getTemporalScore ( vector ) {
1112
1112
const vectorObject = util . getVectorObject ( vector ) ;
1113
1113
const baseScore = getScore ( vector ) ;
1114
1114
const eMetric = util . findMetricValue ( "E" , vectorObject ) ;
@@ -1118,14 +1118,14 @@ var getTemporalScore = function(vector) {
1118
1118
const rcMetric = util . findMetricValue ( "RC" , vectorObject ) ;
1119
1119
const reportConfidence = rcMetric ? rcMetric . numerical : 1 ;
1120
1120
return roundUp ( baseScore * exploitCodeMaturity * remediationLevel * reportConfidence , 1 , vector ) ;
1121
- } ;
1122
- var calculateISCBase = function ( vectorObject ) {
1121
+ }
1122
+ function calculateISCBase ( vectorObject ) {
1123
1123
const cValue = util . findMetricValue ( "C" , vectorObject ) . numerical ;
1124
1124
const iValue = util . findMetricValue ( "I" , vectorObject ) . numerical ;
1125
1125
const aValue = util . findMetricValue ( "A" , vectorObject ) . numerical ;
1126
1126
return 1 - ( 1 - cValue ) * ( 1 - iValue ) * ( 1 - aValue ) ;
1127
- } ;
1128
- var getEnvironmentalScore = function ( vector ) {
1127
+ }
1128
+ function getEnvironmentalScore ( vector ) {
1129
1129
const vectorObject = util . getVectorObject ( vector ) ;
1130
1130
const scopeChanged = vectorObject . MS === "X" ? vectorObject . S === "C" : vectorObject . MS === "C" ;
1131
1131
const modifiedISCBase = calculateISCModifiedBase ( vectorObject ) ;
@@ -1143,32 +1143,32 @@ var getEnvironmentalScore = function(vector) {
1143
1143
return roundUp ( roundUp ( Math . min ( modifiedISC + modifiedExploitability , 10 ) , 1 , vector ) * eValue * rlValue * rcValue , 1 , vector ) ;
1144
1144
}
1145
1145
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 ) {
1148
1148
if ( ! scopeChanged )
1149
1149
return 6.42 * iscBase ;
1150
1150
if ( util . getVersion ( vector ) === "3.0" ) {
1151
1151
return 7.52 * ( iscBase - 0.029 ) - 3.25 * Math . pow ( iscBase - 0.02 , 15 ) ;
1152
1152
}
1153
1153
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 ) {
1156
1156
if ( ! scopeChanged )
1157
1157
return 6.42 * iscBase ;
1158
1158
if ( util . getVersion ( vector ) === "3.0" ) {
1159
1159
return 7.52 * ( iscBase - 0.029 ) - 3.25 * Math . pow ( iscBase - 0.02 , 15 ) ;
1160
1160
}
1161
1161
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 ) {
1164
1164
const avValue = util . findMetricValue ( "AV" , vectorObject ) . numerical ;
1165
1165
const acValue = util . findMetricValue ( "AC" , vectorObject ) . numerical ;
1166
1166
const prMetrics = util . findMetricValue ( "PR" , vectorObject ) . numerical ;
1167
1167
const uiValue = util . findMetricValue ( "UI" , vectorObject ) . numerical ;
1168
1168
const prValue = scopeChanged ? prMetrics . changed : prMetrics . unchanged ;
1169
1169
return 8.22 * avValue * acValue * prValue * uiValue ;
1170
- } ;
1171
- var calculateISCModifiedBase = function ( vectorObject ) {
1170
+ }
1171
+ function calculateISCModifiedBase ( vectorObject ) {
1172
1172
let mcValue = util . findMetricValue ( "MC" , vectorObject ) ;
1173
1173
let miValue = util . findMetricValue ( "MI" , vectorObject ) ;
1174
1174
let maValue = util . findMetricValue ( "MA" , vectorObject ) ;
@@ -1182,8 +1182,8 @@ var calculateISCModifiedBase = function(vectorObject) {
1182
1182
if ( ! maValue || maValue . abbr === "X" )
1183
1183
maValue = util . findMetricValue ( "A" , vectorObject ) ;
1184
1184
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 ) {
1187
1187
let mavValue = util . findMetricValue ( "MAV" , vectorObject ) ;
1188
1188
let macValue = util . findMetricValue ( "MAC" , vectorObject ) ;
1189
1189
let mprMetrics = util . findMetricValue ( "MPR" , vectorObject ) ;
@@ -1198,24 +1198,24 @@ var calculateModifiedExploitability = function(vectorObject, scopeChanged) {
1198
1198
muiValue = util . findMetricValue ( "UI" , vectorObject ) ;
1199
1199
const mprValue = scopeChanged ? mprMetrics . numerical . changed : mprMetrics . numerical . unchanged ;
1200
1200
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 ) {
1203
1203
if ( util . getVersion ( vector ) === "3.0" ) {
1204
1204
return util . roundUpApprox ( num , precision ) ;
1205
1205
}
1206
1206
return util . roundUpExact ( num ) ;
1207
- } ;
1208
- var getImpactSubScore = function ( vector ) {
1207
+ }
1208
+ function getImpactSubScore ( vector ) {
1209
1209
const vectorObject = util . getVectorObject ( vector ) ;
1210
1210
const { S } = vectorObject ;
1211
1211
const ISCBase = calculateISCBase ( vectorObject ) ;
1212
1212
return Number ( calculateISC ( ISCBase , S === "C" , vector ) . toFixed ( 1 ) ) ;
1213
- } ;
1214
- var getExploitabilitySubScore = function ( vector ) {
1213
+ }
1214
+ function getExploitabilitySubScore ( vector ) {
1215
1215
const vectorObject = util . getVectorObject ( vector ) ;
1216
1216
const { S } = vectorObject ;
1217
1217
return Number ( calculateExploitability ( vectorObject , S === "C" ) . toFixed ( 1 ) ) ;
1218
- } ;
1218
+ }
1219
1219
var score = {
1220
1220
getScore,
1221
1221
getTemporalScore,
@@ -1225,7 +1225,7 @@ var score = {
1225
1225
} ;
1226
1226
1227
1227
// lib/score_4_0.ts
1228
- var parseMetric = function ( abbr , vectorObject ) {
1228
+ function parseMetric ( abbr , vectorObject ) {
1229
1229
const definition = util . findMetric ( abbr , vectorObject . CVSS ) ;
1230
1230
let value = util . findMetricValue ( abbr , vectorObject ) ;
1231
1231
if ( vectorObject . CVSS === "4.0" ) {
@@ -1247,8 +1247,8 @@ var parseMetric = function(abbr, vectorObject) {
1247
1247
}
1248
1248
}
1249
1249
return value ;
1250
- } ;
1251
- var eq3eq6CalculateLowerMacroVector = function ( eqLevels ) {
1250
+ }
1251
+ function eq3eq6CalculateLowerMacroVector ( eqLevels ) {
1252
1252
if ( eqLevels . eq3 === "1" && eqLevels . eq6 === "1" ) {
1253
1253
return cvssLookup_global [ `${ eqLevels . eq1 } ${ eqLevels . eq2 } ${ parseInt ( eqLevels . eq3 ) + 1 } ${ eqLevels . eq4 } ${ eqLevels . eq5 } ${ eqLevels . eq6 } ` ] ;
1254
1254
}
@@ -1264,8 +1264,8 @@ var eq3eq6CalculateLowerMacroVector = function(eqLevels) {
1264
1264
return eq3eq6NextLowerLeftMarcoVector > eq3eq6NextLowerRightMarcoVector ? eq3eq6NextLowerLeftMarcoVector : eq3eq6NextLowerRightMarcoVector ;
1265
1265
}
1266
1266
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 ) {
1269
1269
const vectorObj = util . getVectorObject ( vector ) ;
1270
1270
const metrics = {
1271
1271
AV : { } ,
@@ -1448,21 +1448,21 @@ var getScore2 = function(vector) {
1448
1448
vectorScore = 10 ;
1449
1449
}
1450
1450
return parseFloat ( vectorScore . toFixed ( 1 ) ) ;
1451
- } ;
1452
- var getTemporalScore2 = function ( vector ) {
1451
+ }
1452
+ function getTemporalScore2 ( vector ) {
1453
1453
throw new Error ( "This function is not supported for this cvss version" ) ;
1454
1454
return 0 ;
1455
- } ;
1456
- var getEnvironmentalScore2 = function ( vector ) {
1455
+ }
1456
+ function getEnvironmentalScore2 ( vector ) {
1457
1457
throw new Error ( "This function is not supported for this cvss version" ) ;
1458
1458
return 0 ;
1459
- } ;
1460
- var getImpactSubScore2 = function ( vector ) {
1459
+ }
1460
+ function getImpactSubScore2 ( vector ) {
1461
1461
throw new Error ( "This function is not supported for this cvss version" ) ;
1462
- } ;
1463
- var getExploitabilitySubScore2 = function ( vector ) {
1462
+ }
1463
+ function getExploitabilitySubScore2 ( vector ) {
1464
1464
throw new Error ( "This function is not supported for this cvss version" ) ;
1465
- } ;
1465
+ }
1466
1466
var score2 = {
1467
1467
getScore : getScore2 ,
1468
1468
getTemporalScore : getTemporalScore2 ,
0 commit comments