Skip to content

Move Spamhaus DROP tagging to its own enrichment job. Closes #1751 - #1833

Merged
regulartim merged 2 commits into
developfrom
feature/spamhaus-drop-tags
Nov 9, 2026
Merged

regulartim merged 2 commits into
developfrom
feature/spamhaus-drop-tags

Conversation

@rainnj

@rainnj rainnj commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Description

The FireHol job was also tagging Spamhaus rows, since both use the same FireHolList table. Now Spamhaus has its own job, so each source owns its own tags.

  • new SpamhausDropBlocklistCron with its own task and daily schedule
  • FireHolRepository read methods now take a sources list, so each job only reads its own rows
  • moved the FireHol source names to the top of firehol.py so the job can import them
  • has_entries now only checks the job's own rows, so a failed FireHol download can't wipe FireHol tags
  • migration 0075 moves old Spamhaus tags from source="firehol" to source="spamhaus_drop"

Note: Spamhaus tags now show spamhaus_drop as the source in the API. The lookup page only shows firehol tags, 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

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

Checklist

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • I have read and understood the AI policy.
  • I chose an appropriate title for the pull request in the form: <feature name>. Closes #999
  • My branch is based on develop.
  • The pull request is for the branch develop.
  • I have reviewed and verified any LLM-generated code included in this PR.
  • I am interested in participating in GSoC.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • I have checked if my changes affect user-facing behavior that is described in the wiki. If so, I also included an update to the wiki in the description of this PR.
  • Linter (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

GUI changes

No GUI changes

@rainnj rainnj self-assigned this Nov 4, 2026
@rainnj
rainnj requested a review from regulartim November 4, 2026 21:01
@regulartim

Copy link
Copy Markdown
Member

Hey @rainnj ! Are you really interested in a GSoC participation (you checked that checkbox)?

@regulartim regulartim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job as always! :) The changes I suggest are cosmetic.

from greedybear.cronjobs.repositories import FireHolRepository


class SpamhausDropBlocklistCron(BaseEnrichmentJob):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. I wrote a common base class blocklist_enrichment

same table have their own job, FireHolBlocklistCron.
"""

SOURCE_NAME = "spamhaus_drop"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a type annotation to ioc_id.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_tag_entry is now gone. Both jobs use build_tag_entries from the sharec base class BlocklistEnrichmentJob, so ioc_id isnt there anymore

@rainnj
rainnj requested a review from regulartim November 9, 2026 12:39
@rainnj

rainnj commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Good job as always! :) The changes I suggest are cosmetic.

Thank youu @regulartim ! let me know if everything is okay now

@regulartim regulartim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! :)

@regulartim
regulartim merged commit 0e484bd into develop Nov 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants