fahimtayebee/preflight
Composer 安装命令:
composer require fahimtayebee/preflight
包简介
A Laravel project audit and security checker package.
README 文档
README
A Laravel project audit and security checker for catching common risks before deployment.
Public Preview: Preflight is currently in public preview. It uses static/project scanning and may produce false positives.
Why Preflight Exists
Laravel projects often repeat risky mistakes before production deployment: unprotected routes, weak environment settings, unsafe controller patterns, sensitive migration fields, risky Composer packages, and missing request authorization.
Preflight scans an existing Laravel application and reports findings in the terminal, JSON, Markdown, or SARIF. It is scanner/report only: no dashboard UI, no database tables, and no host application modifications.
Installation
composer require fahimtayebee/preflight --dev
Publish the config:
php artisan vendor:publish --tag=preflight-config
Quick Start
php artisan preflight:audit
Example Commands
php artisan preflight:audit php artisan preflight:audit --format=json php artisan preflight:audit --format=md --output=storage/app/preflight-report.md php artisan preflight:audit --format=sarif --output=storage/app/preflight.sarif php artisan preflight:audit --baseline php artisan preflight:audit --use-baseline php artisan preflight:audit --fail-under=80 php artisan preflight:audit --fail-on-severity=critical php artisan preflight:audit --explain php artisan preflight:audit --preset=relaxed php artisan preflight:audit --preset=strict --fail-on-severity=high
Commands
| Command | Purpose |
|---|---|
php artisan preflight:audit |
Run the audit and generate a report. |
php artisan preflight:baseline |
Show, generate, prune, or clear the baseline. |
php artisan preflight:report |
Open or generate a local HTML report. |
php artisan preflight:rules |
List known rules and configured severities. |
php artisan preflight:config-check |
Validate Preflight configuration. |
php artisan preflight:doctor |
Check whether Preflight is ready in the host project. |
php artisan preflight:self-test |
Run Preflight internal health checks. |
See docs/commands.md for all command options.
Report Formats
Preflight supports:
consolejsonmdsarifhtml
SARIF output can be uploaded to GitHub Code Scanning:
php artisan preflight:audit --format=sarif --output=storage/app/preflight.sarif
HTML Reports
HTML reports are static, shareable audit reports for local review, clients, and CI artifacts. They are standalone files with inline CSS and no external assets.
php artisan preflight:audit --format=html --output=storage/app/preflight-report.html php artisan preflight:audit --format=html --output=storage/app/preflight-report.html --explain
If --format=html is used without --output, Preflight saves to the configured default path: storage/app/preflight-report.html.
Local Report Viewer
Open static HTML reports locally:
php artisan preflight:report php artisan preflight:report --generate php artisan preflight:report --generate --explain php artisan preflight:report --latest php artisan preflight:report --file=storage/app/preflight-report.html
The report viewer opens local HTML files. It does not create a persistent dashboard, require authentication, or use a database.
Optional Report UI
Preflight can also register a small read-only Laravel route UI for viewing generated HTML reports in a browser. It is disabled by default and recommended for local or protected development environments only.
'ui' => [ 'enabled' => true, 'path' => 'preflight', 'middleware' => ['web', 'auth'], 'allowed_environments' => ['local', 'testing'], ],
When enabled, visit /preflight to list reports or /preflight/latest to view the newest report. The UI does not run audits from the browser, does not use a database, and does not store history. Reports may include file paths, route names, and security findings, so do not expose it publicly without authentication and environment restrictions.
See docs/ui.md for setup and security guidance.
Explainability And Presets
Use --explain when reviewing findings locally:
php artisan preflight:audit --explain
Expanded output includes why the finding matters, how to fix it, bad and better examples when available, false-positive guidance, and a rule docs URL.
Use presets to adjust runtime reporting without changing config:
php artisan preflight:audit --preset=relaxed php artisan preflight:audit --preset=strict --fail-on-severity=high
relaxedhides low-confidence findings for first adoption runs.defaultpreserves normal behavior.strictincludes all enabled rules and low-confidence findings for mature CI.
Reports include confidence_counts so teams can see how many findings are high, medium, or low confidence.
Changed Files Mode
Changed files mode is useful for pull requests. It uses Git diff output to scan changed files with file-based scanners, while still allowing project-wide checks such as env, routes, and auth.
php artisan preflight:audit --changed --base-ref=origin/main
The default base ref and fallback behavior are configurable. See Changed files mode.
False-Positive Guidance
Preflight reports include confidence levels and, with --explain, rule-specific guidance for handling false positives. Prefer tuning scanner options or using a reviewed baseline before disabling broad rule groups.
Examples:
php artisan preflight:audit --explain php artisan preflight:audit --preset=relaxed
See False positives and Explainability.
Tested Against
Preflight is tested using fixture projects and real Laravel project structures, including:
- Fresh Laravel-style project structure
- Laravel API-style project structure
- Laravel admin-panel style project structure
- Risky project fixtures with known findings
- Clean project fixtures with expected passing results
These tests improve rule reliability, but they do not claim complete security coverage.
Scanners
EnvScannerRouteScannerControllerScannerModelScannerMigrationScannerRequestScannerComposerScannerPolicyScannerBladeScannerAuthScanner
BLADE_UNGUARDED_ADMIN_ACTION is disabled by default because Blade authorization hints are heuristic and may be noisy.
CI Usage
Use score-based gating:
php artisan preflight:audit --format=json --output=storage/app/preflight-report.json --fail-under=80
Use severity-based gating:
php artisan preflight:audit --fail-on-severity=critical
Generate SARIF for GitHub Code Scanning:
php artisan preflight:audit --format=sarif --output=storage/app/preflight.sarif --fail-on-severity=critical
An example GitHub Code Scanning workflow is included at .github/workflows/preflight.yml.example.
Baseline Management
Baselines help teams adopt Preflight on existing projects without failing CI on every reviewed historical finding.
Generate a baseline:
php artisan preflight:baseline generate php artisan preflight:audit --baseline
Show the current baseline:
php artisan preflight:baseline show
Remove entries for issues that have been fixed:
php artisan preflight:baseline prune
Clear the baseline:
php artisan preflight:baseline clear --force
Run while ignoring baseline findings:
php artisan preflight:audit --use-baseline
Recommended first-time flow:
php artisan preflight:audit php artisan preflight:baseline generate php artisan preflight:audit --use-baseline --fail-on-severity=critical
CI can enforce that no new unbaselined issues were introduced:
php artisan preflight:baseline show --fail-on-new
Review baseline changes before committing them.
Rule Configuration
Rules can be disabled or have their severity changed in config/preflight.php:
'rules' => [ 'ROUTE_NO_MIDDLEWARE' => [ 'enabled' => false, ], 'REQUEST_AUTHORIZE_ALWAYS_TRUE' => [ 'enabled' => true, 'severity' => 'medium', ], ],
Disabled rules are removed before reporting, scoring, baselines, SARIF, and CI gates. Severity overrides affect reports, score calculation, --fail-on-severity, and SARIF levels.
Scanner Options
Scanner behavior can be tuned without disabling entire rules:
'scanners' => [ 'routes' => [ 'enabled' => true, 'options' => [ 'auth_middleware_keywords' => ['auth', 'auth:sanctum', 'tenant-auth'], ], ], ],
Documentation
- Configuration
- CI
- Commands
- Changed files
- Examples
- Explainability
- Fix examples
- False positives
- Limitations
- Rules
- Release checklist
Limitations
Preflight is honest about what it is and is not:
- It does not replace a professional security review.
- It may produce false positives.
- It does not guarantee a project is secure.
- It does not perform dependency vulnerability database scanning.
- It does not execute application code or perform runtime testing.
- It uses static and convention-based checks, so confidence and false-positive guidance should be reviewed alongside severity.
Roadmap
- More scanner accuracy improvements.
- More framework-specific checks.
- Stable v1.0 rule API.
Contributing
Contributions are welcome. See CONTRIBUTING.md.
Before submitting a pull request, run:
composer validate --strict vendor/bin/phpunit
Security
Please report security concerns privately. See SECURITY.md.
License
Preflight is open-sourced software licensed under the MIT license.
fahimtayebee/preflight 适用场景与选型建议
fahimtayebee/preflight 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「ci」 「routes」 「Audit」 「laravel」 「scanner」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fahimtayebee/preflight 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fahimtayebee/preflight 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fahimtayebee/preflight 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Block routes by IP
Log adding/updating/deleting of elements
Doctrine ORM provider for the auditor audit-log library.
Provides caching methods which can be easily used for caching routes.
Provide a way to secure accesses to all routes of an symfony application.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 41
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-08