承接 iamariezflores/php-sec-check 相关项目开发

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

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

iamariezflores/php-sec-check

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.

Packagist Version Packagist Downloads PHP Version License: MIT PHPUnit

Overview

php-sec-check is a Composer dev tool that audits your PHP or Laravel project for security misconfigurations and vulnerabilities in seconds. Run it from the command line — no setup required.

The package has no runtime dependencies. PHPUnit is included as a dev dependency for running the test suite during development and contributions.

vendor/bin/sec-check

Features

Generic PHP Checks

These run on any PHP project:

Check Description
PHP Version Warns if your PHP version is below 8.0
Display Errors Detects if display_errors is enabled (exposes stack traces in production)
Composer Audit Runs composer audit to surface known CVEs in your dependencies
Dangerous Functions Checks if high-risk functions are unrestricted in php.ini

Dangerous functions checked: exec, shell_exec, system, passthru, eval, create_function, proc_open, popen, curl_exec, curl_multi_exec, parse_ini_file, show_source

Laravel-Specific Checks

Auto-detected when artisan and bootstrap/app.php are present:

Check Description
APP_DEBUG Check Warns if APP_DEBUG=true, critical if combined with APP_ENV=production
Default Credentials Warns if DB_USERNAME uses a default value (root, admin, etc.) or DB_PASSWORD is empty
.env Credentials Scans for exposed sensitive keys (e.g. APP_KEY, DB_PASSWORD)
Vendor in Git Warns if vendor/ is not excluded in .gitignore

Requirements

  • PHP >= 8.2
  • Composer

Installation

Install as a dev dependency via Composer:

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

Available on Packagist: iamariezflores/php-sec-check

Usage

From your project root, run:

vendor/bin/sec-check

The tool exits with code 0 when no issues are found, and code 1 when any issue is detected. This makes it compatible with any CI/CD pipeline out of the box.

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
[WARN] Dangerous function enabled: curl_exec

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

Scan complete.

CI/CD Integration

Because sec-check exits with code 1 on any finding, you can drop it directly into your pipeline and it will fail the build automatically when issues are detected.

GitHub Actions:

name: Security Check

on: [push, pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: composer install --no-interaction

      - name: Run security check
        run: vendor/bin/sec-check

GitLab CI:

security-check:
  stage: test
  script:
    - composer install --no-interaction
    - vendor/bin/sec-check

Makefile / Shell script:

composer install --no-interaction
vendor/bin/sec-check || exit 1

Configuration

On first run, php-sec-check automatically creates a php-sec-check-config.php file at your project root. Edit this file to add your own sensitive .env key names:

<?php

return [
    'sensitive_keys' => [
        'APP_KEY',
        'DB_PASSWORD',
        'MAIL_PASSWORD',
        'AWS_SECRET_ACCESS_KEY',
        'STRIPE_SECRET_KEY',
        'CUSTOM_SECRET',
    ],
];

Advanced Usage

Programmatic Usage (Laravel)

You can invoke individual checks directly in your code. This is useful for building custom security dashboards or audit routes:

use Aquilinoflores\PhpSecCheck\Checks\Laravel\EnvCredentialsCheck;

Route::get('/security-audit', function () {
    $customKeys = ['CUSTOM_SECRET', 'ANOTHER_KEY'];
    $check = new EnvCredentialsCheck($customKeys);
    $results = $check->run(base_path());

    return response()->json($results);
});

Adding Custom Checks

All checks implement the CheckInterface contract:

interface CheckInterface {
    public function run(string $projectRoot): array;
}

To add a new check, create a class in src/Checks/ that implements CheckInterface, then register it in bin/sec-check.

Running Tests

The test suite uses PHPUnit and covers all PHP and Laravel checks:

composer test

Tests live in tests/Checks/ and tests/Checks/Laravel/, mirroring the src/ structure.

Contributing

Contributions are welcome and encouraged!

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-check-name
  3. Implement your check in src/Checks/, following the CheckInterface contract
  4. Write tests for your check in the corresponding tests/Checks/ directory — PRs without tests will not be merged
  5. Verify the full suite passes: composer test
  6. Commit your changes: git commit -m "feat: add your-check-name check"
  7. Push to your fork and open a Pull Request

Guidelines:

  • Keep checks modular and focused on a single security concern
  • Every new check class must have a corresponding *Test.php file
  • Every bug fix must include a regression test that would have caught the bug
  • Tests must pass before a PR will be reviewed

License

This project is open-source software licensed under the MIT License.

iamariezflores/php-sec-check 适用场景与选型建议

iamariezflores/php-sec-check 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 iamariezflores/php-sec-check 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 iamariezflores/php-sec-check 我们能提供哪些服务?
定制开发 / 二次开发

基于 iamariezflores/php-sec-check 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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