Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Created January 26, 2024 14:20
Show Gist options
  • Save cmcdevitt/d578d894dba8a671fdccf875a1c78b73 to your computer and use it in GitHub Desktop.
Save cmcdevitt/d578d894dba8a671fdccf875a1c78b73 to your computer and use it in GitHub Desktop.
Recalculate Remediation Targets
/*
If you need to update your remediation targets, create a Fix Script in the Vulnerability Response scope,
craft your Encoded Query, test, test, and then valideate.
*/
var vit = new GlideRecord("sn_vul_vulnerable_item");
//This Encoded Query is just an example
vit.addEncodedQuery('active=true^risk_rating=2^risk_score>=80^ORrisk_score<=49^NQactive=true^risk_rating=3^risk_score>=50^ORrisk_score<=29^NQactive=true^risk_rating=4^risk_score>=30^ORrisk_score<=0^NQactive=true^risk_rating=5^risk_score>0');
vit.setLimit(1);//Remove before flight, for people who don't read directions
vit.query();
while (vit.next()) {
//You may or may want to update this at the same time. Comment Out if this is not needed
vit.risk_rating = new sn_vul.VulnerabilityUtils().getRiskRatingFromRiskScore(vit.risk_score, 'vr_risk_rating');
var remediation_data = new sn_vul.VulnerabilityTTRUtil().getRemediationInfo(vit);
if (remediation_data) {
vit.ttr_target_date = remediation_data["ttr_target_date"];
vit.ttr_applied_rule = remediation_data['ttr_applied_rule'];
vit.ttr_status = remediation_data['ttr_status'];
}
vit.update();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment