Ejemplo n.º 1
0
 def score(self, task):
     this = task.get_result(self.__servicename__)
     if not this:
         self.logger.warn("no result found for task {}".format(task.id))
         return None
     return score_creator(self.__servicename__, 1 if this.validated else 0,
                          {})
Ejemplo n.º 2
0
 def score(self, task):
     this = task.get_result(self.__servicename__)
     if not this:
         self.logger.warn("no result found for task {}".format(task.id))
         return None
     try:
         json_result = json.loads(this.result.replace("'", "\""))
     except Exception as e:
         self.logger.error("{}".format(e))
         json_result = {}
     return score_creator(
         self.__servicename__, this.float_result, {
             "total": json_result.get("total"),
             "positives": json_result.get("positives"),
             "scan_date": json_result.get("scan_date")
         })
Ejemplo n.º 3
0
def r_passthrough_hash(hash):
    v = get_manager().get_analyser("virustotal")
    if not v:
        raise ValueError("no virustotal analysers found")
    data = v.view("file", hash)
    resp_code = data.get('response_code')
    if resp_code != 1:
        return json_response("unknown", 200)
    else:
        n_found = data.get("total")
        scans = data.get("scans", [])
        positives = sum([x.get("detected") for x in scans.values()])
        score = (positives * 100) / n_found
        return json_response(
            score_creator(
                "virustotal", score, {
                    "total": data.get("total"),
                    "positives": data.get("positives"),
                    "scan_date": data.get("scan_date")
                }), 200)