Repository navigation
e2e: generate browser test credentials at runtime with a literal guard - #242
Merged
Merged
Conversation
Moves all browser test passwords out of literals in web/e2e/*.spec.ts into per-run OS-random helpers in web/e2e/fixtures.ts (testPassword, wrongTestPassword, freshTestPassword), mirroring crates/consolebook-server/tests/support/mod.rs. Adds a Rust guard test (tests/no_e2e_credential_literals.rs) with a negative-control corpus and tree-walk check covering every .ts file under web/e2e/. Closes #143
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Primary Issue
Closes #143
Problem And Outcome
#126moved Rust integration test credentials to runtime-generated OS-random values incrates/consolebook-server/tests/support/mod.rsand addedtests/no_credential_literals.rsto prevent hard-coded password literals from returning. However, 11 Playwright browser specs underweb/e2e/still declared 25 hard-coded password literals (const PASSWORD = 'invented-passphrase-1',password: 'invented-passphrase-1',.fill('invented-passphrase-1'),.fill('wrong-password-x'), etc.).This PR adds one runtime credential generator in
web/e2e/fixtures.ts, migrates all 11 browser specs to use it, and adds a Rust guard test (crates/consolebook-server/tests/no_e2e_credential_literals.rs) with a negative-control corpus and tree-walk test covering every.tsfile underweb/e2e/.Why not split:
web/e2e/draft-recovery.spec.tsonly replaces three existing password constant literals with runtime helper calls without adding behavior.Changes
web/e2e/fixtures.tstestPassword(),wrongTestPassword(), andfreshTestPassword()generating 41-byte OS-randominvented-<32 hex>credentials per worker process, mirroringcrates/consolebook-server/tests/support/mod.rs.web/e2e/*.spec.ts(11 files:draft-recovery.spec.ts,drafts.spec.ts,installation-export.spec.ts,lifecycle.spec.ts,programs.spec.ts,public-url.spec.ts,retention.spec.ts,sessions.spec.ts,shell.spec.ts,signoff-history.spec.ts,welcome.spec.ts)testPassword(),wrongTestPassword(), andfreshTestPassword()from./fixtures.crates/consolebook-server/tests/no_e2e_credential_literals.rs&crates/consolebook-server/tests/no_e2e_credential_literals/cases.txtcargo test --workspace(andnix flake check/fmt-clippy-test/cargo xtask proof), covering sensitive bindings, object/JSON fields, embedded JSON, Playwright.getByLabel/.getByPlaceholder(...).fill(...), and sign-in/reset calls, with a 39-case corpus (positive findings, clean shapes, documentedmisseditems drift-checked against the doc header, malformed inputs) and a Unix tree-walk check (nested.ts, skips non-.tsand symlinks, fails naming non-UTF-8 files).Correction Ladder
Rung 2 (automated static guard test in
cargo test --workspace+ single runtime credential generator inweb/e2e/fixtures.ts).Verification
Red-first proof (before migrating
web/e2e/*.spec.ts)cargo test -p consolebook-server --test no_e2e_credential_literalsfailedno_e2e_spec_declares_its_own_credential_literal(whilethe_case_corpus_scans_as_writtenandthe_walk_skips_links_and_data_and_names_bad_filespassed), reporting all 25 credential literals across all 11 spec files (draft-recovery.spec.ts,drafts.spec.ts,installation-export.spec.ts,lifecycle.spec.ts,programs.spec.ts,public-url.spec.ts,retention.spec.ts,sessions.spec.ts,shell.spec.ts,signoff-history.spec.ts,welcome.spec.ts).After migration
cargo test -p consolebook-server --test no_e2e_credential_literals: 3/3 passed.cargo test -p consolebook-server --test no_credential_literals: 4/4 passed.Local proof receipt — passed
3996761a41a41ed6398dea22d73065cf69d4a089treec588ab2747d1c8547be79e55e5998a63af5cc5a1; unchanged during run: truecargo xtask proofin/data/dev/src/consolebook87f297e8dad4868f1364b29eb9a45b372ca3dc34e8e205c3505d15883036daa5/home/dev/.cache/ms-playwright/chromium-1254/chrome-linux64/chrome(Google Chrome for Testing 158.0.8127.18)target/debug/consolebook-serversha256e86669c18fb4dd6da407be509b38325346aa3d245380b36a5509a422622c6e4022f6d23e1ba0e5a809c5bef6d755ddaf7260b64eac577bb91bc83ebc7a7135619e9ae832d188b3c187efc2e7864e8fc8d1c86fa28f4e2f9afc69d65439e7f458scripts/check-guidance-names.sh2b172a8e66c87574(cd web && npm ci && npm run check && npm run build)a32fa5d1785abce9cargo fmt --checke3b0c44298fc1c14cargo clippy --workspace --all-targets -- -D warningsb27fd2d5e31f7322cargo test --workspace3ef305d9dcd06ffecargo build -p consolebook-server3406675665ce13d9(cd web && npx playwright install chromium && npm run e2e)182efa6bb02e70a8