Repository navigation
Move Spamhaus DROP tagging to its own enrichment job. Closes #1751 - #1833
Conversation
|
Hey @rainnj ! Are you really interested in a GSoC participation (you checked that checkbox)? |
regulartim
left a comment
There was a problem hiding this comment.
Good job as always! :) The changes I suggest are cosmetic.
| from greedybear.cronjobs.repositories import FireHolRepository | ||
|
|
||
|
|
||
| class SpamhausDropBlocklistCron(BaseEnrichmentJob): |
There was a problem hiding this comment.
This new job basically does exactly what FireHolBlocklistCron does, right? Is it possible to make SpamhausDropBlocklistCron a subclass of FireHolBlocklistCron (or alternatively, let both share a third, common base class) and get rid of most of the code here?
There was a problem hiding this comment.
Yeah, I agree. I wrote a common base class blocklist_enrichment
| same table have their own job, FireHolBlocklistCron. | ||
| """ | ||
|
|
||
| SOURCE_NAME = "spamhaus_drop" |
There was a problem hiding this comment.
greedybear/cronjobs/spamhaus_drop.py already defines SOURCE_NAME for spamhouse. We should import that here instead of defining it a second time, no?
| created_count = self._write_tags(tag_entries) | ||
| self.log.info(f"{self.SOURCE_NAME} enrichment completed, created {created_count} tags.") | ||
|
|
||
| def _build_tag_entry(self, ioc_id) -> dict: |
There was a problem hiding this comment.
Please add a type annotation to ioc_id.
There was a problem hiding this comment.
build_tag_entry is now gone. Both jobs use build_tag_entries from the sharec base class BlocklistEnrichmentJob, so ioc_id isnt there anymore
Thank youu @regulartim ! let me know if everything is okay now |
Description
The FireHol job was also tagging Spamhaus rows, since both use the same
FireHolListtable. Now Spamhaus has its own job, so each source owns its own tags.SpamhausDropBlocklistCronwith its own task and daily scheduleFireHolRepositoryread methods now take asourceslist, so each job only reads its own rowsfirehol.pyso the job can import themhas_entriesnow only checks the job's own rows, so a failed FireHol download can't wipe FireHol tags0075moves old Spamhaus tags fromsource="firehol"tosource="spamhaus_drop"Note: Spamhaus tags now show
spamhaus_dropas the source in the API. The lookup page only showsfireholtags, so Spamhaus is hidden there for now, can be its own issue.Related issues
Follow up from #1714
Closes #1751
AI disclosure
I use Claude to help with code I dont understand, check my changes, and suggest fixes to enhance my code and challenge my logic, I also use it to help me write tests and help me write code if I am unsure how.
Type of change
Checklist
Formalities
<feature name>. Closes #999develop.develop.Docs and tests
Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.GUI changes
No GUI changes