PHP code example of laravelsecurityaudit / laravel-secret-scanner

1. Go to this page and download the library: Download laravelsecurityaudit/laravel-secret-scanner library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravelsecurityaudit / laravel-secret-scanner example snippets


use LaravelSecurityAudit\SecretScanner\Scanning\Scanner;
use LaravelSecurityAudit\SecretScanner\Scanning\Contracts\ScanContext;
use LaravelSecurityAudit\SecretScanner\Rules\Secrets\StripeKeyRule;

final class StringContext implements ScanContext
{
    public function __construct(private string $body) {}
    public function body(): string { return $this->body; }
    public function location(): string { return 'body'; }
}

$scanner = new Scanner([new StripeKeyRule]);
$findings = $scanner->scan(new StringContext('token sk_live_0123456789abcdef'));

$scanner->riskLevel($findings); // "critical"