Skip to main content

Production-grade Python CLI tool for auditing Laravel web applications for common security misconfigurations

Project description

๐Ÿ” Laravel Security Scanner

PyPI Version Python Version License: MIT

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

๐Ÿš€ Installation

Via PyPI (Recommended)

pip install laravel-security-scanner

Via Source

# 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)
laravel-sec-scanner https://your-laravel-app.com

# Or using Python directly
python main.py https://your-laravel-app.com

# Multiple targets
laravel-sec-scanner https://app1.com https://app2.com

# JSON report only
laravel-sec-scanner https://app.com --format json --output ./my-reports

# HTML report only
laravel-sec-scanner https://app.com --format html --output ./my-reports

# SARIF report for GitHub Security tab
laravel-sec-scanner https://app.com --format sarif --output ./my-reports

# Skip SSL verification (e.g. staging with self-signed cert)
laravel-sec-scanner https://staging.app.com --no-ssl-verify

# Set custom timeout
laravel-sec-scanner https://app.com --timeout 20

# Run specific checks only
laravel-sec-scanner 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 --checks to run specific checks only

๐Ÿงช Running Tests

# Install dev dependencies
pip install laravel-security-scanner[dev]

# Run tests
pytest tests/unit/ -v
pytest tests/ -v --tb=short   # all tests

Current Test Coverage: 51 tests passing โœ…

โž• Adding a New Check

  1. Create app/services/checks/my_check.py extending BaseCheck
  2. Implement async def run(self, target: ScanTarget) -> Finding
  3. 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: laravel-sec-scanner 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

laravel_security_scanner-1.1.1.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laravel_security_scanner-1.1.1-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file laravel_security_scanner-1.1.1.tar.gz.

File metadata

  • Download URL: laravel_security_scanner-1.1.1.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for laravel_security_scanner-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e5878f3216a38d40bba57cf75c6ae8f1e1884d022c25f98940d7bd708a6e4587
MD5 428ba3479252147081e606c44cb6243b
BLAKE2b-256 5a4f7f4a9a59ff5d919a0b6e60f545035ff29efa833589a9f06c68d8202cba1b

See more details on using hashes here.

File details

Details for the file laravel_security_scanner-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for laravel_security_scanner-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9484fe6cf4102d3742a47fbc2a7b11da382664b72334cc88f62be9cf917c50a2
MD5 f545d52874266e7f5ab301704c25f4df
BLAKE2b-256 b542bc47b10455fdb60a9711831b64806ac0fd4f70a08f8e70f94eb800ada5f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page