A PHP tool to lint PHP files for security issues based on CIS and OWASP best practices.
- Overview
- Features
- Requirements
- Installation
- Usage
- FAQ
- Support
- Changelog
- ToDo
- Contributing
- Code of Conduct
- DCO
- Contributors
- Notice
- License
PHP Security Linter is a static analysis tool designed to identify security vulnerabilities in PHP code by enforcing CIS benchmarks and OWASP Top 10 standards. Built for developers and security teams, this linter scans codebases without execution(SAST) to detect risks like SQL injection, XSS, misconfigurations, and sensitive data exposure before they reach production.
- 35 built-in security rules (16 CIS and 19 OWASP):
- Injection flaws (SQLi, Command, LDAP)
- Cryptographic weaknesses
- XSS and SSRF vulnerabilities
- Security misconfigurations
- Sensitive data exposure
- API security risks
- Cloud misconfigurations
- Multi-Standard support:
- CIS PHP Benchmark v3.0
- OWASP Top 10 2021
- Custom rule sets
- Fast static analysis without executing code
- Console output with file-level findings and scan summary
- Configurable ruleset
- DevSecOps ready CI/CD pipeline integration
- Exclusion support for ignoring specific paths
- Supported PHP: 8.2 and newer
- Supported platforms: Windows, GNU/Linux, MacOS
- PHP 8.2 or newer
- Composer 2 or newer
The current main branch (dev-main) and 3.x releases require PHP 8.2 or newer.
| Package version | Branch name | PHP version | Status |
|---|---|---|---|
| dev-main | main |
8.2+ | Active |
| 3.* | main |
8.2+ | Active |
| dev-main-php7.4 | main-php7.4 |
7.4 | Maintenance |
| 2.* | main-php7.4 |
7.4 | Maintenance |
| 1.* | 5.6 | EOL |
- Active: Full support
- Maintenance: Critical and security fixes only
- EOL: Unsupported
The PHP 7.4 and PHP 5.6 entries refer only to older release lines; they are not supported by the current main branch or 3.x releases.
- Component diagram:
- Dataflow diagram:
Via Composer per project:
composer require --dev yousha/php-security-linterOr via Composer globally:
composer global require yousha/php-security-linterLint current directory:
php vendor/bin/php-sl --path=.Or (Windows):
vendor\bin\php-sl.bat --path=.Lint a directory:
php vendor/bin/php-sl --path=./srcLint with path exclusion:
php vendor/bin/php-sl --path=./app --exclude=storage,testsExcluding a specific directory, path exclusion, and rule exclusion:
php bin/php-sl.php --path=./src --exclude=storage --exclude-rules=CIS-003,OWASP-001| Option | Description |
|---|---|
-p, --path |
Path to scan (required) |
--exclude |
Comma-separated paths to exclude |
--exclude-rules |
Comma-separated rule IDs to ignore |
--list-rules |
List available rule IDs |
--help |
Show help message |
Scan Results
========================================
File: /src/auth.php
✗ [CRITICAL] OWASP: SQL Injection vulnerability detected (Line 42)
✗ [HIGH] CIS: Hardcoded database credentials (Line 15)
File: /src/utils.php
✗ [MEDIUM] OWASP: XSS vulnerability possible (Line 88)
Summary: Scanned 24 files, found 3 potential issues.Run tests to ensure everything works as expected:
composer testOr:
vendor/bin/phpunit tests/See FAQ.txt file.
For any question, issues and feature requests, open an issue..
See CHANGELOG.txt file.
See TODO.txt file.
Contributions are welcome! Please follow these steps:
- Fork repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed description of your changes.
For more details see CONTRIBUTING.txt.
See CODE_OF_CONDUCT.txt file.
See DCO.txt file.
See CONTRIBUTORS.txt file.
See NOTICE.txt file.
This open-source software is distributed under the GPL-3.0 license. See LICENSE file.


