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 bug with module exclusions #1872

Merged
merged 3 commits into from
Oct 18, 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: 0 additions & 2 deletions bbot/scanner/preset/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,6 @@ def _is_valid_module(self, module, module_type, name_only=False, raise_error=Tru

if module in self.exclude_modules:
reason = "the module has been excluded"
if raise_error:
raise ValidationError(f'Unable to add {module_type} module "{module}" because {reason}')
return False, reason, {}

module_flags = preloaded.get("flags", [])
Expand Down
8 changes: 0 additions & 8 deletions bbot/test/test_step_1/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,6 @@ async def test_cli_args(monkeypatch, caplog, capsys, clean_default_config):
result = await cli._main()
assert result == True

# enable and exclude the same module
caplog.clear()
assert not caplog.text
monkeypatch.setattr("sys.argv", ["bbot", "-m", "ffuf_shortnames", "-em", "ffuf_shortnames"])
result = await cli._main()
assert result == None
assert 'Unable to add scan module "ffuf_shortnames" because the module has been excluded' in caplog.text

# require flags
monkeypatch.setattr("sys.argv", ["bbot", "-f", "active", "-rf", "passive"])
result = await cli._main()
Expand Down
19 changes: 16 additions & 3 deletions bbot/test/test_step_1/test_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,22 @@ def test_preset_module_resolution(clean_default_config):
assert set(preset.scan_modules) == {"wayback"}

# modules + module exclusions
with pytest.raises(ValidationError) as error:
preset = Preset(exclude_modules=["sslcert"], modules=["sslcert", "wappalyzer", "wayback"]).bake()
assert str(error.value) == 'Unable to add scan module "sslcert" because the module has been excluded'
preset = Preset(exclude_modules=["sslcert"], modules=["sslcert", "wappalyzer", "wayback"]).bake()
baked_preset = preset.bake()
assert baked_preset.modules == {
"wayback",
"cloudcheck",
"python",
"json",
"speculate",
"dnsresolve",
"aggregate",
"excavate",
"txt",
"httpx",
"csv",
"wappalyzer",
}


@pytest.mark.asyncio
Expand Down
Loading