From 0997b7c61c3b4fe7aed49c8b46fdfde4a00d4774 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 19 Dec 2024 12:39:18 -0500 Subject: [PATCH] fix gowitness file error --- bbot/modules/gowitness.py | 2 ++ .../module_tests/test_module_gowitness.py | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/bbot/modules/gowitness.py b/bbot/modules/gowitness.py index 8c5591990a..361d6b2c55 100644 --- a/bbot/modules/gowitness.py +++ b/bbot/modules/gowitness.py @@ -142,6 +142,8 @@ async def handle_batch(self, *events): url = screenshot["url"] final_url = screenshot["final_url"] filename = self.screenshot_path / screenshot["filename"] + filename = filename.relative_to(self.scan.home) + filename = self.helpers.truncate_filename(filename) webscreenshot_data = {"path": str(filename), "url": final_url} parent_event = event_dict[url] await self.emit_event( diff --git a/bbot/test/test_step_2/module_tests/test_module_gowitness.py b/bbot/test/test_step_2/module_tests/test_module_gowitness.py index 6090fbb1d6..205b482f40 100644 --- a/bbot/test/test_step_2/module_tests/test_module_gowitness.py +++ b/bbot/test/test_step_2/module_tests/test_module_gowitness.py @@ -102,3 +102,23 @@ def check(self, module_test, events): webscreenshots = [e for e in events if e.type == "WEBSCREENSHOT"] assert webscreenshots, "failed to raise WEBSCREENSHOT events" assert all("blob" in e.data and e.data["blob"] for e in webscreenshots), "blob not found in WEBSCREENSHOT data" + + +class TestGoWitnessLongFilename(TestGowitness): + """ + Make sure long filenames are truncated properly + """ + targets = ["http://127.0.0.1:8888/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity"] + config_overrides = {"file_blobs": True} + + async def setup_after_prep(self, module_test): + request_args = {"uri": "/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity/blacklanternsecurity"} + respond_args = { + "response_data": "BBOT is lifeBBOT is life", + "headers": {"Server": "Apache/2.4.41 (Ubuntu)"}, + } + module_test.set_expect_requests(request_args, respond_args) + + def check(self, module_test, events): + webscreenshots = [e for e in events if e.type == "WEBSCREENSHOT"] + assert webscreenshots, "failed to raise WEBSCREENSHOT events"