diff --git a/bbot/scanner/target.py b/bbot/scanner/target.py index 6de7fdf8ac..f121895455 100644 --- a/bbot/scanner/target.py +++ b/bbot/scanner/target.py @@ -147,7 +147,7 @@ def add_target(self, t, event_type=None): # allow commented lines if not str(t).startswith("#"): raise ValidationError(f'Could not add target "{t}": {e}') - if self.make_in_scope: + if self.make_in_scope and event.host: event.scope_distance = 0 try: self._events[event.host].add(event) diff --git a/bbot/test/test_step_1/test_target.py b/bbot/test/test_step_1/test_target.py index 90db526c7f..a54cd36c16 100644 --- a/bbot/test/test_step_1/test_target.py +++ b/bbot/test/test_step_1/test_target.py @@ -1,7 +1,8 @@ from ..bbot_fixtures import * # noqa: F401 -def test_target(bbot_config, bbot_scanner): +@pytest.mark.asyncio +async def test_target(bbot_config, bbot_scanner): scan1 = bbot_scanner("api.publicapis.org", "8.8.8.8/30", "2001:4860:4860::8888/126", config=bbot_config) scan2 = bbot_scanner("8.8.8.8/29", "publicapis.org", "2001:4860:4860::8888/125", config=bbot_config) scan3 = bbot_scanner("8.8.8.8/29", "publicapis.org", "2001:4860:4860::8888/125", config=bbot_config) diff --git a/bbot/test/test_step_2/module_tests/test_module_github_org.py b/bbot/test/test_step_2/module_tests/test_module_github_org.py index 4a01544f6d..5f15d0892e 100644 --- a/bbot/test/test_step_2/module_tests/test_module_github_org.py +++ b/bbot/test/test_step_2/module_tests/test_module_github_org.py @@ -367,3 +367,55 @@ def check(self, module_test, events): and e.scope_distance == 2 ] ), "Found to find TheTechromancer github repo" + + +class TestGithub_Org_Custom_Target(TestGithub_Org): + targets = ["ORG:blacklanternsecurity"] + config_overrides = {"scope_report_distance": 10, "omit_event_types": [], "speculate": True} + + def check(self, module_test, events): + assert len(events) == 7 + assert 1 == len( + [e for e in events if e.type == "ORG_STUB" and e.data == "blacklanternsecurity" and e.scope_distance == 1] + ) + assert 1 == len( + [ + e + for e in events + if e.type == "SOCIAL" + and e.data["platform"] == "github" + and e.data["profile_name"] == "blacklanternsecurity" + and e.scope_distance == 1 + ] + ) + assert 1 == len( + [e for e in events if e.type == "DNS_NAME" and e.data == "github.com" and e.scope_distance == 1] + ) + assert 1 == len( + [ + e + for e in events + if e.type == "URL_UNVERIFIED" + and e.data == "https://github.com/blacklanternsecurity" + and e.scope_distance == 1 + ] + ) + assert 1 == len( + [ + e + for e in events + if e.type == "CODE_REPOSITORY" + and e.data["url"] == "https://github.com/blacklanternsecurity/test_keys" + and e.scope_distance == 1 + ] + ) + assert 1 == len( + [ + e + for e in events + if e.type == "SOCIAL" + and e.data["platform"] == "github" + and e.data["profile_name"] == "TheTechromancer" + and e.scope_distance == 2 + ] + )