Skip to content

Generate test credentials at run time - #28

Merged
imanimanyara merged 1 commit into
mainfrom
chore/generated-test-credentials
Oct 19, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
chore/generated-test-credentials

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Why

Secret scanning cannot tell a test key from a leaked one. GitGuardian raised 28 incidents across laranail by 2026-10-18, and 27 were test literals or false positives, each closed by hand. A value generated when the suite runs never reaches the repository, so there is nothing to report.

What changed

  • 1 literal → 0, no exemptions. OutboundHttpChannelsTest's push-channel api_key is generated with bin2hex(random_bytes(16)), and the "key not leaked into the body" assertion checks for that same value.
  • New guard tests/Unit/NoLiteralCredentialsTest.php, scanning tests/ with a floor of 8 of 10 files, plus a self-test that proves its scanner recognises a named literal and a URL password and ignores a variable.
  • No laranail/package-tools dependency, deliberately. The sweep's shared helpers (TestCredentials, AssertsNoLiteralCredentials) ship in package-tools 0.1.9, which requires PHP ^8.4.1. This package supports ^8.3 and its CI matrix tests 8.3, so even a require-dev entry would make the 8.3 leg unresolvable. Instead the literal is generated inline and the guard is a minimal local copy of package-tools' scanner (its named-position and URL rules, its shape and metadata-name filters, and the @credential-literal-exempt line marker).
  • CHANGELOG [Unreleased] → Changed.

Verification

  • vendor/bin/pest: 83 passed.
  • pint --test: pass. PHPStan (--debug --memory-limit=2G): no errors. Rector --dry-run --debug: clean.
  • package-tools' own scanner, run from another checkout over tests/, also reports 0 literals.
  • Red proof: a scratch 'token' => 'hunter2-…' line appended to LocalChannelsTest.php turned the guard red (LocalChannelsTest.php:116 hu…); restored with git checkout.

Secret scanning cannot tell a test key from a leaked one: GitGuardian raised
28 incidents across laranail, 27 of them test literals closed by hand. The
push channel's API key is now generated per run, and a guard test fails on
any literal left behind.

The guard is a minimal local copy of package-tools' check rather than a
dependency on it: package-tools requires PHP ^8.4.1, and this package's CI
still tests 8.3, so even a require-dev entry would break that leg.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@imanimanyara
imanimanyara merged commit 14a391a into main Oct 19, 2026
11 checks passed
@imanimanyara
imanimanyara deleted the chore/generated-test-credentials branch October 19, 2026 14:49
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.

2 participants