From 6b1bd1cf65c2caf0df074c42ed44cff1303c40ad Mon Sep 17 00:00:00 2001 From: Jason Booth Date: Thu, 24 Aug 2023 15:28:57 -0400 Subject: [PATCH 1/4] add '/control/' to websocket url --- bbot/agent/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bbot/agent/agent.py b/bbot/agent/agent.py index f3b296927..a24f1504d 100644 --- a/bbot/agent/agent.py +++ b/bbot/agent/agent.py @@ -49,8 +49,8 @@ async def ws(self, rebuild=False): verbs = ("Building", "Built") if rebuild: verbs = ("Rebuilding", "Rebuilt") - log.debug(f"{verbs[0]} websocket connection to {self.url}") - self._ws = await websockets.connect(self.url, **kwargs) + log.debug(f"{verbs[0]} websocket connection to {self.url}/control/") + self._ws = await websockets.connect(f"{self.url}/control/", **kwargs) log.debug(f"{verbs[1]} websocket connection to {self.url}") return self._ws From b5e9e620c4d388891b79ce5fe727045fe6ca058a Mon Sep 17 00:00:00 2001 From: Jason Booth Date: Fri, 25 Aug 2023 09:17:21 -0400 Subject: [PATCH 2/4] add '/control/ to another spot --- bbot/agent/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbot/agent/agent.py b/bbot/agent/agent.py index a24f1504d..519d11ea3 100644 --- a/bbot/agent/agent.py +++ b/bbot/agent/agent.py @@ -114,7 +114,7 @@ async def start_scan(self, scan_id, name=None, targets=[], modules=[], output_mo f"Starting scan with targets={targets}, modules={modules}, output_modules={output_modules}" ) output_module_config = OmegaConf.create( - {"output_modules": {"websocket": {"url": f"{self.url}/scan/{scan_id}/", "token": self.token}}} + {"output_modules": {"websocket": {"url": f"{self.url}/control/scan/{scan_id}/", "token": self.token}}} ) config = OmegaConf.create(config) config = OmegaConf.merge(self.config, config, output_module_config) From 3656e302681381b779f58b778c16cdf773989025 Mon Sep 17 00:00:00 2001 From: Jason Booth Date: Fri, 25 Aug 2023 10:14:48 -0400 Subject: [PATCH 3/4] formatting --- bbot/agent/agent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bbot/agent/agent.py b/bbot/agent/agent.py index 519d11ea3..f5ec42ca2 100644 --- a/bbot/agent/agent.py +++ b/bbot/agent/agent.py @@ -114,7 +114,11 @@ async def start_scan(self, scan_id, name=None, targets=[], modules=[], output_mo f"Starting scan with targets={targets}, modules={modules}, output_modules={output_modules}" ) output_module_config = OmegaConf.create( - {"output_modules": {"websocket": {"url": f"{self.url}/control/scan/{scan_id}/", "token": self.token}}} + { + "output_modules": { + "websocket": {"url": f"{self.url}/control/scan/{scan_id}/", "token": self.token} + } + } ) config = OmegaConf.create(config) config = OmegaConf.merge(self.config, config, output_module_config) From 7bb559718691bfe43b0bc32a9053ced94e7cfe5e Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Thu, 31 Aug 2023 14:35:15 -0400 Subject: [PATCH 4/4] updated agent tests --- bbot/agent/agent.py | 7 ++++--- bbot/test/test_step_1/test_agent.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bbot/agent/agent.py b/bbot/agent/agent.py index f5ec42ca2..f30fb94d1 100644 --- a/bbot/agent/agent.py +++ b/bbot/agent/agent.py @@ -49,9 +49,10 @@ async def ws(self, rebuild=False): verbs = ("Building", "Built") if rebuild: verbs = ("Rebuilding", "Rebuilt") - log.debug(f"{verbs[0]} websocket connection to {self.url}/control/") - self._ws = await websockets.connect(f"{self.url}/control/", **kwargs) - log.debug(f"{verbs[1]} websocket connection to {self.url}") + url = f"{self.url}/control/" + log.debug(f"{verbs[0]} websocket connection to {url}") + self._ws = await websockets.connect(url, **kwargs) + log.debug(f"{verbs[1]} websocket connection to {url}") return self._ws async def start(self): diff --git a/bbot/test/test_step_1/test_agent.py b/bbot/test/test_step_1/test_agent.py index e9da3ba45..a4b8e447e 100644 --- a/bbot/test/test_step_1/test_agent.py +++ b/bbot/test/test_step_1/test_agent.py @@ -20,7 +20,7 @@ async def websocket_handler(websocket, path, scan_done=None): # control channel or event channel? control = True - if path == "/" and first_run: + if path == "/control/" and first_run: # test ping await websocket.send(json.dumps({"conversation": "90196cc1-299f-4555-82a0-bc22a4247590", "command": "ping"})) _first_run = False