Skip to content

Generate test credentials at run time - #20

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 test literals or false positives, each closed by hand. A guard test stops the next one reaching the repository.

What changed

  • laranail/package-tools floor raised to ^0.1.9, the first release shipping AssertsNoLiteralCredentials and TestCredentials.
  • 0 literals replaced: the suite holds no real credential.
  • 2 exemptions, both in tests/Feature/NamingConventionTest.php, both false positives on a name containing token:
    • 'licensing.token.issue' => 'laranail-license-kit.token.issue' -- a route name, not a credential.
    • 'licensing-token' => 'laranail-license-kit.token' -- a rate-limiter name, not a credential.
  • New guard tests/Architecture/NoLiteralCredentialsTest.php scans tests/ and database/factories/ (41 files, floor 37).
  • CHANGELOG [Unreleased] entry.

Verification

  • Scanner: 2 literals before, 0 after (both exempted).
  • Pest 306 passed; laranail-pint passed; PHPStan no errors; Rector dry-run clean.
  • Red proof: appended $probe = ['secret' => 'abcd1234']; to tests/ArchTest.php, the guard failed naming that line, then restored the file with git checkout.

Follow-up: package-tools 0.1.10

This commit raises the laranail/package-tools floor to ^0.1.10 and adds a second test to NoLiteralCredentialsTest, assertCredentialPurposesAreWordsIn(), which fails the suite on any generated-credential purpose that is not a single plain lowercase word. Renamed 0 purposes (none were compound). Markers removed: 0 -- the two in NamingConventionTest.php (lines 33 and 39) are no longer needed by 0.1.10, but each trails its literal on the same line, and editing that line would put the literal into this diff, so they stay.

Red proof: a scratch line calling TestCredentials::password() with a hyphenated purpose turned the new test red; the file was restored with git checkout HEAD, and nothing committed contains it. Local gates: Pest, laranail-pint, PHPStan and Rector all pass.

GitGuardian raised 28 incidents across laranail, nearly all of them
literal credentials in tests. This suite holds none, but two route and
rate-limiter names read as tokens to the scanner, so they are marked as
deliberate, and a guard test now fails the suite on any literal added
later. Raises the laranail/package-tools floor to ^0.1.9, the first
release that ships the guard.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 11:51

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.

Secret scanning reads a compound purpose passed to TestCredentials, such
as a hyphenated one, as the password itself, so a generated credential
can be reported as a leaked one. A single plain lowercase word never has
been. Rename every purpose to one word, and switch on
assertCredentialPurposesAreWordsIn() so a new compound purpose fails the
suite instead of reaching a pull request.

package-tools 0.1.10 ships that check and a scanner that no longer
reports some lines earlier releases did, so the floor rises to ^0.1.10
and exemption markers the scanner no longer needs are removed.
@imanimanyara
imanimanyara merged commit 33f9ae6 into main Oct 19, 2026
15 checks passed
@imanimanyara
imanimanyara deleted the chore/generated-test-credentials branch October 19, 2026 14:48
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