Skip to content

Generate test credentials at run time - #30

Merged
imanimanyara merged 2 commits into
mainfrom
chore/generated-test-credentials
Oct 19, 2026
Merged

imanimanyara merged 2 commits into
mainfrom
chore/generated-test-credentials

Conversation

@imanimanyara

@imanimanyara imanimanyara commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Why

GitGuardian raised 28 incidents across laranail by 2026-10-18. 27 were literal test credentials or false positives, and each was closed by hand. A provider secret spelled out in a test reads exactly like a leaked one.

What changed

  • 13 literals reported by CredentialLiterals → 0, 13 replaced, 0 exempted. Every provider secret the suite configured is now TestCredentials::secret('<purpose>'). Two positional database secrets in CredentialResolutionTest (not flagged by the scanner) were converted too, so the file is consistent.
  • Redaction tests keep their meaning. AdapterContractTest puts the generated secret in the simulated connection error and asserts the result does not contain it; CommandsTest's "never prints a secret" hunts for the same generated value it configured.
  • Distinct values are asserted. The database-over-config resolution test asserts its two generated secrets differ, since that is what proves the row won.
  • Guard: tests/Arch/NoLiteralCredentialsTest.php (the repo's existing architecture directory, already a test suite in phpunit.xml.dist), minFiles: 24 (27 files scanned).
  • laranail/package-tools floor raised to ^0.1.9, the first release with TestCredentials and the guard (laranail rule 3).
  • CHANGELOG [Unreleased] → ### Changed.

Verification (local, PHP 8.4)

  • Pest: 270 passed (860 assertions).
  • laranail-pint --test: passed.
  • PHPStan: no errors.
  • Rector dry-run: no changes.
  • Red proof: a literal 'secret' => '…' appended to WidgetTest.php turned the guard red, naming the file and line; reverted with git checkout.

Follow-up: package-tools 0.1.10

  • laranail/package-tools floor raised to ^0.1.10.
  • NoLiteralCredentialsTest gains a second test, assertCredentialPurposesAreWordsIn() (same dir, minFiles: 24).
  • Purposes renamed: 0 (all 5 were already single words). Markers removed: 0 (none in the suite).
  • Red proof: a scratch TestCredentials::password() call with a hyphenated purpose turned the new test red; the file was restored and nothing of it is committed.
  • Locally: 271 Pest tests, Pint, PHPStan and Rector clean.

GitGuardian raised 28 incidents across laranail by 2026-10-18, 27 of
them literal test credentials or false positives, each closed by hand.
A provider secret spelled out in a test reads exactly like a leaked one.

Every provider secret the suite configured is now generated by
TestCredentials. The redaction tests hunt for the same generated value
they configured, and the database-over-config test asserts its two
secrets differ, since that is what proves the row won. A guard fails on
any literal added later.

package-tools 0.1.9 is the first release with TestCredentials and the
guard, so the floor moves to ^0.1.9.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:06

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.

GitGuardian reads a compound purpose, two words joined by a hyphen, as the
password itself, which turns a generated credential back into a reported
one. package-tools 0.1.10 ships assertCredentialPurposesAreWordsIn(), so the floor
moves to ^0.1.10 and the credential guard gains a second test that keeps every
purpose a single plain lowercase word.

No purpose in this suite needed renaming, and every remaining exemption marker is still required by the 0.1.10 scanner.
@imanimanyara
imanimanyara merged commit a89afe3 into main Oct 19, 2026
21 checks passed
@imanimanyara
imanimanyara deleted the chore/generated-test-credentials branch October 19, 2026 14:46
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