def do_perform_test(self, caplog, url, expected, type_="remote"): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_ssl_verify() thug.reset_image_processing() thug.set_image_processing() thug.get_image_processing() thug.register_pyhook("MIMEHandler", "handle_image", self.handle_image_hook) thug.set_json_logging() thug.log_init(url) m = getattr(thug, "run_{}".format(type_)) m(url) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample, expected): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_events('click,storage') thug.set_extensive() thug.disable_cert_logging() thug.set_file_logging() thug.set_json_logging() thug.set_features_logging() thug.set_ssl_verify() thug.set_threshold(3) thug.log_init(sample) thug.run_local(sample) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample, expected): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_events('click,storage') thug.disable_cert_logging() thug.set_file_logging() thug.set_json_logging() thug.set_features_logging() thug.log_init(sample) thug.run_local(sample) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample): thug = ThugAPI() thug.log_init(sample) thug.set_useragent('win7ie90') thug.set_verbose() thug.set_json_logging() thug.reset_features_logging() assert thug.get_features_logging() is False thug.set_features_logging() assert thug.get_features_logging() is True thug.log_init(sample) thug.run_local(sample) thug.log_event() for r in caplog.records: try: features = json.dumps(r) except Exception: continue if not isinstance(features, dict): continue if "html_count" not in features: continue for url in self.expected: if not url.endswith(sample): continue for key in features: assert features[key] == self.expected[url][key]
def do_perform_test(self, caplog, url, expected, type_="remote"): thug = ThugAPI() thug.set_useragent('win7ie90') thug.disable_screenshot() thug.enable_screenshot() thug.set_file_logging() thug.set_json_logging() thug.set_ssl_verify() thug.log_init(url) m = getattr(thug, "run_{}".format(type_)) m(url) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)