Skip to content

Commit 7199895

Browse files
Merge pull request #57 from bWlrYQ/fix-target-id-filtering
Fix target_id filtering for technologies and findings listing when using the API
2 parents ade99fe + 26cae88 commit 7199895

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

bbot_server/modules/assets/assets_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,8 @@ async def _update_asset(self, host: str, update: dict):
197197

198198
async def _insert_asset(self, asset: dict):
199199
# we exclude scope here to avoid accidentally clobbering it
200-
asset.pop("scope", None)
200+
# however we preserve scope for technologies and findings since they should inherit scope
201+
asset_type = asset.get("type", "Asset")
202+
if asset_type == "Asset":
203+
asset.pop("scope", None)
201204
await self.strict_collection.insert_one(asset)

bbot_server/modules/findings/findings_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ async def handle_event(self, event, asset):
126126
cves=cves,
127127
event=event,
128128
)
129+
# inherit scope from the parent asset so as to make sure that target_id filtering works
130+
if asset and hasattr(asset, "scope"):
131+
finding.scope = asset.scope
129132
# update finding names
130133
findings = set(getattr(asset, "findings", []))
131134
findings.add(finding.name)

bbot_server/modules/technologies/technologies_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ async def handle_event(self, event, asset):
123123
netloc=event.netloc,
124124
last_seen=event.timestamp,
125125
)
126+
# inherit scope from the parent asset so as to make sure that target_id filtering works
127+
if asset and hasattr(asset, "scope"):
128+
t.scope = asset.scope
126129
# insert the technology into the database
127130
await self._update_or_insert_technology(t)
128131
# make an activity if the technology is new

0 commit comments

Comments
 (0)