Skip to main content

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 --checks to 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

  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: 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

laravel_security_scanner-1.1.0.tar.gz (39.6 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.0-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

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

Hashes for laravel_security_scanner-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8ceba38df727cf7b474d0f3101c2e67018ae7e27a774082531afb9d9cde05cbf
MD5 7e598f715001503e0cfd53cdf05bb19c
BLAKE2b-256 d1a8bef0314f77bf8cd694835f8866692a95bd051735bae490e1e8ecf9833166

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for laravel_security_scanner-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2950aca35a01877cd7453969ae8a4332fd7aaea91aca2e99bc8bfded88745e1
MD5 ff1a5c7f5d30ed7473f828ab385915a5
BLAKE2b-256 944769123385abe0580d5c7e41825adc6985f36bac69dcecaadb21738b5c45ef

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