Skip to content

Skip IOCs with empty days_seen in scoring pipeline#892

Merged
regulartim merged 1 commit intointelowlproject:developfrom
Sanchit2662:fix/scoring-skip-empty-days-seen
Feb 26, 2026
Merged

Skip IOCs with empty days_seen in scoring pipeline#892
regulartim merged 1 commit intointelowlproject:developfrom
Sanchit2662:fix/scoring-skip-empty-days-seen

Conversation

@Sanchit2662
Copy link
Copy Markdown
Contributor

Summary

While reviewing the scoring pipeline, I noticed that get_features() in greedybear/cronjobs/scoring/utils.py performs division using days_seen_count without checking if it's zero. Since the days_seen field in the IOC model defaults to an empty list ([]), any IOC with unpopulated data causes a ZeroDivisionError that crashes the entire scoring job — affecting both TrainModels and UpdateScores cronjobs. This prevents all IOC scores from being updated until the bad record is manually removed.

Fix

Added a guard to prevent division by zero by using max(days_seen_count, 1) when calculating per-day metrics. This ensures IOCs with empty days_seen don't crash the pipeline while still allowing them to be processed with sensible defaults.

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • My branch is based on develop.
  • The pull request is for the branch develop.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • Linter (Ruff) gave 0 errors.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

Closes #886

Closes intelowlproject#886

Signed-off-by: Sanchit2662 <sanchit2662@gmail.com>
@Sanchit2662
Copy link
Copy Markdown
Contributor Author

Hi @regulartim , please review the changes when you get a chance. Happy to make any adjustments if needed. Thanks!

Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

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

Thanks! :)

@regulartim regulartim merged commit 536a38a into intelowlproject:develop Feb 26, 2026
4 checks passed
cclts pushed a commit to cclts/GreedyBear that referenced this pull request Mar 11, 2026
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