Skip to content

Instantly share code, notes, and snippets.

@9b
Created March 24, 2011 19:43
Show Gist options
  • Save 9b/885715 to your computer and use it in GitHub Desktop.
Save 9b/885715 to your computer and use it in GitHub Desktop.
Key off anti-virus name and collect signatures, unique signature count and total detection
var map = function () {
this.scans.virustotal.report.results.scanners.forEach(
function (z) {
emit(z.antivirus, {signatures: [z.signature] , count: 1, total: 0});
}
);
}
var reduce = function (key, values) {
var count = 0;
var total = 0;
var sigs = [];
values.forEach(
function(z){
total += z.count;
z.signatures.forEach(
function(y) {
if(y != "") { sigs.push(y); }
}
)
}
)
var newArray=new Array();
label:for(var i=0; i<sigs.length;i++ ) {
for(var j=0; j<newArray.length;j++ ) {
if(newArray[j]==sigs[i])
continue label;
}
newArray[newArray.length] = sigs[i];
}
count = newArray.length;
return { count: count, total: total, signatures: newArray };
}
db.malware.mapReduce(map,reduce, {out: "composite_scans" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment