Conversation
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.
chainsaw lintcurrently exits0even when rules fail to validate, so it cannot be used as a gate — in CI or anywhere else.The
Command::Lintarm already countsfailed— it just never acts on it. This returns an error when that count is non-zero, then adds a workflow that runs the linter on pull requests.Changes
1.
lintfails when rules fail (src/main.rs, 3 lines)Consistent with the existing
bail!/return Err(anyhow!(...))usage in other subcommands in the same function. Output on success is unchanged; on failure the existing per-file[!]lines are unchanged and a summary error is added.2.
.github/workflows/lint-rules.yml— runs on PRs touchingrules/,src/or the cargo manifests. It builds chainsaw from the PR's own source rather than downloading a release, so a rule that depends on a schema change in the same PR is validated against that change. UsesSwatinem/rust-cache, so only the first run pays the full build.Verification
Built locally and tested both paths:
rules/with #240 appliedValidated 131 detection rules out of 131rules/as on master[x] 1 detection rule(s) failed to validaterules/as on masterValidated 130 … out of 131— passes silentlyThe last row is the problem this fixes.
Note — CI here will be red until #240 merges
This PR's own check will fail, because master still contains the malformed
rules/mft/netexec_mft.ymlthat #240 fixes. That failure is the check doing its job on its first run: the rule has been unloadable since it was added in #226 (2026-04-01) and nothing surfaced it.Merge #240 first and this goes green. Happy to rebase, or to fold the two together if you would rather review one change.
Open questions
actions-rs/toolchain@v1is used here to match the existingv1.yml/v2.yml, but that action is archived upstream. Happy to switch this workflow todtolnay/rust-toolchain— I kept it consistent rather than introducing a second pattern unasked.lintfail by default, on the reasoning that a linter which cannot fail is not useful for automation. If you would rather not change existing behaviour, this could be--fail-on-error/--strictinstead, with CI passing the flag. Say which you prefer and I will adjust.master. Easy to drop if you would rather keep it PR-only.