Production-grade Python CLI tool for auditing Laravel web applications for common security misconfigurations
Project description
๐ Laravel Security Scanner
Production-grade Python CLI tool for auditing Laravel web applications for common security misconfigurations.
๐ฏ What It Checks
| Check ID | Title | Severity |
|---|---|---|
ENV_EXPOSED |
.env file publicly accessible | ๐ด CRITICAL |
DEBUG_MODE |
Laravel debug mode enabled | ๐ด HIGH |
SENSITIVE_FILES |
Sensitive files/directories exposed | ๐ด HIGH |
SECURITY_HEADERS |
Missing HTTP security headers | ๐ MEDIUM |
INSECURE_CONFIG |
CORS, cookie flags, server headers | ๐ MEDIUM |
LARAVEL_VERSION |
Laravel version disclosure | ๐ MEDIUM |
TELESCOPE_EXPOSED |
Laravel Telescope exposed | ๐ด HIGH |
DEBUGBAR_EXPOSED |
Laravel Debugbar exposed | ๐ MEDIUM |
MIX_MANIFEST_EXPOSED |
Laravel Mix manifest exposed | ๐ข LOW |
HORIZON_EXPOSED |
Laravel Horizon exposed | ๐ MEDIUM |
NOVA_EXPOSED |
Laravel Nova exposed | ๐ด HIGH |
CSRF_PROTECTION |
CSRF protection missing | ๐ด HIGH |
SESSION_SECURITY |
Session security configuration | ๐ MEDIUM |
RATE_LIMITING |
Rate limiting missing | ๐ MEDIUM |
HTTP_METHODS |
Dangerous HTTP methods enabled | ๐ MEDIUM |
COMPOSER_CVE |
Composer.lock CVE scan | ๐ด CRITICAL |
๐ Project Structure
laravel-security-scanner/
โโโ app/
โ โโโ core/
โ โ โโโ settings.py # Pydantic settings + .env loader
โ โ โโโ logging.py # Loguru structured logging
โ โโโ models/
โ โ โโโ scan.py # ScanTarget, Finding, ScanResult models
โ โโโ services/
โ โ โโโ scanner.py # ScannerService โ async orchestrator
โ โ โโโ reporter.py # Console / JSON / TXT / HTML / SARIF report generator
โ โ โโโ rate_limiter.py # RateLimiter & RetryableClient
โ โ โโโ checks/
โ โ โโโ base.py # BaseCheck abstract class
โ โ โโโ __init__.py # Check registry (ALL_CHECKS)
โ โ โโโ env_exposed.py
โ โ โโโ debug_mode.py
โ โ โโโ security_headers.py
โ โ โโโ sensitive_files.py
โ โ โโโ insecure_config.py
โ โ โโโ laravel_version.py
โ โ โโโ telescope_exposed.py
โ โ โโโ debugbar_exposed.py
โ โ โโโ mix_manifest_exposed.py
โ โ โโโ horizon_exposed.py
โ โ โโโ nova_exposed.py
โ โ โโโ csrf_protection.py
โ โ โโโ session_security.py
โ โ โโโ rate_limiting.py
โ โ โโโ http_methods.py
โ โ โโโ composer_lock_cve.py
โ โโโ utils/
โ โโโ url.py # URL normalisation
โโโ tests/
โ โโโ unit/
โ โโโ test_models.py
โ โโโ test_url_utils.py
โ โโโ test_env_check.py
โ โโโ test_laravel_version.py
โ โโโ test_telescope_exposed.py
โ โโโ test_debugbar_exposed.py
โ โโโ test_mix_manifest_exposed.py
โ โโโ test_horizon_exposed.py
โ โโโ test_nova_exposed.py
โ โโโ test_csrf_protection.py
โ โโโ test_session_security.py
โ โโโ test_rate_limiting.py
โ โโโ test_http_methods.py
โ โโโ test_composer_lock_cve.py
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # GitHub Actions CI/CD
โโโ logs/
โโโ reports/
โโโ cve_database.json # CVE database for composer scan
โโโ .env.example
โโโ requirements.txt
โโโ pytest.ini
โโโ CHANGELOG.md
โโโ VERSION
โโโ main.py
๐ง Setup
# 1. Clone / download
git clone https://github.com/AlgoDev/Laravel-Security-Scanner.git
cd laravel-security-scanner
# 2. Create virtualenv
python3.11 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure
cp .env.example .env
# Edit .env as needed
๐ Usage
# Scan a single target (all formats)
python main.py https://your-laravel-app.com
# Multiple targets
python main.py https://app1.com https://app2.com
# JSON report only
python main.py https://app.com --format json --output ./my-reports
# HTML report only
python main.py https://app.com --format html --output ./my-reports
# SARIF report for GitHub Security tab
python main.py https://app.com --format sarif --output ./my-reports
# Skip SSL verification (e.g. staging with self-signed cert)
python main.py https://staging.app.com --no-ssl-verify
# Set custom timeout
python main.py https://app.com --timeout 20
# Run specific checks only
python main.py https://app.com --checks ENV_EXPOSED,DEBUG_MODE,COMPOSER_CVE
๐ฏ Features
- Multiple Output Formats: Console, JSON, TXT, HTML, and SARIF reports
- Progress Bar: Real-time progress tracking with rich library during scans
- CI/CD Integration: GitHub Actions workflow included (
.github/workflows/ci.yml) - Async Scanning: Concurrent checks for faster results
- Comprehensive Checks: 16 security checks covering critical Laravel vulnerabilities
- SARIF Support: SARIF format output for GitHub Security tab integration
- Rate Limiting: Built-in rate limiter to avoid overwhelming target servers
- Retry Mechanism: Automatic retry for failed requests with exponential backoff
- Connection Pooling: HTTP connection reuse for better performance
- Check Selection: Use
--checksto run specific checks only
๐งช Running Tests
pytest tests/unit/ -v
pytest tests/ -v --tb=short # all tests
Current Test Coverage: 51 tests passing โ
โ Adding a New Check
- Create
app/services/checks/my_check.pyextendingBaseCheck - Implement
async def run(self, target: ScanTarget) -> Finding - Register in
app/services/checks/__init__.py โ ALL_CHECKS
That's it โ the ScannerService picks it up automatically.
๐ค Exit Codes
| Code | Meaning |
|---|---|
0 |
All targets clean |
1 |
One or more vulnerabilities found |
Useful for CI/CD pipelines: python main.py https://app.com || echo "Security issues found!"
๐ Changelog
See CHANGELOG.md for detailed version history.
๐ Version
Current version: v1.1.0 (see VERSION file)
๐ฏ Total Security Checks: 16
๐ Output Formats: 5 (Console, JSON, TXT, HTML, SARIF)
๐งช Tests: 51 passing
๐ CI/CD: GitHub Actions ready
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file laravel_security_scanner-1.1.0.tar.gz.
File metadata
- Download URL: laravel_security_scanner-1.1.0.tar.gz
- Upload date:
- Size: 39.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ceba38df727cf7b474d0f3101c2e67018ae7e27a774082531afb9d9cde05cbf
|
|
| MD5 |
7e598f715001503e0cfd53cdf05bb19c
|
|
| BLAKE2b-256 |
d1a8bef0314f77bf8cd694835f8866692a95bd051735bae490e1e8ecf9833166
|
File details
Details for the file laravel_security_scanner-1.1.0-py3-none-any.whl.
File metadata
- Download URL: laravel_security_scanner-1.1.0-py3-none-any.whl
- Upload date:
- Size: 46.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2950aca35a01877cd7453969ae8a4332fd7aaea91aca2e99bc8bfded88745e1
|
|
| MD5 |
ff1a5c7f5d30ed7473f828ab385915a5
|
|
| BLAKE2b-256 |
944769123385abe0580d5c7e41825adc6985f36bac69dcecaadb21738b5c45ef
|