@@ -58,7 +58,7 @@ const calculateISCBase = function (vectorObject) {
5858 */
5959function getEnvironmentalScore ( vector ) {
6060 const vectorObject = util . getVectorObject ( vector ) ;
61- const scopeChanged = vectorObject . MS === "C" ;
61+ const scopeChanged = vectorObject . MS === "X" ? vectorObject . S === "C" : vectorObject . MS === " C";
6262 const modifiedISCBase = calculateISCModifiedBase ( vectorObject ) ;
6363 const modifiedExploitability = calculateModifiedExploitability ( vectorObject , scopeChanged ) ;
6464 const modifiedISC = calculateISC ( modifiedISCBase , scopeChanged , vector ) ;
@@ -94,10 +94,9 @@ function getEnvironmentalScore(vector) {
9494
9595const calculateISC = function ( iscBase , scopeChanged , vector ) {
9696 if ( ! scopeChanged ) return 6.42 * iscBase ;
97- if ( util . getVersion ( vector ) === "3.0" ) {
97+ if ( util . getVersion ( vector ) === "3.0" ) {
9898 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" ) {
101100 return 7.52 * ( iscBase - 0.029 ) - 3.25 * Math . pow ( iscBase * 0.9731 - 0.02 , 13 ) ;
102101 }
103102} ;
@@ -142,8 +141,7 @@ const calculateModifiedExploitability = function (vectorObject, scopeChanged) {
142141
143142 if ( ! mavValue || mavValue . abbr === "X" ) mavValue = util . findMetricValue ( "AV" , vectorObject ) ;
144143 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 ) ;
147145 if ( ! muiValue || muiValue . abbr === "X" ) muiValue = util . findMetricValue ( "UI" , vectorObject ) ;
148146
149147 const mprValue = scopeChanged ? mprMetrics . numerical . changed : mprMetrics . numerical . unchanged ;
@@ -153,18 +151,17 @@ const calculateModifiedExploitability = function (vectorObject, scopeChanged) {
153151
154152/**
155153 * Chooses the correct way to round numbers depending on the CVSS version number
156- *
154+ *
157155 * @param {Number } num The number to round
158156 * @param {Number } precision The number of decimal places to preserve (only affects CVSS 3.0)
159157 * @param {String } vector The vector currently being parsed
160- *
158+ *
161159 * @returns {num } The rounded number
162160 */
163161function roundUp ( num , precision , vector ) {
164- if ( util . getVersion ( vector ) === "3.0" ) {
162+ if ( util . getVersion ( vector ) === "3.0" ) {
165163 return util . roundUpApprox ( num , precision ) ;
166- }
167- else if ( util . getVersion ( vector ) === "3.1" ) {
164+ } else if ( util . getVersion ( vector ) === "3.1" ) {
168165 return util . roundUpExact ( num ) ;
169166 }
170167}
@@ -173,4 +170,4 @@ module.exports = {
173170 getScore,
174171 getTemporalScore,
175172 getEnvironmentalScore
176- } ;
173+ } ;
0 commit comments