承接 selfphp/secrets-detector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

selfphp/secrets-detector

最新稳定版本:1.0.0

Composer 安装命令:

composer require selfphp/secrets-detector

包简介

Detect secrets like API keys, tokens or passwords in PHP projects (e.g. in .env, config, or PHP source). Ideal for CI/CD and pre-commit hooks.

README 文档

README

Detect hardcoded secrets like API keys, tokens or passwords in PHP projects – ideal for CI/CD pipelines, pre-commit hooks, or manual audits.

🚀 Features

  • 🔍 Scans .env, .ini, PHP source and config files for secrets
  • 📦 Composer integration (autoload & CLI)
  • 🧠 Framework-aware: supports Symfony (APP_SECRET), Laravel (JWT_SECRET), and others
  • ⚙️ Configurable scan paths via .secrets-detector.json
  • 📄 Output formats: JSON, Markdown
  • ✅ CI/CD-ready with exit codes for automated fail conditions

📦 Installation

As a dev dependency:

composer require --dev selfphp/secrets-detector

Or install globally:

composer global require selfphp/secrets-detector

🔧 Usage

php bin/secrets-detector secrets:scan

Options

Option Description
--json=report.json Export results to JSON
--markdown=report.md Export results to Markdown
--fail-on-detect Exit with non-zero code on finding secrets

Example

php bin/secrets-detector secrets:scan --json=report.json --markdown=report.md --fail-on-detect

🛠 Configuration

You can define custom include/exclude paths using a .secrets-detector.json file in your project root:

{
  "include": ["src", "config", ".env"],
  "exclude": ["vendor", "tests"]
}

🧪 Testing

Run all unit tests:

vendor/bin/phpunit --display-deprecations

✅ CI Integration

See ready-made CI examples in docs/ci:

  • github-actions.yml
  • gitlab-ci.yml
  • bitbucket-pipelines.yml

Each file shows how to run the CLI and fail builds if secrets are detected.

🧠 Patterns Detected

  • Stripe secrets: sk_live_, sk_test_
  • Bearer tokens: Authorization: Bearer ...
  • AWS credentials: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • Database logins: DB_PASSWORD, DB_USERNAME
  • JWT and app secrets: JWT_SECRET, APP_SECRET
  • Google API keys: AIza...
  • Private keys: -----BEGIN PRIVATE KEY-----

(See PatternRegistry for all patterns.)

📜 License

MIT

👤 Author

SELFPHP - Damir Enseleit
https://www.selfphp.de
@SELFPHP

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-08