Warden is a comprehensive Laravel security audit package that proactively monitors your dependencies and application configuration for security vulnerabilities. Built for enterprise-grade security scanning, Warden provides powerful features for modern Laravel applications.
- π Dependency Scanning: Composer and NPM vulnerability detection
- βοΈ Configuration Audits: Environment, storage permissions, and Laravel config
- π Code Analysis: PHP syntax validation and security checks
- π§ Custom Audit Rules: Organization-specific security policies
- β‘ Parallel Execution: Up to 5x faster audit performance
- ποΈ Intelligent Caching: Prevents redundant scans with configurable TTL
- π― Severity Filtering: Focus on critical issues only
- π Multiple Output Formats: JSON, GitHub Actions, GitLab CI, Jenkins
- π Rich Notifications: Slack, Discord, Email with formatted reports
- β° Automated Scheduling: Laravel scheduler integration
- π CI/CD Ready: Native support for all major platforms
Perfect for continuous security monitoring and DevOps pipelines.
- Installation
- Quick Start
- Configuration
- Security Audits
- Usage Examples
- Notifications
- Custom Audits
- Scheduling
- CI/CD Integration
- Advanced Features
To install Warden, use Composer:
composer require dgtlss/wardenPublish configuration:
php artisan vendor:publish --tag="warden-config"This creates config/warden.php with all available options.
php artisan warden:auditphp artisan warden:audit --npmphp artisan warden:audit --output=json --severity=highphp artisan warden:audit --silentAdd these to your .env file:
# Slack (recommended - rich formatting)
WARDEN_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
# Discord
WARDEN_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
# Microsoft Teams
WARDEN_TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/YOUR/WEBHOOK
# Email
WARDEN_EMAIL_RECIPIENTS=security@company.com,admin@company.com
WARDEN_EMAIL_FROM=security@company.com
WARDEN_EMAIL_FROM_NAME="Security Team"
# Legacy webhook (backward compatibility)
WARDEN_WEBHOOK_URL=https://your-webhook-url.comWARDEN_CACHE_ENABLED=true
WARDEN_CACHE_DURATION=3600 # Cache for 1 hour
WARDEN_PARALLEL_EXECUTION=true # Enable parallel auditsWARDEN_SCHEDULE_ENABLED=false
WARDEN_SCHEDULE_FREQUENCY=daily # hourly|daily|weekly|monthly
WARDEN_SCHEDULE_TIME=03:00
WARDEN_SCHEDULE_TIMEZONE=UTCWARDEN_SEVERITY_FILTER= # null|low|medium|high|critical
WARDEN_OUTPUT_JSON=false
WARDEN_OUTPUT_JUNIT=falseWarden performs comprehensive security analysis across multiple areas:
- Scans PHP dependencies for known vulnerabilities
- Uses official
composer auditcommand - Identifies abandoned packages with replacement suggestions
- Analyzes JavaScript dependencies (when
--npmflag used) - Detects vulnerable packages in
package.json - Validates
package-lock.jsonintegrity
- Verifies
.envfile presence and.gitignorestatus - Checks for missing critical environment variables
- Validates sensitive key configuration
- Audits Laravel storage directories (
storage/,bootstrap/cache/) - Ensures proper write permissions
- Identifies missing or misconfigured paths
- Debug mode status verification
- Session security settings
- CSRF protection validation
- General security misconfigurations
- Code syntax validation across your application
- Configurable directory exclusions
- Integration with existing audit workflow
# Standard audit
php artisan warden:audit
# Include NPM + severity filtering
php artisan warden:audit --npm --severity=medium
# Force cache refresh
php artisan warden:audit --force
# Ignore abandoned packages
php artisan warden:audit --ignore-abandoned# JSON for processing
php artisan warden:audit --output=json > security-report.json
# GitHub Actions annotations
php artisan warden:audit --output=github
# GitLab CI dependency scanning
php artisan warden:audit --output=gitlab > gl-dependency-scanning-report.json
# Jenkins format
php artisan warden:audit --output=jenkins# Combined options
php artisan warden:audit --npm --severity=high --output=json --silent
# PHP syntax check
php artisan warden:syntax
# Schedule management
php artisan warden:schedule --enable
php artisan warden:schedule --statusWarden supports multiple notification channels with rich formatting:
- Color-coded severity levels
- Organized finding blocks
- Clickable CVE links
- Professional formatting
WARDEN_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL- Rich embeds with color coding
- Grouped findings by source
- Custom branding
WARDEN_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK- Adaptive Cards with structured layouts
- Color-coded severity indicators
- Action buttons and rich formatting
WARDEN_TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/YOUR/WEBHOOK- Professional HTML templates with modern styling
- Severity-based color coding and summary statistics
- Grouped findings by source with detailed information
- Separate templates for vulnerabilities and abandoned packages
WARDEN_EMAIL_RECIPIENTS=security@company.com,admin@company.com
WARDEN_EMAIL_FROM=security@company.com
WARDEN_EMAIL_FROM_NAME="Security Team"Configure multiple channels simultaneously - Warden sends to all configured endpoints.
Create organization-specific security rules:
<?php
namespace App\Audits;
use Dgtlss\Warden\Contracts\CustomAudit;
class DatabasePasswordAudit implements CustomAudit
{
public function audit(): bool
{
$dbPassword = env('DB_PASSWORD', '');
return !in_array(strtolower($dbPassword), ['password', '123456', 'admin']);
}
public function getFindings(): array
{
return [
[
'package' => 'environment',
'title' => 'Weak Database Password',
'severity' => 'critical',
'description' => 'Database password is weak or commonly used',
'remediation' => 'Use a strong, unique password'
]
];
}
public function getName(): string
{
return 'Database Password Security';
}
public function getDescription(): string
{
return 'Checks for weak database passwords';
}
public function shouldRun(): bool
{
return !empty(env('DB_CONNECTION'));
}
}Add to config/warden.php:
'custom_audits' => [
\App\Audits\DatabasePasswordAudit::class,
\App\Audits\ApiKeySecurityAudit::class,
// Add more custom audits
],# Enable scheduling
php artisan warden:schedule --enable
# Check status
php artisan warden:schedule --status
# Disable scheduling
php artisan warden:schedule --disableWARDEN_SCHEDULE_ENABLED=true
WARDEN_SCHEDULE_FREQUENCY=daily
WARDEN_SCHEDULE_TIME=03:00Ensure Laravel's scheduler is running:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1name: Security Audit
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Install dependencies
run: composer install --no-progress --prefer-dist
- name: Security Audit
run: php artisan warden:audit --output=github --severity=highsecurity_audit:
stage: test
script:
- composer install --no-progress --prefer-dist
- php artisan warden:audit --output=gitlab --silent > gl-dependency-scanning-report.json
artifacts:
reports:
dependency_scanning: gl-dependency-scanning-report.json
expire_in: 1 week
allow_failure: falsepipeline {
agent any
stages {
stage('Security Audit') {
steps {
sh 'composer install --no-progress --prefer-dist'
sh 'php artisan warden:audit --output=jenkins --severity=high'
}
post {
always {
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: '.',
reportFiles: 'audit-report.json',
reportName: 'Security Audit Report'
])
}
}
}
}
}- Parallel Execution: Enabled by default for 5x speed improvement
- Intelligent Caching: Configurable cache duration prevents redundant API calls
- Severity Filtering: Focus resources on critical issues
Exit Codes:
0: No vulnerabilities found1: Vulnerabilities detected2: Audit process failures
Severity Levels:
critical: Immediate attention requiredhigh: Address as soon as possiblemedium: Should be reviewed and fixedlow: Minor security concerns
// config/warden.php
'audits' => [
'parallel_execution' => true,
'timeout' => 300,
'retry_attempts' => 3,
'severity_filter' => 'medium',
],
'cache' => [
'enabled' => true,
'duration' => 3600, // 1 hour
],
'sensitive_keys' => [
'DB_PASSWORD',
'STRIPE_SECRET',
'AWS_SECRET_ACCESS_KEY',
],- β Parallel audit execution for 5x faster performance
- β Complete notification suite (Slack, Discord, Teams, Enhanced Email)
- β Professional email templates with severity colors and statistics
- β Microsoft Teams integration with Adaptive Cards
- β CI/CD output formats (GitHub Actions, GitLab CI, Jenkins)
- β Automated scheduling via Laravel scheduler
- β Custom audit rules for organization-specific policies
- β Intelligent caching with force refresh capability
- β Severity filtering to focus on critical issues
- π Audit history tracking and trend analysis
- π Additional audit types (Docker, Git, API security)
- π Web dashboard for audit management
- π€ AI-powered vulnerability analysis and recommendations
Command not found:
php artisan config:clear
composer dump-autoloadComposer audit failures:
# Update Composer to latest version
composer self-updateThis package is open source and released under the MIT License.
We welcome contributions! Please see our CONTRIBUTING GUIDELINES for details on:
- π Bug reports
- β¨ Feature requests
- π§ Code contributions
- π Documentation improvements
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Releases: Version History & Changelogs
If you find Warden useful for your organization's security needs, please consider supporting its development.
Made with β€οΈ for the Laravel community