Skip to content

Make lint exit non-zero on invalid rules - #242

Merged
alexkornitzer merged 1 commit into
WithSecureOpenSource:masterfrom
jpl1337:fix/lint-exit-nonzero
Sep 23, 2026
Merged

alexkornitzer merged 1 commit into
WithSecureOpenSource:masterfrom
jpl1337:fix/lint-exit-nonzero

Conversation

@jpl1337

@jpl1337 jpl1337 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Split out of #241 per review — this is the exit-code fix on its own, no CI changes.

chainsaw lint currently exits 0 even when rules fail to validate, so it cannot be used as a gate. The Command::Lint arm already counts failed — it just never acts on it. This returns an error when that count is non-zero.

$ chainsaw lint --kind chainsaw rules/        # with a malformed rule present
[!] /some/rule.yml: did not find expected key at line N column M, ...
[+] Validated 130 detection rules out of 131
$ echo $?
0   # before this change
1   # after this change

Output on success is unchanged; on failure the existing per-file [!] lines are unchanged and a summary error is added.

Verified locally: cargo build --release + chainsaw lint --kind chainsaw rules/ against current rules/ (131/131) exits 0; reintroducing a malformed rule exits 1.

@alexkornitzer

Copy link
Copy Markdown
Collaborator

Thanks :)

@alexkornitzer
alexkornitzer merged commit 5b2283d into WithSecureOpenSource:master Sep 23, 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