Skip to content

Commit

Permalink
Merge pull request #1348 from blacklanternsecurity/fix-unwanted-orgs
Browse files Browse the repository at this point in the history
Fix ORG Target Bug
  • Loading branch information
TheTechromancer authored May 3, 2024
2 parents c2478e3 + d31ec7a commit 6fbf389
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bbot/scanner/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion bbot/test/test_step_1/test_target.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
52 changes: 52 additions & 0 deletions bbot/test/test_step_2/module_tests/test_module_github_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
)

0 comments on commit 6fbf389

Please sign in to comment.