@@ -58,7 +58,7 @@ const calculateISCBase = function (vectorObject) {
58
58
*/
59
59
function getEnvironmentalScore ( vector ) {
60
60
const vectorObject = util . getVectorObject ( vector ) ;
61
- const scopeChanged = vectorObject . MS === "C" ;
61
+ const scopeChanged = vectorObject . MS === "X" ? vectorObject . S === "C" : vectorObject . MS === " C";
62
62
const modifiedISCBase = calculateISCModifiedBase ( vectorObject ) ;
63
63
const modifiedExploitability = calculateModifiedExploitability ( vectorObject , scopeChanged ) ;
64
64
const modifiedISC = calculateISC ( modifiedISCBase , scopeChanged , vector ) ;
@@ -94,10 +94,9 @@ function getEnvironmentalScore(vector) {
94
94
95
95
const calculateISC = function ( iscBase , scopeChanged , vector ) {
96
96
if ( ! scopeChanged ) return 6.42 * iscBase ;
97
- if ( util . getVersion ( vector ) === "3.0" ) {
97
+ if ( util . getVersion ( vector ) === "3.0" ) {
98
98
return 7.52 * ( iscBase - 0.029 ) - 3.25 * Math . pow ( iscBase - 0.02 , 15 ) ;
99
- }
100
- else if ( util . getVersion ( vector ) === "3.1" ) {
99
+ } else if ( util . getVersion ( vector ) === "3.1" ) {
101
100
return 7.52 * ( iscBase - 0.029 ) - 3.25 * Math . pow ( iscBase * 0.9731 - 0.02 , 13 ) ;
102
101
}
103
102
} ;
@@ -142,8 +141,7 @@ const calculateModifiedExploitability = function (vectorObject, scopeChanged) {
142
141
143
142
if ( ! mavValue || mavValue . abbr === "X" ) mavValue = util . findMetricValue ( "AV" , vectorObject ) ;
144
143
if ( ! macValue || macValue . abbr === "X" ) macValue = util . findMetricValue ( "AC" , vectorObject ) ;
145
- if ( ! mprMetrics || mprMetrics . abbr === "X" )
146
- mprMetrics = util . findMetricValue ( "PR" , vectorObject ) ;
144
+ if ( ! mprMetrics || mprMetrics . abbr === "X" ) mprMetrics = util . findMetricValue ( "PR" , vectorObject ) ;
147
145
if ( ! muiValue || muiValue . abbr === "X" ) muiValue = util . findMetricValue ( "UI" , vectorObject ) ;
148
146
149
147
const mprValue = scopeChanged ? mprMetrics . numerical . changed : mprMetrics . numerical . unchanged ;
@@ -153,18 +151,17 @@ const calculateModifiedExploitability = function (vectorObject, scopeChanged) {
153
151
154
152
/**
155
153
* Chooses the correct way to round numbers depending on the CVSS version number
156
- *
154
+ *
157
155
* @param {Number } num The number to round
158
156
* @param {Number } precision The number of decimal places to preserve (only affects CVSS 3.0)
159
157
* @param {String } vector The vector currently being parsed
160
- *
158
+ *
161
159
* @returns {num } The rounded number
162
160
*/
163
161
function roundUp ( num , precision , vector ) {
164
- if ( util . getVersion ( vector ) === "3.0" ) {
162
+ if ( util . getVersion ( vector ) === "3.0" ) {
165
163
return util . roundUpApprox ( num , precision ) ;
166
- }
167
- else if ( util . getVersion ( vector ) === "3.1" ) {
164
+ } else if ( util . getVersion ( vector ) === "3.1" ) {
168
165
return util . roundUpExact ( num ) ;
169
166
}
170
167
}
@@ -173,4 +170,4 @@ module.exports = {
173
170
getScore,
174
171
getTemporalScore,
175
172
getEnvironmentalScore
176
- } ;
173
+ } ;
0 commit comments