Skip to content

Generate test credentials at run time - #24

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

Secret scanning cannot tell a test password 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

  • laranail/package-tools floor raised from ^0.1.3 to ^0.1.9, the release that ships TestCredentials and AssertsNoLiteralCredentials (laranail rule 3).
  • 4 literals → 0, all replaced, no exemptions. The shared-secret token tests in AccessControlTest and ConfigContractTest take their tokens from TestCredentials::secret(). The wrong token gets its own purpose, and the test asserts it differs from the configured one.
  • New guard tests/Unit/Architecture/NoLiteralCredentialsTest.php (under tests/Unit because phpunit.xml only defines the Unit and Feature suites), scanning tests/, floor 15 of 17 files.
  • CHANGELOG [Unreleased] → Changed.

Verification

  • vendor/bin/pest: 76 passed, 1 skipped.
  • laranail-pint --test: pass. PHPStan (--debug --memory-limit=2G): no errors. Rector: the repository has no rector.php, on main as on this branch.
  • Red proof: a scratch 'token' => 'hunter2-…' line appended to AccessControlTest.php turned the guard red (AccessControlTest.php:107 (named) hu…); restored with git checkout.

Follow-up: package-tools 0.1.10

One more commit, Adopt package-tools 0.1.10's credential checks:

  • laranail/package-tools floor raised to ^0.1.10.
  • The guard test gains a second check, assertCredentialPurposesAreWordsIn(), over the same directories and file floor: every TestCredentials purpose must be a single plain lowercase word, since secret scanning reads a compound purpose as the password itself.
  • 0 purposes renamed: every purpose in the suite was already a single word.
  • No exemption markers were redundant.
  • Red proof: a scratch TestCredentials::password() call with a hyphenated purpose turned the new check red; the file was restored with git checkout and nothing of it is committed.
  • CHANGELOG: the existing [Unreleased] entry now names the new floor and the second check.

Secret scanning cannot tell a test password from a leaked one: GitGuardian
raised 28 incidents across laranail, 27 of them test literals closed by hand.
The access-token tests now take their tokens from package-tools'
TestCredentials, and a guard test fails on any literal left behind.

The package-tools floor rises to ^0.1.9, the release that ships the helpers,
so the prefer-lowest legs resolve them.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:39

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 such as TestCredentials::password('smtp-new')
as the password itself, so a generated credential can be reported as a leaked one.
package-tools 0.1.10 adds assertCredentialPurposesAreWordsIn(), which fails on any
purpose that is not a single plain lowercase word; the guard test now runs it beside
the literal check, over the same directories and file floor.

Raise the package-tools floor to ^0.1.10 for it. That release's scanner also
recognises Eloquent cast names, provider names and reference keys as non-credentials,
so exemption markers it no longer needs are removed. Each was checked by confirming
CredentialLiterals::in() reports nothing on the line the marker covered.
@imanimanyara
imanimanyara merged commit bb4787d into main Oct 19, 2026
5 checks passed
@imanimanyara
imanimanyara deleted the chore/generated-test-credentials branch October 19, 2026 14:52
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