From 32b8692728cbfaa0e8800a508bc0f8f643860ad9 Mon Sep 17 00:00:00 2001 From: liquidsec Date: Fri, 3 Apr 2026 13:35:11 -0400 Subject: [PATCH] Improve URL event stdout display format Show status code, URL, title, and redirect target instead of raw JSON dict. --- bbot/core/event/base.py | 24 ++++++++++++++++++++++++ bbot/modules/httpx.py | 3 +++ 2 files changed, 27 insertions(+) diff --git a/bbot/core/event/base.py b/bbot/core/event/base.py index 64c30d6abe..f50ae0c77c 100644 --- a/bbot/core/event/base.py +++ b/bbot/core/event/base.py @@ -1363,6 +1363,22 @@ def sanitize_data(self, data): def pretty_string(self): return self.url + def _data_human(self): + parts = [] + status = self.http_status + if status: + parts.append(f"[{status}]") + parts.append(self.url) + if status and str(status).startswith("3"): + location = self.data.get("redirect_location", "") + if location: + parts.append(f"-> {location}") + else: + title = self.http_title + if title: + parts.append(f"- [{title}]") + return " ".join(parts) + def add_tag(self, tag): self_url = getattr(self, "parsed_url", "") self_host = getattr(self, "host", "") @@ -1427,6 +1443,14 @@ def http_title(self): def http_title(self, value): self.data["http_title"] = value + @property + def redirect_location(self): + return self.data.get("redirect_location", "") + + @redirect_location.setter + def redirect_location(self, value): + self.data["redirect_location"] = value + class URL(URL_UNVERIFIED): def __init__(self, *args, **kwargs): diff --git a/bbot/modules/httpx.py b/bbot/modules/httpx.py index dd996a2b58..860894015b 100644 --- a/bbot/modules/httpx.py +++ b/bbot/modules/httpx.py @@ -206,6 +206,9 @@ async def handle_batch(self, *events): title = j.get("title", "") if title: url_event.http_title = title + location = j.get("header", {}).get("location", "") + if location: + url_event.redirect_location = location if url_event != parent_event: await self.emit_event(url_event) # HTTP response