Repository navigation
Guard the tests against literal credentials - #19
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, and 27 of them were test literals or false positives, each closed by hand. This adds package-tools' shared guard: one test fails on any literal credential left in the tests, and a second fails on any TestCredentials purpose that is not a single lowercase word, since scanners read a compound purpose as the password itself. It keeps the next incident out rather than closing it after the push. Requires laranail/package-tools ^0.1.10, the first release that ships both checks.
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, and 27 of them were test literals or false positives, each closed by hand. This guard keeps the next one out of this repository.
What changed
tests/Architecture/NoLiteralCredentialsTest.phpadds two tests fromlaranail/package-tools'AssertsNoLiteralCredentials:assertNoLiteralCredentialsIn([tests/], minFiles: 5), which fails on any literal credential in the tests;assertCredentialPurposesAreWordsIn([tests/], minFiles: 5), which fails on anyTestCredentialspurpose that is not a single lowercase word.laranail/package-toolsgoes from^0.1to^0.1.10, the first release with the purpose check.[Unreleased]→### Changedentry.No literal credentials were found on
main, so no test values changed. The repo has nodatabase/factoriesorworkbench/database/factories.Scan size
The scan inspects 6 PHP files under
tests/(including the guard itself). The floor is 5, about 90%, so a wrong path fails instead of passing over nothing.Red proof
After committing, I appended a scratch line to
tests/TestCase.phpholding a literal under a credential name (value generated at run time), and the literal test went red namingtests/TestCase.phpand thenamedrule. I then appended a scratchTestCredentials::password()call with a hyphenated purpose, and the purpose test went red naming it. Each was restored withgit checkout HEAD -- tests/TestCase.php, and both tests went green again.Nothing scratch is committed.
Local gates
php vendor/bin/laranail-pint --test: passed.