PHP code example of laramint / php-security-scanner
1. Go to this page and download the library: Download laramint/php-security-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/ */
laramint / php-security-scanner example snippets
// @php-security-ignore
echo $userHtml; // this line is suppressed
echo $safe; // @php-security-ignore // end-of-line form, same effect
// @php-security-ignore-start
echo $a; // suppressed
echo $b; // suppressed
// @php-security-ignore-end
echo $c; // NOT suppressed
// @php-security-ignore-start xss.echo
echo $a; // XSS suppressed; SQL rules still active
// @php-security-ignore-end
// @php-security-ignore xss.echo // rule-scoped single-line
echo $d;
use LaraMint\PhpSecurityScanner\Extension\Extension;
use LaraMint\PhpSecurityScanner\Rules\RuleRegistry;
use LaraMint\PhpSecurityScanner\Taint\{SourceRegistry, SinkRegistry, SanitizerRegistry};
final class MyExtension implements Extension
{
public function name(): string { return 'my-framework'; }
public function register(
RuleRegistry $rules,
SourceRegistry $sources,
SinkRegistry $sinks,
SanitizerRegistry $sanitizers,
): void {
$sources->addMethod('App\\Http\\MyRequest', ['raw', 'all']);
$sanitizers->addFunction('my_escape', ['html']);
$rules->register(new MyCustomRule());
}
}