Skip to content

test: one runtime test credential, and a guard against password literals - #145

Merged
TusanHomichi merged 2 commits into
mainfrom
claude/126-test-credential
Oct 15, 2026
Merged

TusanHomichi merged 2 commits into
mainfrom
claude/126-test-credential

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #126

Problem And Outcome

Every integration test file declared its own password. CodeQL's rust/hard-coded-cryptographic-value and rust/cleartext-logging rules then flagged each new test file, turning the PR's CodeQL check red and blocking merge until the alerts were dismissed by hand. This happened on #130 and #139.

After merge, the Rust integration tests hold no password literal outside one allowlisted compatibility fixture. A guard test fails cargo test on a new one.

Changes

  • tests/support/mod.rs provides:
    • password(), a per-process value from OS randomness;
    • wrong_password(), fresh_password(), and too_short_password();
    • the shared login and user_with_role helpers that 14 and 12 test crates had each copied;
    • assertion messages that name no user.
  • 26 test files moved onto it, for a net of about 490 fewer lines. Test meaning is unchanged; the review checked the auth, reset, recovery, policy, and wrong-password flows.
    • upgrade_compat keeps its argon2 0.5 fixture password, allowlisted by exact path. It again checks a one-character near miss, built at run time.
  • tests/no_credential_literals.rs: the guard.
    • Scan contract: stated in the header.
    • Shapes: sensitive bindings, with any non-empty literal in the initializer; fields; JSON keys; JSON inside strings; ("password", "lit") pairs; credential calls, including macros and turbofish.
    • Exemptions: empty literals, so absence and empty-password tests read naturally.
    • Remaining misses: listed in the header, each with its reason.
    • Controls: a 149-case corpus that is checked against the header in both directions.
    • Against the pre-change tests: 38 findings in 26 files.
  • docs/development.md: one sentence on where test credentials come from.

Scope

Verification

- scripts/check-guidance-names.sh
- web/: npm ci, npm run check, npm run build
- cargo fmt --check
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace
- cargo build -p consolebook-server
- web/: npm run e2e (system Google Chrome 155)

Review And Merge Notes

  • Independent review (reviewer role, frozen worktree at fc3f7fe): 0 blocking.
    • It probed the guard with 80 synthetic sources.
    • No panic, hang, or wrong line number.
    • Every pattern the old tests used is caught.
    • Three should-fixes, all applied in c19f940: the near miss, the uncaught-shape class plus an honest header, and empty-literal false positives. Nits: wording, symlinks, the unreadable-file path, and mod placement.
  • Delta: self-reviewed by the integrator.
  • Correction rungs: 1 (no literal exists, from a single support module) and 2 (the guard).
  • Authority: the maintainer selected test: one shared invented credential so CodeQL stops re-flagging every test file #126 on 2026-10-15; standing PR permission.

🤖 Generated with Claude Code

TusanHomichi and others added 2 commits October 15, 2026 14:33
Integration tests no longer declare passwords: tests/support provides a
per-process password generated from OS randomness (plus wrong, fresh, and
too-short variants), the shared login and user helpers that 14 and 12 test
crates had each copied, and assertion messages that name no user. With no
literal there is nothing for CodeQL's hard-coded-credential and
cleartext-logging rules to flag in new test files (#126; recurred on #130
and #139).

tests/no_credential_literals.rs scans every test source and fails on a
password, passphrase, or secret literal in a binding, struct field, JSON key,
JSON-in-a-string, or a credential call, with its scan contract in the header,
an exact-path allowlist (upgrade_compat's argon2 0.5 fixture), and negative
controls for every shape it flags and every allowed shape it must not; against
the pre-change tests it reports 38 findings across 28 files.

Closes #126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent review found no blockers. Follow-ups: upgrade_compat again
checks a one-character near miss of the fixture password, built at run time
(a verifier that ignored the last byte passed the previous version); a
sensitive binding is flagged for any non-empty literal in its initializer
(arrays, vec!, Some, match/if arms, closures), a ("password", "literal")
pair and macro/turbofish credential calls are caught, and sign-in helpers
are matched by more names; empty literals are exempt, so absence and
empty-password tests read naturally; the header lists every remaining miss
with its reason. The controls move to a 149-case corpus checked against the
header in both directions, the walk skips symbolic links, and an unreadable
file is named. Against the pre-change tests: 38 findings in 26 files.

Refs #126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T22:14:57.945843Z c19f940 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread crates/consolebook-server/tests/upgrade_compat.rs Dismissed
Comment thread crates/consolebook-server/tests/upgrade_compat.rs Dismissed
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.

test: one shared invented credential so CodeQL stops re-flagging every test file

2 participants