test: fail when sudo action filter selects nothing - #421
Conversation
Signed-off-by: ITSMESB <131141975+ITSMERNB@users.noreply.github.com>
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at 27d05215714cfddf250ec3ce6e5b06d9afbf907b.
Six lines, and they close a hole I would not have found by reading. I proved both directions in a network-isolated container rather than reasoning about it.
With your change, breaking the filter so it selects nothing:
$ sed -i 's/if \*program != "sudo" {/if *program != "sudoX" {/' crates/sysknife-daemon/tests/sudoers_grants_match_argv.rs
$ cargo test -p sysknife-daemon --test sudoers_grants_match_argv --offline
running 2 tests
test every_sudo_action_is_authorised_by_a_packaged_grant ... FAILED
panicked at crates/sysknife-daemon/tests/sudoers_grants_match_argv.rs:116:5:
only 0 sudo action specs were checked; the mechanism or program filter must have changed and this guard is no longer looking at anything
test result: FAILED. 1 passed; 1 failed
The same mutation against main, without your six lines:
$ git checkout origin/main -- crates/sysknife-daemon/tests/sudoers_grants_match_argv.rs
$ sed -i 's/if \*program != "sudo" {/if *program != "sudoX" {/' ...
$ cargo test -p sysknife-daemon --test sudoers_grants_match_argv --offline
running 2 tests
test every_sudo_action_is_authorised_by_a_packaged_grant ... ok
test result: ok. 2 passed; 0 failed
Green, checking nothing, for as long as anyone cared to look. That is the whole argument for this PR and it is now on the record. The guard that verifies every sudo action has a matching grant could have been silently inspecting an empty set after any refactor of ActionMechanism, and the board would have stayed green.
I like that you put the counter next to the pre-existing assert!(!grants.is_empty(), ...). Both inputs to the cross-check are now guarded, which makes the pair read as deliberate rather than as one-off paranoia.
One optional note, with a measurement attached. I set the threshold impossibly high to make the test print the real number:
$ sed -i 's/checked > 50,/checked > 100000,/' ...
only 132 sudo action specs were checked; ...
So the live count is 132 against a floor of 50. The guard fires only if the catalogue loses more than 61% of its sudo specs. That still catches the failure you wrote it for, which is the filter going vacuous, so I am not asking you to change it. If you want it tighter, something near 120 would catch a partial regression too, at the cost of a number that needs nudging when the catalogue grows. Your call, and it does not block the merge.
Heads up on a collision that is not your fault: #429 edits the same function at the same insertion point, so whichever of the two lands second needs a trivial rebase. Both additions are compatible and the resolution is to keep both lines. I will handle the ordering.
Approving. This is a small diff that makes an existing guard honest, which is my favourite kind.
|
Merged as You turned a guard that could pass while looking at nothing into one that says so out loud, and the gate ran that proof rather than taking my review's word for it: The mutation breaks the program filter so the loop selects nothing, which is the exact shape your assertion exists for, and it fails at rc=101: I updated your branch against I said on the review that the #429 ordering was mine to handle, and it is: #429 now conflicts in your file, in #423 is still waiting on the Two pull requests from you in a week, both about making a check able to fail, says you have been burned by one that could not. If you run Linux anywhere that matters, a server you patch or a fleet you keep alive, I would like to know how SysKnife reads there. |
…and lacs-project#421 The branch recorded 1853, which was right when it was written and is one short now that lacs-project#426 landed. The figure comes from the runner rather than from arithmetic: $ UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh test_baseline: recorded 1854 rust tests in tests/evidence/workspace-tests.json The three published figures move with it, in README.md, docs/introduction.md and docs/distro-support.md, and scripts/check_evidence_claims.py agrees: Published figures match the evidence artifacts. Maintainer change on a contributor branch; the pull request's own commits are untouched.
* fix(daemon): declare CHAIN_ROW_COLUMNS once, in store.rs The 17-column ChainRow SELECT list was declared twice — once per backend — kept in sync only by a 'Mirrors' doc comment. The Postgres copy's own comment records the last drift: a column addition updated one query and the mapper, and the miss surfaced only as a runtime 'no column found for name: chain_version' from the live-Postgres test while unit tests stayed green. Hoist one pub(crate) const into store.rs, the shared parent of both backends; both modules import it, the four SELECT sites keep their per-backend placeholders (?1 / $1), and the second declaration goes. The drift test ran green first, was mutated red on purpose (failure pasted in the PR), and is replaced by a pin on the exact 17-column list — the invariant both mappers depend on. Closes #397 * chore: move the rust test baseline to 1853 with the new pin chain_row_columns_pinned adds one test to the workspace suite. The baseline and the three published figures that derive from it move with it, per the check the CI run called out. * chore(evidence): move the rust baseline to 1854 after #426 and #421 The branch recorded 1853, which was right when it was written and is one short now that #426 landed. The figure comes from the runner rather than from arithmetic: $ UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh test_baseline: recorded 1854 rust tests in tests/evidence/workspace-tests.json The three published figures move with it, in README.md, docs/introduction.md and docs/distro-support.md, and scripts/check_evidence_claims.py agrees: Published figures match the evidence artifacts. Maintainer change on a contributor branch; the pull request's own commits are untouched. --------- Co-authored-by: Vladimir Rotariu <sysknife-development@protonmail.com>
Summary
Validation
sudo->sudozmutation: targeted nextest run started 2 tests and failed withonly 0 sudo action specs were checkedcargo fmt --all -- --checkgit diff --checkCloses #408