A PHP tool to lint PHP files for security issues based on CIS and OWASP best practices.
- Overview
- Features
- Requirements
- Installation
- Configuration
- 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.
- 200+ vuilt-in security rules:
- 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
- Multiple output formats (Console, JSON)
- Configurable ruleset with severity levels
- DevSecOps ready CI/CD pipeline integration
- Exclusion support for ignoring specific paths
- Supported PHP: 7.4, 8.3
- Supported platforms: Windows, GNU/Linux, MacOS
- PHP 7.4 or PHP 8.3
- Composer >= 2
Package version | Branch | PHP version | Status |
---|---|---|---|
dev-main | main |
8.3 | Active |
3.* | main |
8.3 | Active |
2.* | main-php7.4 |
7.4 | Maintenance |
1.* | 5.6 | EOL |
- Active: Full support
- Maintenance: Critical/Security fixes only
- EOL: Unsupported
- Component diagram:
- Dataflow diagram:
Via Composer:
composer require --dev yousha/php-security-linter
Or Composer global installation:
composer global require yousha/php-security-linter
Customize rules by creating a php-security-config.json
:
{
"excludeRules": ["CIS-001", "OWASP-003"],
"severityLevel": "medium",
"customRules": {
"CUSTOM-001": {
"pattern": "dangerous_function\\s*\\(",
"message": "Custom dangerous function detected",
"severity": "high"
}
}
}
Lint a directory:
php vendor/bin/php-security-linter --path ./src
Lint with exclusions:
php vendor/bin/php-security-linter --path ./app --exclude vendor,tests
JSON output:
php vendor/bin/php-security-linter --path ./public --format json
Option | Description |
---|---|
-p, --path |
Path to scan (required) |
--exclude |
Comma-separated paths to exclude |
--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 test
Or:
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.