Skip to content

Guard the tests against literal credentials - #19

Merged
imanimanyara merged 1 commit into
mainfrom
chore/credential-guard
Oct 19, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
chore/credential-guard

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

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.php adds two tests from laranail/package-tools' AssertsNoLiteralCredentials:
    • assertNoLiteralCredentialsIn([tests/], minFiles: 5), which fails on any literal credential in the tests;
    • assertCredentialPurposesAreWordsIn([tests/], minFiles: 5), which fails on any TestCredentials purpose that is not a single lowercase word.
  • laranail/package-tools goes from ^0.1 to ^0.1.10, the first release with the purpose check.
  • CHANGELOG: an [Unreleased] → ### Changed entry.

No literal credentials were found on main, so no test values changed. The repo has no database/factories or workbench/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.php holding a literal under a credential name (value generated at run time), and the literal test went red naming tests/TestCase.php and the named rule. I then appended a scratch TestCredentials::password() call with a hyphenated purpose, and the purpose test went red naming it. Each was restored with git checkout HEAD -- tests/TestCase.php, and both tests went green again.

Nothing scratch is committed.

Local gates

  • Pest: 22 passed (48 assertions).
  • php vendor/bin/laranail-pint --test: passed.
  • No PHPStan or Rector configured.

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.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 15:29

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.

@imanimanyara
imanimanyara merged commit 7927d6f into main Oct 19, 2026
8 checks passed
@imanimanyara
imanimanyara deleted the chore/credential-guard branch October 19, 2026 16:20
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