Skip to content

feat: add --hide-secrets flag to redact connection credentials#63

Open
JoshSalway wants to merge 1 commit intolaravel:mainfrom
JoshSalway:fix/hide-secrets-credentials
Open

feat: add --hide-secrets flag to redact connection credentials#63
JoshSalway wants to merge 1 commit intolaravel:mainfrom
JoshSalway:fix/hide-secrets-credentials

Conversation

@JoshSalway
Copy link

Summary

  • Adds a --hide-secrets option to BaseCommand that all commands inherit
  • Extends outputJsonIfWanted() to recursively redact sensitive values when the flag is set
  • Redacts named credential fields (password, secret, api_key, access_key, secret_key, secretAccessKey, token, private_key, etc.) in any nested structure
  • Redacts environment variable key/value pairs where the key contains sensitive terms (e.g. DB_PASSWORD, APP_SECRET)
  • All redacted values are replaced with ********

This addresses the issue where cache:list, cache:get, database-cluster:get, bucket-key:get, and similar commands expose connection passwords and secrets in their JSON output. For example:

{"connection": {"hostname": "...", "password": "plaintext"}}

With --hide-secrets:

{"connection": {"hostname": "...", "password": "********"}}

Closes #60

Test plan

  • Added 20 unit tests covering field name detection, key name detection, recursive redaction, nested structures, edge cases
  • All 51 tests pass (vendor/bin/pest)
  • PHPStan passes with no errors (vendor/bin/phpstan analyse)

🤖 Generated with Claude Code

The existing outputJsonIfWanted() method now applies recursive secret
redaction when --hide-secrets is passed. This covers both environment
variable key/value pairs (where the key looks sensitive) and named
credential fields like password, secret, api_key, access_key,
secret_key, token, and private_key in any nested structure.

Closes laravel#60

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Bug: cache:list and bucket:list expose connection passwords in JSON output

1 participant