iamariezflores/php-sec-check 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

iamariezflores/php-sec-check

最新稳定版本:v1.0.0.2

Composer 安装命令:

composer require iamariezflores/php-sec-check

包简介

PHP Security Check Tool

README 文档

README

A lightweight CLI tool to scan PHP and Laravel projects for common security risks.
Runs as vendor/bin/sec-check after installation via Composer.

✨ Features

  • Generic PHP Checks

    • PHP version check
    • Detect if display_errors is enabled
    • Dangerous function detection (exec, shell_exec, system, eval, etc.)
    • Composer dependency audit (composer audit)
  • 🚀 Laravel-Specific Checks

    • Auto-detects Laravel projects
    • Scans .env for sensitive credentials
    • Warns if vendor/ is committed to Git
  • ⚙️ Configurable

    • Creates a php-sec-check-config.php file on first run
    • Add your own sensitive keys for .env scanning
    • Example:
      <?php
      return [
          'sensitive_keys' => [
              'APP_KEY',
              'DB_PASSWORD',
              'MAIL_PASSWORD',
              'AWS_SECRET_ACCESS_KEY',
              'STRIPE_SECRET_KEY',
              'CUSTOM_SECRET',
          ],
      ];

📦 Installation

Require it via Composer (recommended for dev):

composer require iamariezflores/php-sec-check --dev

📖 Usage

Run the scanner

vendor/bin/sec-check

Example output

=== PHP Security Check Tool ===

[PHP VERSION]
[OK] PHP version is up-to-date.

[DISPLAY ERRORS]
[WARN] 'display_errors' is enabled. Disable in production.

[COMPOSER DEPENDENCIES]
[OK] No known vulnerabilities found in dependencies.

[DANGEROUS FUNCTIONS]
[WARN] Dangerous function enabled: exec
[WARN] Dangerous function enabled: shell_exec
...

Laravel project detected!
[WARNING] Sensitive key 'APP_KEY' found in .env!
[WARNING] vendor/ directory exists and is not ignored in .gitignore!
Scan complete.

🔧 Advanced Usage

Custom Keys via Config

After the first run, edit php-sec-check-config.php in your project root to add new sensitive keys.

Custom Keys via Code (Laravel)

You can also inject custom keys programmatically:

use Aquilinoflores\PhpSecCheck\Checks\Laravel\EnvCredentialsCheck;

Route::get('/test-security', function () {
    $customKeys = ['CUSTOM_SECRET', 'ANOTHER_KEY'];
    $envCheck = new EnvCredentialsCheck($customKeys);
    return json_encode($envCheck->run(base_path()));
});

🤝 Contributing

Contributions are welcome!

  1. Fork the repo
  2. Create your feature branch:
  3. Commit your changes.
  4. Push to the branch.
  5. Create a Pull request.
  6. Please ensure new checks follow the modular structure in src/Checks/.

统计信息

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

GitHub 信息

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

其他信息

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