Conversation
load_and_check_rules() only looked at the errors of the rules in SigmaCollection.rules. Errors that are not attached to a rule, such as an unknown collection 'action:' or an invalid filter (filters are kept in SigmaCollection.filters), were never reported, so 'sigma check' passed inputs that 'sigma convert' rejects. These errors are now reported, counted as rule errors (so --fail-on-error applies) and added to the JUnit report. Rule errors are also contained in SigmaCollection.errors; they are skipped there so they are not counted twice. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BLUF
sigma checkonly reads the errors attached to rules inSigmaCollection.rules. It ignores errors that belong to no rule, such as an unknownaction:or an invalid filter (filters are stored inSigmaCollection.filters).sigma check --fail-on-error --fail-on-issues rules/passes (exit 0, "Found 0 errors") on a file thatsigma convert -t <backend> rules/rejects with "Errors found in Sigma rules". A CI gate built onsigma checklets these files through.load_and_check_rules()now also reports the entries ofSigmaCollection.errorsthat don't belong to a loaded rule. They count as rule errors, so--fail-on-errorapplies, and they are added to the--junitxmlreport. Per-rule errors, which pySigma also copies intoSigmaCollection.errors, are still counted once.mainand pass with the fix.Priority: high
Details
Root cause:
sigma/cli/check.py:130-175.load_and_check_rules()loops overrule_collection.rulesand readsrule.errors. It never readsrule_collection.errors, butsigma convertdoes, viacheck_rule_errors()(sigma/cli/rules.py:39-49). The two commands therefore disagree on:action: repaetraisesSigmaCollectionError. No rule is created, so the error lives only inSigmaCollection.errors.SigmaFilteris kept inSigmaCollection.filters, not in.rules, so its errors (for example an invalidid) are never seen.pySigma also puts every per-rule error into
SigmaCollection.errors(collection.pyerrors.extend(parsed_rule.errors)). The fix therefore skips errors that are already attached to a rule in.rules, compared by object identity. The count fortests/files/invalidstays at 6.Before:
After:
Testing
tests/test_check.py:test_check_unknown_collection_action(fails onmain)test_check_invalid_filter(fails onmain)test_check_collection_error_junitxml(fails onmain)test_check_rule_errors_not_double_counted(regression guard)poetry.lock: pySigma 1.4.0, click 8.4.2, pyparsing 3.3.2):pytest --cov=sigma→ 122 passed, 1 skipped.🤖 Generated with Claude Code