Skip to content

test: stop printing the asserted Result in the seven flagged assertions - #1611

Merged
Jaro-c merged 1 commit into
developfrom
fix/no-tainted-result-in-assertion-messages
Aug 30, 2026
Merged

Jaro-c merged 1 commit into
developfrom
fix/no-tainted-result-in-assertion-messages

Conversation

@Jaro-c

@Jaro-c Jaro-c commented Aug 30, 2026

Copy link
Copy Markdown
Member

Summary

Seven rust/cleartext-logging alerts are open on main, all the same shape: an assertion in the integration suite formatting a Result that CodeQL traced back to create_project_secrets.

The source is the function's name. SensitiveDataCall matches on HeuristicNames::nameIndicatesSensitiveData, so create_project_secrets is a taint source because it contains "secret" — not because of anything its Result<()> can carry, and #1599 already made it impossible for a payload to reach one of those errors.

The fix that corrects the model rather than the sinks needs a ModelsAsDataBarrier, which needs a configuration this repository owns, which the organization's Glyndor baseline pins away. That was #1603 and it is closed. This is what is left.

Why removing the value is certain to work

Not hoped — measured, twice, from the scan's own results:

  • resources_health.rs:209 already asserts on the same tainted result with a plain message and is not flagged.
  • Eighteen .unwrap() calls on the same values across the suite are not flagged either.

Only assert! interpolating the value is a sink.

Seven changed, eleven left alone

There are eighteen occurrences of the pattern in the suite. CodeQL flagged seven. The other eleven are on paths the query does not reach.

Nothing syntactic separates them, so each of the three files gains a note saying the inconsistency is deliberate. Without it the next reader tidies it up and the alerts come back — which is the failure this repository keeps meeting in prose form.

The one that lost the most is split, not flattened

commands_networking.rs's matches! assertion would have gone from naming what it got to saying nothing:

let err = result.expect_err("expected RunExited, got Ok");
assert!(
    matches!(err, podup::ComposeError::RunExited(_)),
    "expected RunExited, got a different ComposeError variant"
);

expect_err prints the Ok value, which here is (), so it is safe and it keeps the difference between the run succeeded and it failed with the wrong variant. A single flat message would have thrown that away.

Test plan

  • cargo fmt --all --check and cargo clippy --locked --all-targets --all-features -- -D warnings, both clean
  • The affected tests pass against live Podman: run_flags and commands_networking all green, including the restructured one
  • The restructured assertion driven red by expecting Unsupported instead of RunExited — reports "expected RunExited, got a different ComposeError variant"
  • Exactly seven occurrences removed: 18 before, 11 after

The cost, stated rather than discovered

These seven no longer say which error they got. And nothing prevents an eighth: a syntactic gate cannot tell the seven from the eleven, so there is no check to add that would not also ban the assertions that are fine.

Whether the alerts actually clear will not be visible until this reaches main, because code scanning runs on the default branch only.

Checklist

  • Targets develop
  • Commits are signed off (DCO, git commit -s) and signed
  • Labels applied
  • No secrets, keys or credentials in code, logs or fixtures
  • Cargo.toml and debian/changelog untouched
  • Docs updated if behaviour changed. Tests only

Refs #3, #4, #5, #6, #7, #8, #9.

Signed-off-by: Jaro-c 75870284+Jaro-c@users.noreply.github.com

Seven `rust/cleartext-logging` alerts are open on `main`, all of them the same
shape: an assertion in the integration suite formatting a `Result` that CodeQL
traced back to `create_project_secrets`.

The source is the function's NAME. `SensitiveDataCall` matches on
`HeuristicNames::nameIndicatesSensitiveData`, so `create_project_secrets` is a
taint source because it contains "secret", not because of anything its
`Result<()>` can carry — and #1599 already made it impossible for a payload to
reach one of those errors. The fix that would have corrected the model rather
than the sinks needs a barrier model, which needs a configuration this
repository owns, which the organization's `Glyndor baseline` pins away. That was
#1603 and it is closed. This is what is left.

Removing the formatted value removes the sink. That is certain rather than
hoped: `resources_health.rs:209` already asserts on the same tainted result with
a plain message and is not flagged, and eighteen `.unwrap()` calls on the same
values across the suite are not flagged either. Only `assert!` interpolating the
value is a sink.

Seven changed, eleven left alone. There are eighteen occurrences of the pattern
in the suite and CodeQL flagged seven; the other eleven are on paths the query
does not reach. Nothing syntactic separates them, so each of the three files
gains a note saying why the inconsistency is deliberate — without it, the next
reader tidies it up and the alerts come back.

The `matches!` assertion in `commands_networking.rs` lost the most, so it is
split instead of flattened. `expect_err` first, which prints the `Ok` value —
here `()` — then the variant check. That keeps the difference between "the run
succeeded" and "it failed with the wrong variant", which a single flat message
would have thrown away. Driven red by expecting `Unsupported` instead:
"expected RunExited, got a different ComposeError variant".

The cost, stated rather than discovered: these seven no longer say which error
they got, and nothing prevents an eighth. A syntactic gate cannot tell the seven
from the eleven, so there is no check to add that would not also ban the
assertions that are fine.

Signed-off-by: Jaro-c <75870284+Jaro-c@users.noreply.github.com>
@Jaro-c Jaro-c added type:security Security-relevant change type:test Tests prio:P2 Medium priority effort:S Small status:review In review labels Aug 30, 2026
@Jaro-c
Jaro-c merged commit fa536fe into develop Aug 30, 2026
25 checks passed
@Jaro-c
Jaro-c deleted the fix/no-tainted-result-in-assertion-messages branch August 30, 2026 19:19
Jaro-c added a commit that referenced this pull request Aug 30, 2026
Eight pull requests, no version bump and no tag. Both branches stay at 5.4.0 and release.yml fires only on a v* tag or a manual dispatch.

Update path: #1612 podup update's refusal on an apt-owned binary now says when apt will never do it either; #1609 that refusal now happens for Homebrew and Scoop too, which it never did; #1607 glyndor-archive-keyring becomes a hard Depends.
Security: #1611 the seven assertions CodeQL flagged stop printing the Result they assert on.
Housekeeping: #1606 podup stops publishing to crates.io; #1604 the two crates excluded from the workspace get their own Dependabot entries; #1605 the two files closest to the line-limit cap are split; #1601 the README says what depending on unattended-upgrades does not buy.

This promotion also measured the code_scanning rule added to protect-main earlier today. With seven rust/cleartext-logging alerts open on main, it came back CLEAN. GitHub's documented behaviour -- that the rule blocks on alerts introduced by the pull request rather than pre-existing ones -- is confirmed rather than read.

What it does not fix: code scanning still runs on the default branch only, so none of the eight was scanned on its own pull request. #1603 would have changed that and is closed, because the organization's Glyndor baseline pins CodeQL to default setup across fifteen repositories.

Signed-off-by: Jaro-c <75870284+Jaro-c@users.noreply.github.com>
@Jaro-c Jaro-c mentioned this pull request Aug 30, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort:S Small prio:P2 Medium priority status:review In review type:security Security-relevant change type:test Tests

Development

Successfully merging this pull request may close these issues.

1 participant