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 filedownload error #2107

Merged
merged 2 commits into from
Dec 20, 2024
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
2 changes: 2 additions & 0 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,8 @@ def make_event(
When working within a module's `handle_event()`, use the instance method
`self.make_event()` instead of calling this function directly.
"""
if not data:
raise ValidationError("No data provided")

# allow tags to be either a string or an array
if not tags:
Expand Down
3 changes: 2 additions & 1 deletion bbot/modules/filedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ async def download_file(self, url, content_type=None, source_event=None):
file_event = self.make_event(
{"path": str(file_destination)}, "FILESYSTEM", tags=["filedownload", "file"], parent=source_event
)
await self.emit_event(file_event)
if file_event is not None:
await self.emit_event(file_event)
self.urls_downloaded.add(hash(url))

def make_filename(self, url, content_type=None):
Expand Down
4 changes: 4 additions & 0 deletions bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ async def test_events(events, helpers):
assert str(parent_event_3.module) == "mymodule"
assert str(parent_event_3.module_sequence) == "mymodule->mymodule->mymodule"

# event with no data
with pytest.raises(ValidationError):
event = scan.make_event(None, "DNS_NAME", parent=scan.root_event)

await scan._cleanup()


Expand Down
Loading