def execute(self, input_data):
        ''' Execute the VTQuery worker '''
        md5 = input_data['meta']['md5']
        response = requests.get('http://www.virustotal.com/vtapi/v2/file/report', 
                                params={'apikey':self.apikey,'resource':md5, 'allinfo':1})

        # Make sure we got a json blob back
        try:
            vt_output = response.json()
        except ValueError:
            return {'vt_error': 'VirusTotal Query Error, no valid response... past per min quota?'}
        
        # Just pull some of the fields
        output = {field:vt_output[field] for field in vt_output.keys() if field not in self.exclude}
        
        # Check for not-found
        not_found = False if output else True        

        # Add in file_type
        output['file_type'] = input_data['meta']['file_type']
        
        # Toss back a not found
        if not_found:
            output['not_found'] = True
            return output

        # Organize the scans fields
        scan_results = collections.Counter()
        for scan in vt_output['scans'].values():
            if 'result' in scan:
                if scan['result']:
                    scan_results[scan['result']] += 1
        output['scan_results'] = scan_results.most_common(5)
        return output
def execute ( self , input_data ) : md5 = input_data [ 'meta' ] [ 'md5' ] response = requests . get ( 'http://www.virustotal.com/vtapi/v2/file/report' , params = { 'apikey' : self . apikey , 'resource' : md5 , 'allinfo' : 1 } ) try : vt_output = response . json ( ) except ValueError : return { 'vt_error' : 'VirusTotal Query Error, no valid response... past per min quota?' } output = { field : vt_output [ field ] for field in vt_output . keys ( ) if field not in self . exclude } not_found = False if output else True output [ 'file_type' ] = input_data [ 'meta' ] [ 'file_type' ] if not_found : output [ 'not_found' ] = True return output scan_results = collections . Counter ( ) for scan in vt_output [ 'scans' ] . values ( ) : if 'result' in scan : if scan [ 'result' ] : scan_results [ scan [ 'result' ] ] += 1 output [ 'scan_results' ] = scan_results . most_common ( 5 ) return output
Execute the VTQuery worker