Exemplo n.º 1
0
 def test039_handle_output_files_resubmit(self,
                                          m_session_transaction,
                                          m_Scan,
                                          m_File,
                                          m_append_new_files_to_scan,
                                          m_filter_children):
     m_scan, m_session = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.resubmit_files = True
     m_Scan.load_from_ext_id.return_value = m_scan
     uploaded_files = {'filename': 'filehash'}
     result = {'uploaded_files': uploaded_files}
     fw1 = MagicMock()
     m_append_new_files_to_scan.return_value = [fw1]
     m_parentfile = MagicMock()
     m_parentfile.children = []
     m_filter_children.return_value = uploaded_files
     m_File.load_from_sha256.return_value = m_parentfile
     module.handle_output_files("scanid", "parent_file_hash",
                                "probe", result)
     m_Scan.load_from_ext_id.assert_called_once_with("scanid",
                                                     session=m_session)
     m_append_new_files_to_scan.assert_called_once_with(m_scan,
                                                        uploaded_files,
                                                        m_session)
     self.assertItemsEqual(m_parentfile.children, [fw1])
Exemplo n.º 2
0
def scan_result(scanid, file_hash, probe, result):
    try:
        log.debug("scanid: %s file_hash: %s probe: %s",
                  scanid, file_hash, probe)
        scan_ctrl.handle_output_files(scanid, file_hash, probe, result)
        scan_ctrl.set_result(scanid, file_hash, probe, result)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise scan_result.retry(countdown=2, max_retries=3, exc=e)
Exemplo n.º 3
0
def scan_result(scanid, file_hash, probe, result):
    try:
        log.debug("scanid: %s file_hash: %s probe: %s",
                  scanid, file_hash, probe)
        scan_ctrl.handle_output_files(scanid, file_hash, probe, result)
        scan_ctrl.set_result(scanid, file_hash, probe, result)
	scan_ctrl.set_probe_tag(file_hash, probe, result)
    except IrmaDatabaseError as e:
        log.exception(e)
        raise scan_result.retry(countdown=2, max_retries=3, exc=e)
Exemplo n.º 4
0
 def test038_handle_output_files_resubmit_False(self, m_session_transaction,
                                                m_Scan, m_File):
     m_scan, m_session = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.resubmit_files = False
     m_Scan.load_from_ext_id.return_value = m_scan
     result = {'uploaded_files': []}
     module.handle_output_files("scanid", "parent_file_hash", "probe",
                                result)
     m_Scan.load_from_ext_id.assert_called_once_with("scanid",
                                                     session=m_session)
Exemplo n.º 5
0
 def test038_handle_output_files_resubmit_False(self,
                                                m_session_transaction,
                                                m_Scan,
                                                m_File):
     m_scan, m_session = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.resubmit_files = False
     m_Scan.load_from_ext_id.return_value = m_scan
     result = {'uploaded_files': []}
     module.handle_output_files("scanid", "parent_file_hash",
                                "probe", result)
     m_Scan.load_from_ext_id.assert_called_once_with("scanid",
                                                     session=m_session)
Exemplo n.º 6
0
 def test039_handle_output_files_resubmit(self,
                                          m_session_transaction,
                                          m_Scan,
                                          m_File,
                                          m_append_new_files_to_scan):
     m_scan, m_session = MagicMock(), MagicMock()
     m_session_transaction().__enter__.return_value = m_session
     m_scan.resubmit_files = True
     m_Scan.load_from_ext_id.return_value = m_scan
     uploaded_files = {}
     result = {'uploaded_files': uploaded_files}
     fw1 = MagicMock()
     m_append_new_files_to_scan.return_value = [fw1]
     m_parentfile = MagicMock()
     m_parentfile.children = []
     m_File.load_from_sha256.return_value = m_parentfile
     module.handle_output_files("scanid", "parent_file_hash",
                                "probe", result)
     m_Scan.load_from_ext_id.assert_called_once_with("scanid",
                                                     session=m_session)
     m_append_new_files_to_scan.assert_called_once_with(m_scan,
                                                        uploaded_files,
                                                        m_session)
     self.assertItemsEqual(m_parentfile.children, [fw1])