[crowdstrike] Snort parser fails on single-line rules missing trailing newline#6553
[crowdstrike] Snort parser fails on single-line rules missing trailing newline#6553throuxel wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #6553 +/- ##
===========================================
- Coverage 27.71% 2.13% -25.58%
===========================================
Files 1874 1782 -92
Lines 116670 114061 -2609
===========================================
- Hits 32333 2434 -29899
- Misses 84337 111627 +27290
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the CrowdStrike Snort parser where rules lacking a trailing newline (single-rule files or last rule in a file) were silently dropped, causing the entire parse to return empty. The fix extends the end-of-rule detection in _split_snort_rules to also accept lines ending in ;) without a newline, and adds focused unit tests covering both _split_snort_rules and the full SnortParser.parse flow.
Changes:
- Broaden end-of-rule check in
_split_snort_rulesto accept;)with or without a trailing newline. - Add tests for single/multiple rules with and without trailing newlines, including full
parse(...)assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| external-import/crowdstrike/src/crowdstrike_feeds_services/utils/snort_parser.py | Adds an additional end-of-rule condition so rules without a trailing newline are flushed. |
| external-import/crowdstrike/tests/test_snort_parser_trailing_newline.py | New tests validating Snort parsing with/without trailing newlines. |
|
|
||
| if rule_buffer is not None and line.endswith(cls._RULE_ENDS): | ||
| if rule_buffer is not None and ( | ||
| line.endswith(cls._RULE_ENDS) or line.rstrip("\n").endswith(";)") |
There was a problem hiding this comment.
suggestion: Maybe it could be simplified to just:
| line.endswith(cls._RULE_ENDS) or line.rstrip("\n").endswith(";)") | |
| line.rstrip("\n").endswith(";)") |
Proposed changes
Related issues
Checklist
Further comments
I didn't manage to reproduce the issue from crowdstrike data.