How to Specify Conditions in Vulnerability Calculation Rule Scripts

akie
Tera Contributor

We would like to calculate the value of the [Risk score] column of Vulnerable Items[sn_vul_vulnerable_item] using the Vulnerability Calculator Rules[sn_vul_calculator].

We want to calculate it.
We would like to set the conditions and values in the [When this condition is met] and [Set these values] tabs in the script,
We would like to know the sample code that should be set in each tab.

 

The current settings are as follows.
In this state, when I press the “Calculate Risk Score” link of an existing record of a Vulnerable Items TBL that matches the criteria, the [Risk score] and [Risk rating] columns are updated with the specified values,
However, when I try to create a new Vulnerable Items record, the following message appears and the record cannot be created.

 

○Setting details> [Set these values]

-----------------------------------------------------------------------------------------------

var item = new GlideRecord("sn_vul_vulnerable_item"); 
item.addQuery("vulnerability.exploit", "1");
item.addQuery("vulnerability.id", "TEN-118918");
current.setValue("risk_score", 100);
var weight = current.risk_score * 0.2; 
current.setValue("risk_score",weight);
current.updateMultiple();

-----------------------------------------------------------------------------------------------

○Message

akie_1-1734487337678.png

2 REPLIES 2

alvinbm1
Tera Expert

// Set the Risk Score based on vulnerability_score current.risk_score = current.vulnerability_score; // Set Risk Rating based on the risk score if (current.risk_score >= 9) { current.risk_rating = 'Critical'; } else if (current.risk_score >= 7) { current.risk_rating = 'High'; } else if (current.risk_score >= 4) { current.risk_rating = 'Medium'; } else { current.risk_rating = 'Low'; }

akie
Tera Contributor

Thanks for the reply.

I understand about the scripts to set risk_score and risk_rating.

Do you know why the following error message appears when creating a new vulnerability items?

akie_1-1734592432460.png