Skip to content

crypto/hardcoded-secret flags CancelToken::default(), and review_prepare lists findings that review_finalize will ignore #697

Closed

Description

@ajianaz

Cora version

cora 0.19.0

Operating system

macOS (Darwin 25.5.0, arm64)

Which command?

cora review --staged --no-llm, and the MCP agent-as-reviewer tools cora.review_prepare / cora.review_finalize.

What happened?

1. crypto/hardcoded-secret matches a type name, not a secret. In a Rust diff, this line is reported as CRITICAL "Hardcoded password or secret in variable":

let cancel = CancelToken::default();

Nothing here is a credential: CancelToken is a type and default() a constructor. In the same diff, let a_token = Session::default(); and let x = Builder::default(); are NOT flagged, so the pattern appears to key on the text Token::default, not on an assignment of a literal.

Impact: to keep reviews usable, a project has to silence the rule by title (ignore.rules: ["Hardcoded password or secret"]), and that title-based ignore suppresses EVERY crypto/hardcoded-secret finding, real hardcoded secrets included. We do this in codecoradev/tole today; a narrower rule would let us drop that blanket ignore.

2. review_prepare reports findings that review_finalize will drop. With the ignore above in .cora.yaml, cora.review_prepare still lists the finding in deterministic_findings (critical, crypto/hardcoded-secret), while cora.review_finalize on the same diff with no agent findings returns total_issues: 0, should_block: false. An agent reading the prepare payload sees a CRITICAL it should not act on. This happened in a real session: the agent changed code to avoid a finding that the repo's config already ignored.

What did you expect to happen?

  1. crypto/hardcoded-secret fires on a secret-shaped value assigned to a secret-shaped name (a string literal, a key-like token), not on <Type>Token::default() or any constructor call.
  2. review_prepare either applies the repo's ignore rules (and inline cora-ignore markers) to deterministic_findings, or marks each finding that finalize will drop (for example "ignored": true plus the matching rule), so the agent judges against what will actually be reported.

Steps to reproduce

mkdir repro && cd repro && git init -q
printf 'fn main() {}\n' > main.rs && git add main.rs && git commit -qm init
printf 'fn main() {\n    let cancel = CancelToken::default();\n    let a_token = Session::default();\n    let x = Builder::default();\n}\n' > main.rs
git add main.rs

# 1. Only line 2 is reported:
cora review --staged --no-llm --format compact
#   [CRITICAL] main.rs:2: Hardcoded password or secret in variable (crypto/hardcoded-secret)

# 2. Ignore the rule by title, then compare prepare and finalize:
printf 'ignore:\n  rules:\n    - "Hardcoded password or secret"\n' > .cora.yaml
cora review --staged --no-llm --format compact
#   No issues found.
git diff --cached > repro.diff

Then, over cora mcp (stdio JSON-RPC) with the contents of repro.diff:

  • cora.review_prepare {"diff": <repro.diff>} → deterministic_findings contains {"file": "main.rs", "line": 2, "rule_id": "crypto/hardcoded-secret", "severity": "critical"}.
  • cora.review_finalize {"diff": <repro.diff>, "issues": []} → total_issues: 0, should_block: false.

Additional context

Found while running the agent-as-reviewer flow as the commit gate on codecoradev/tole.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscope:coreCore review engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions