Skip to content

Guard the tests against literal credentials - #85

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, 27 of them test literals or false positives, each closed by hand. This guard keeps the next one out.

What changed

  • tests/Tools/Architecture/NoLiteralCredentialsTest.php runs package-tools' shared AssertsNoLiteralCredentials with two tests: no literal credential anywhere under tests/, and every TestCredentials purpose a single lowercase word.
  • laranail/package-tools in require-dev: ^0.1 → ^0.1.10. The test is a PHPUnit class under tests/Tools/, so the existing Tools suite and its autoload-dev namespace already run it.
  • CHANGELOG [Unreleased] → ### Changed entry.

No literal credentials were found on main, so no test values changed.

Scan size and floor

The scan inspects 91 PHP files under tests/; both assertions use minFiles: 82 (about 90%), so a wrong path fails instead of passing over nothing.

Red proof

With the commit in place, a scratch line holding a literal under a password key (generated at run time) turned the literal test red, and a scratch TestCredentials::password() call with a hyphenated purpose turned the purpose test red. Both were restored with git checkout HEAD -- <file>; nothing scratch is committed.

Local gates

  • Pest runner: 575 passed
  • laranail-pint --test: passed
  • PHPStan (--debug --memory-limit=2G): no errors
  • Rector (--dry-run --debug): no changes

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 now fails on any
literal credential under tests/, and on any TestCredentials purpose that
is not a single lowercase word, which scanners read as the password.

The guard is laranail/package-tools' shared AssertsNoLiteralCredentials,
so the floor rises to ^0.1.10, the first release with the purpose check.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 15:34

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 ac4f173 into main Oct 19, 2026
17 checks passed
@imanimanyara
imanimanyara deleted the chore/credential-guard branch October 19, 2026 16:30
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