Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vuln host bug #2157

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ def __init__(self, *args, **kwargs):
self.data = self.data
break
# die if we still haven't found a host
if not self.host:
raise ValueError("No host was found in event parents. Host must be specified!")
if not self.host and not self.data.get("path", ""):
raise ValueError(f"No host was found in event parents: {self.get_parents()}. Host must be specified!")


class DictPathEvent(DictEvent):
Expand Down Expand Up @@ -1408,7 +1408,7 @@ def raw_response(self):
"""
raw_header = self.data.get("raw_header", "")
body = self.data.get("body", "")
return f'{raw_header}{body}'
return f"{raw_header}{body}"

@property
def http_status(self):
Expand Down
20 changes: 15 additions & 5 deletions bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,15 +964,25 @@ def test_event_closest_host():
assert vuln.data["path"] == "/tmp/asdf.txt"
assert vuln.host == "www.evilcorp.com"

# no host == not allowed
# no host and no path == not allowed
event3 = scan.make_event("wat", "ASDF", parent=scan.root_event)
assert not event3.host
with pytest.raises(ValueError):
finding = scan.make_event({"path": "/tmp/asdf.txt", "description": "test"}, "FINDING", parent=event3)
finding = scan.make_event({"description": "test"}, "FINDING", parent=event3)
finding = scan.make_event({"path": "/tmp/asdf.txt", "description": "test"}, "FINDING", parent=event3)
assert finding is not None
finding = scan.make_event({"host": "evilcorp.com", "description": "test"}, "FINDING", parent=event3)
assert finding is not None
with pytest.raises(ValueError):
vuln = scan.make_event(
{"path": "/tmp/asdf.txt", "description": "test", "severity": "HIGH"}, "VULNERABILITY", parent=event3
)
vuln = scan.make_event({"description": "test", "severity": "HIGH"}, "VULNERABILITY", parent=event3)
vuln = scan.make_event(
{"path": "/tmp/asdf.txt", "description": "test", "severity": "HIGH"}, "VULNERABILITY", parent=event3
)
assert vuln is not None
vuln = scan.make_event(
{"host": "evilcorp.com", "description": "test", "severity": "HIGH"}, "VULNERABILITY", parent=event3
)
assert vuln is not None


def test_event_magic():
Expand Down
Loading