(self, filename, crits_id, data)
return
Submit a sample to ThreatGRID
Submit a sample to ThreatGRID
Submit a sample to ThreatGRID
def sample_submit(self, filename, crits_id, data):
        """
        Submit a sample to ThreatGRID
        """
        # Set API query parameters and submit sample
        params = {'tags': 'CRITS',
                  'filename': filename,
                  'os': '',
                  'osver': '',
                  'source': 'CRITS:{}'.format(crits_id),
                  'sample': data}
        response = self.api_request('/api/v2/samples', params, 'post')

        if response:
            self._info("Sample submitted to ThreatGRID (run time is 5 mins).")
            if response.get('data'):
                submitted = response.get('data')
                result = {
                        'id':               submitted.get('id'),
                        'submitted_at':     submitted.get('submitted_at'),
                        'tags':             ''.join(submitted.get('tags', [])),
                        'submission_id':    submitted.get('submission_id'),
                        'state':            submitted.get('state'),
                        'status':           submitted.get('status'),
                        }
                self._add_result('threatgrid_submitted', submitted.get('filename'), result)
                self._notify()
                if not self.md5 == submitted.get('md5').lower():
                    self._error("MD5 mismatch between ThreatGRID and CRITS.")
                return submitted.get('id')
        self._error("ThreatGRID sample submission failed.")
        return
def sample_submit ( self , filename , crits_id , data ) : # Set API query parameters and submit sample params = { 'tags' : 'CRITS' , 'filename' : filename , 'os' : '' , 'osver' : '' , 'source' : 'CRITS:{}' . format ( crits_id ) , 'sample' : data } response = self . api_request ( '/api/v2/samples' , params , 'post' ) if response : self . _info ( "Sample submitted to ThreatGRID (run time is 5 mins)." ) if response . get ( 'data' ) : submitted = response . get ( 'data' ) result = { 'id' : submitted . get ( 'id' ) , 'submitted_at' : submitted . get ( 'submitted_at' ) , 'tags' : '' . join ( submitted . get ( 'tags' , [ ] ) ) , 'submission_id' : submitted . get ( 'submission_id' ) , 'state' : submitted . get ( 'state' ) , 'status' : submitted . get ( 'status' ) , } self . _add_result ( 'threatgrid_submitted' , submitted . get ( 'filename' ) , result ) self . _notify ( ) if not self . md5 == submitted . get ( 'md5' ) . lower ( ) : self . _error ( "MD5 mismatch between ThreatGRID and CRITS." ) return submitted . get ( 'id' ) self . _error ( "ThreatGRID sample submission failed." ) return