Repository navigation
Guard the tests against literal credentials - #23
Merged
Merged
Conversation
Secret scanners cannot tell a test password from a leaked one, and report both. GitGuardian raised 28 incidents across laranail by 2026-10-18, 27 of them test literals or false positives, each closed by hand. This guard keeps the next one out: the suite fails on any literal credential in the tests, and on any TestCredentials purpose that is not a single plain word, which scanners read as the password itself. Uses the shared AssertsNoLiteralCredentials trait, so package-tools' floor rises to ^0.1.10, the first release with the purpose check.
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.
Why
Secret scanners cannot tell a test password from a leaked one, and report both. GitGuardian raised 28 incidents across laranail by 2026-10-18, 27 of them test literals or false positives, each closed by hand. This guard keeps the next one out.
What changed
tests/Arch/NoLiteralCredentialsTest.php(new) runs package-tools'AssertsNoLiteralCredentialswith two tests:assertNoLiteralCredentialsInfails on any literal credential (named, strong or URL userinfo).assertCredentialPurposesAreWordsInfails on anyTestCredentialspurpose that is not a single lowercase word, since scanners read a compound one as the password itself.laranail/package-toolsfloor raised to^0.1.10, the first release with the purpose check.[Unreleased]→### Changedentry.Scope and floor
Scans
tests/: 11 PHP files, floorminFiles: 10(about 90%), so a wrong path fails instead of passing an empty scan. No literal credentials were found onmain, so no test values changed. The file sits intests/Arch, which theArchitecturejob instatic-analysis.ymlruns (pest --ci tests/Arch); thephpunit.xmlsuites cover onlytests/Unitandtests/Feature.Red proof
With the change committed, each test was shown to fail and then restored with
git checkout HEAD -- <file>(nothing scratch committed):TestCredentials::password()call with a hyphenated purpose → the purpose test failed, the literal test passed.Local gates
phpunit.xmlsuites);pest tests/Arch12 passedlaranail-pint --test: passed--debug --memory-limit=2G): no errors--dry-run --debug): no changes