Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mixed Content Scanner Cli Laravel Package

spatie/mixed-content-scanner-cli

CLI tool to detect mixed content on HTTPS sites. Crawls pages and reports HTML elements whose URLs use http:// (images, scripts, iframes, forms, etc.). Install via Composer globally and run: mixed-content-scanner scan .

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Purpose Alignment: The package is a standalone CLI tool (not a Laravel package) designed to scan websites for mixed content (HTTP resources loaded over HTTPS, violating security best practices). It is not a Laravel dependency but can be integrated into Laravel-based workflows via:
    • Artisan commands (custom wrapper).
    • CI/CD pipelines (GitHub Actions, GitLab CI, etc.).
    • Scheduled cron jobs (for periodic scans).
  • Use Case Fit: Ideal for security audits, pre-deployment checks, or automated compliance validation in Laravel applications where HTTPS is enforced but mixed content may slip through (e.g., hardcoded URLs, third-party scripts, or legacy assets).
  • Non-Functional Fit:
    • Lightweight: No database or heavy dependencies; runs as a one-off scan.
    • Output-Oriented: Generates actionable reports (CLI output, JSON, or HTML) rather than modifying code.

Integration Feasibility

  • Laravel Compatibility:
    • No Direct Laravel Integration: The package is PHP-based but not a Laravel service provider or facade. Requires manual invocation (e.g., via exec() or a custom Artisan command).
    • Dependency Conflict Risk: Low (only requires PHP CLI and Guzzle HTTP client). No Laravel framework dependencies.
  • Technical Debt:
    • Minimal: Integration would involve wrapping the CLI tool in a Laravel-friendly interface (e.g., a ScanMixedContent command).
    • Maintenance: Since the package is abandoned (last release 2022), long-term support may require forking or replacing it with alternatives (e.g., browserling/screenshot-api or custom scripts using Symfony Panther).

Technical Risk

  • Functional Risks:
    • False Positives/Negatives: Mixed content detection may miss edge cases (e.g., dynamically loaded resources via JavaScript). Validation should include manual spot-checks.
    • Performance: Scanning large sites (e.g., e-commerce with thousands of pages) could be slow. May require parallelization or sampling.
  • Operational Risks:
    • Dependency Rot: No updates since 2022. Risk of breaking changes if PHP/Guzzle dependencies evolve.
    • Rate Limiting: Aggressive scanning may trigger anti-bot measures (e.g., Cloudflare challenges). Mitigate with delays or proxies.
  • Security Risks:
    • Data Exposure: Scanning internal/staging environments may leak sensitive URLs. Restrict to production-like environments.
    • CLI Injection: If using exec(), sanitize inputs to prevent command injection.

Key Questions

  1. Scope of Scans:
    • Should scans cover all routes, or focus on critical paths (e.g., checkout, login)?
    • How to handle dynamic content (e.g., SPAs, API-driven pages)?
  2. Automation Strategy:
    • Should scans run on-demand (e.g., via Artisan) or scheduled (cron)?
    • Where to store results? (e.g., database table, S3, or Slack alerts?)
  3. False Positive Handling:
    • How to exclude known-safe mixed content (e.g., CDN assets with HTTP fallback)?
  4. Scalability:
    • For multi-tenant apps, how to isolate scans per tenant?
  5. Alternatives:
    • Evaluate if a custom solution (e.g., using Laravel’s Http client + regex) or commercial tools (e.g., Sqreen, Datadog) better fit needs.

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Artisan Command: Best for developer-driven scans (e.g., php artisan scan:mixed-content).
    • CI/CD Integration: Ideal for automated pre-deployment checks (e.g., GitHub Actions workflow).
    • Queue Jobs: For asynchronous scans of large sites (using Laravel Queues + exec).
  • Non-Laravel Dependencies:
    • PHP CLI: Required to run the scanner.
    • Guzzle HTTP Client: Handled internally by the package (no additional setup).
    • Optional: JSON/HTML output parsers (e.g., Symfony\Component\DomCrawler) for post-processing.

Migration Path

  1. Proof of Concept (PoC):
    • Install the package globally (composer global require spatie/mixed-content-scanner-cli).
    • Test manual scans: mixed-content-scanner scan https://example.com.
    • Validate output format (CLI, JSON, or HTML).
  2. Laravel Wrapper:
    • Create a custom Artisan command:
      // app/Console/Commands/ScanMixedContent.php
      class ScanMixedContent extends Command {
          protected $signature = 'scan:mixed-content {url?}';
          protected $description = 'Scan a URL for mixed content issues';
      
          public function handle() {
              $url = $this->argument('url') ?? config('app.url');
              $command = "mixed-content-scanner scan {$url}";
              $output = shell_exec($command);
              $this->info($output);
          }
      }
      
    • Register the command in app/Console/Kernel.php.
  3. Automation:
    • CI/CD: Add to deploy.php or GitHub Actions:
      - name: Scan for mixed content
        run: php artisan scan:mixed-content
      
    • Scheduled: Add to cron (e.g., daily):
      0 3 * * * cd /path/to/app && php artisan scan:mixed-content >> /var/log/mixed-content.log
      
  4. Result Processing:
    • Parse JSON output (if enabled) and store in a database table:
      // Example: Store findings in `mixed_content_issues` table
      $issues = json_decode($output, true);
      foreach ($issues['issues'] as $issue) {
          MixedContentIssue::create([
              'url' => $issue['url'],
              'mixed_url' => $issue['mixedUrl'],
              'severity' => $issue['severity'],
          ]);
      }
      

Compatibility

  • PHP Version: Requires PHP 7.4+ (check Laravel’s PHP version support).
  • Laravel Version: No direct dependency, but Laravel 8+ recommended for Artisan command features.
  • Environment:
    • Works on shared hosting (if PHP CLI is available).
    • May need Docker or local dev environments for CI/CD integration.

Sequencing

  1. Phase 1: Manual scans during development to identify mixed content.
  2. Phase 2: Integrate into CI/CD for pre-production validation.
  3. Phase 3: Schedule regular scans (e.g., weekly) with alerts for new issues.
  4. Phase 4: (Optional) Build a dashboard (e.g., using Laravel Nova or a custom admin panel) to track historical data.

Operational Impact

Maintenance

  • Package Updates:
    • No Active Maintenance: Monitor for PHP/Guzzle compatibility issues. Plan to fork or replace if critical bugs arise.
    • Dependency Management: Use composer why-not spatie/mixed-content-scanner-cli to track updates.
  • Custom Code:
    • Artisan command and result processors require documentation for onboarding.
    • Backup: Store scan results in a database with retention policies (e.g., 90 days).

Support

  • Troubleshooting:
    • Common Issues:
      • False positives (e.g., misclassified CDN URLs).
      • Timeouts for large sites (adjust --timeout flag).
      • Permission errors (ensure PHP CLI has access to the app directory).
    • Debugging: Log raw CLI output for diagnostics:
      file_put_contents(storage_path('logs/mixed-content-debug.log'), $output);
      
  • Escalation Path:
    • For critical false negatives, manual review of affected pages.
    • Consider commercial tools if support needs exceed open-source capabilities.

Scaling

  • Performance:
    • Single-URL Scans: Fast (<1s for most pages).
    • Multi-URL Scans: Use parallel processing (e.g., Laravel Queues + parallel-lint pattern):
      foreach ($urls as $url) {
          ScanMixedContentJob::dispatch($url)->delay(now()->addMinutes(1));
      }
      
    • Large Sites: Implement sampling (e.g., scan 10% of routes) or incremental scans (track changes since last scan).
  • Resource Usage:
    • Memory: Low (CLI tool is lightweight).
    • CPU: Moderate for concurrent scans. Monitor during load testing.

Failure Modes

| Failure Scenario | Impact | Mitigation |

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport