Skip to content

Commit

Permalink
Merge pull request #1872 from blacklanternsecurity/fix-preset-bug
Browse files Browse the repository at this point in the history
Fix bug with module exclusions
  • Loading branch information
TheTechromancer authored Oct 18, 2024
2 parents 7bbc9e6 + c6f445b commit a3f0bbe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
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 @@ -532,9 +532,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

0 comments on commit a3f0bbe

Please sign in to comment.