feat: deduplicate bounties on (bounty_type, attacker_ip, payload)

Before inserting a bounty, check whether an identical row already exists.
Drops silent duplicates to prevent DB saturation from aggressive scanners.
This commit is contained in:
2026-04-15 18:02:52 -04:00
parent 0ab97d0ade
commit e9d151734d
2 changed files with 93 additions and 0 deletions

View File

@@ -327,6 +327,15 @@ class SQLModelRepository(BaseRepository):
data["payload"] = json.dumps(data["payload"])
async with self.session_factory() as session:
dup = await session.execute(
select(Bounty.id).where(
Bounty.bounty_type == data.get("bounty_type"),
Bounty.attacker_ip == data.get("attacker_ip"),
Bounty.payload == data.get("payload"),
).limit(1)
)
if dup.first() is not None:
return
session.add(Bounty(**data))
await session.commit()