Repository navigation
Generate test credentials at run time - #18
Merged
Merged
Conversation
GitGuardian raised 28 incidents across laranail, nearly all of them literal credentials in tests. The operator password, the wrong password, the redaction canary and the config secrets the redactor must hide are now generated per run with TestCredentials; the redaction tests still prove the value never reaches output. The TestCase::PASSWORD constant becomes TestCase::password(), since a constant cannot hold a generated value. A guard test in tests/Arch fails the suite on any literal left behind. Raises the laranail/package-tools floor to ^0.1.9, the first release with these helpers.
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.
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
GitGuardian raised 28 incidents across laranail by 2026-10-18; 27 were test literals or false positives, each closed by hand. A value generated at run time never reaches the repository, so there is nothing to report.
What changed
laranail/package-toolsfloor raised to^0.1.9, the first release shippingTestCredentialsandAssertsNoLiteralCredentials.TestCase::PASSWORD(a constant cannot hold a generated value) becomesTestCase::password(), returningTestCredentials::password('operator'); its one caller is updated;TestCredentials::password('wrong'), with a new assertion that it differs from the operator's;SecretRedactorTest,AuditTest,ExecuteTest,SecurityReviewTest) isTestCredentials::secret('canary'), hex so it survives the redactor'sNAME=valueand URL parsing; every "never reaches the output" assertion reads the same value;reportingDB password,services.acme.secret) are generated.tests/Arch/NoLiteralCredentialsTest.phpscanstests/(47 files, floor 42). It sits intests/Arch, whichphpunit.xmlalready runs.[Unreleased]entry.Verification
$probe = ['password' => 'nope-nope'];toDestructiveTest.php, the guard failed naming that line, then restored the file withgit checkout.Follow-up: package-tools 0.1.10
This commit raises the
laranail/package-toolsfloor to^0.1.10and adds a second test toNoLiteralCredentialsTest,assertCredentialPurposesAreWordsIn(), which fails the suite on any generated-credential purpose that is not a single plain lowercase word. Renamed 0 purposes (all were already single words). Markers removed: 0 (none present).Red proof: a scratch line calling
TestCredentials::password()with a hyphenated purpose turned the new test red; the file was restored withgit checkout HEAD, and nothing committed contains it. Local gates: Pest, laranail-pint, PHPStan and Rector all pass.