Skip to content

Rust: Address result duplication in rust/hard-coded-cryptographic-value - #22426

Open
geoffw0 wants to merge 3 commits into
github:mainfrom
geoffw0:match
Open

Rust: Address result duplication in rust/hard-coded-cryptographic-value#22426
geoffw0 wants to merge 3 commits into
github:mainfrom
geoffw0:match

Conversation

@geoffw0

@geoffw0 geoffw0 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Small fix for a result duplication issue in rust/hard-coded-cryptographic-value. The issue is a match expression containing constants in each or many of the match arms, for example (from the test):

let str3 = match(val) {
    0 => "one", // constant
    1 => "two", // constant
    _ => "many" // constant
}

It turns out this can cause quite severe multiplication of results in rare cases (e.g. imagine the above but with 100 cases, and flowing to 20 sinks). The solution is to make the match expression itself the source, as it's close enough to see what's going on with just one result.

@geoffw0
geoffw0 requested a review from a team as a code owner August 25, 2026 16:52
Copilot AI balanced review requested due to automatic review settings August 25, 2026 16:52
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Collapses constant match-arm sources into the enclosing match expression, preventing duplicate cryptographic-value alerts.

Changes:

  • Treats qualifying match expressions as constant sources.
  • Adds regression coverage and updates expected results.
  • Documents the analysis improvement.
Show a summary per file
File Description
HardcodedCryptographicValueExtensions.qll Adds match-expression source aggregation.
test_cookie.rs Adds regression test coverage.
HardcodedCryptographicValue.expected Updates generated expectations.
2026-08-25-hardcoded-cryptographic-match-expressions.md Adds change note.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants