def test_successful_contract_audit_request_dockerhub_fail_multiple_analyzers(self): """ Tests that a report is generated when the dockerhub fails """ # Replace analyzers with a single dockerhub fail analyzer faulty_wrapper = Wrapper( wrappers_dir="{0}/tests/resources/wrappers".format(project_root()), analyzer_name="dockerhub_fail", args="", storage_dir="/tmp/{}{}".format(time(), random()), timeout_sec=60, prefetch=False ) analyzer = Analyzer(faulty_wrapper) original_analyzers = self.__audit_node.config._Config__analyzers original_analyzers_config = self.__audit_node.config._Config__analyzers_config self.__audit_node.config._Config__analyzers[1] = analyzer self.__audit_node.config._Config__analyzers_config[1] = {"dockerhub_fail": analyzer} # since we're mocking the smart contract, we should explicitly call its internals buggy_contract = resource_uri("DAOBug.sol") self.__request_audit(buggy_contract, self.__PRICE) self.__evt_wait_loop(self.__submitReport_filter) # NOTE: if the audit node later requires the stubbed fields, this will have to change a bit self.__send_done_message(self.__REQUEST_ID) self.__assert_audit_request_report(self.__REQUEST_ID, report_file_path="reports/DockerhubFailAllAnalyzers.json") self.__assert_all_analyzers(self.__REQUEST_ID) # set the values back self.__audit_node.config._Config__analyzers = original_analyzers self.__audit_node.config._Config__analyzers_config = original_analyzers_config compressed_report = self.__compress_report("reports/DockerhubFailAllAnalyzers.json") # asserting the database content expected_row = {"request_id": 1, "requestor": self.__config.account, "contract_uri": buggy_contract, "evt_name": "LogAuditAssigned", 'assigned_block_nbr': "IGNORE", "submission_block_nbr": "IGNORE", "fk_status": "DN", "fk_type": "AU", "price": str(self.__PRICE), "status_info": "Report successfully submitted", "tx_hash": "IGNORE", "submission_attempts": 1, "is_persisted": 1, "audit_uri": "IGNORE", "audit_hash": "IGNORE", "audit_state": 5, "full_report": "IGNORE", "compressed_report": compressed_report } self.assert_event_table_contains(self.__config, [expected_row], ignore_keys=[key for key in expected_row if expected_row[key] == "IGNORE"])
def __new_analyzer(timeout_sec=60, prefetch=False): faulty_wrapper = Wrapper( wrappers_dir="{0}/tests/resources/wrappers".format(project_root()), analyzer_name="dockerhub_fail", args="", storage_dir="/tmp/./dockerhub_fail/{}{}".format(time(), random()), timeout_sec=timeout_sec, prefetch=prefetch) return Analyzer(faulty_wrapper)
def __new_analyzer(timeout_sec=600): securify_wrapper = Wrapper( wrappers_dir="{0}/plugins/analyzers/wrappers".format( project_root()), analyzer_name="securify", args="", storage_dir="/tmp/{}{}".format(time(), random()), timeout_sec=timeout_sec, ) return Analyzer(securify_wrapper)