Last active
August 29, 2015 13:57
-
-
Save mattburch/9619879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listHostsByVulnerabilityRegex = function(title,score) { | |
// Retrieves all host, port, protocol instances afflicted by a certain vulnerability Regex | |
// | |
// Created by: Matt Burch | |
// Usage: listHostsByVulnerabilityRegex(/Self-[Ss]igned/,'high') | |
// Requires client-side updates: false | |
score = score.toLowerCase(); | |
var RATING = { | |
'hightop' : 10.0, | |
'highbot' : 7.0, | |
'mediumtop' : 6.9, | |
'mediumbot' : 4.0, | |
'lowtop' : 3.9, | |
'lowbot' : 1.0, | |
}; | |
var PROJECT_ID = Session.get( 'projectId'); | |
var vulnerability; | |
if (score == '') { | |
vulnerability = Vulnerabilities.find({ "project_id": PROJECT_ID, "title": { "$regex": title} }).fetch(); | |
if ( !vulnerability) { | |
return ( "Vulnerability not found"); | |
} | |
} | |
else if (RATING[score + 'top'] == undefined) { | |
return ("Vulnerability score must be: high, medium or low"); | |
} | |
else { | |
vulnerability = Vulnerabilities.find({ "project_id": PROJECT_ID, "title": { "$regex": title}, "$and": [{"cvss": {"$gte": RATING[score + 'bot']}}, {"cvss": {"$lte": RATING[score + 'top']}}] }).fetch(); | |
if ( !vulnerability) { | |
console.log( "Vulnerability not found"); | |
return; | |
} | |
} | |
vulnerability.forEach( function(vulm) { | |
console.log(vulm.title + " CVSS:" + vulm.cvss); | |
var hosts = vulm.hosts; | |
hosts.forEach( function(host){ | |
var realHost = Hosts.findOne({ "project_id": PROJECT_ID, "string_addr": host.string_addr}); | |
console.log (host.string_addr + ":" + host.port + "/" + host.protocol); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment