PHP code example of psalm / plugin-laravel

1. Go to this page and download the library: Download psalm/plugin-laravel 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/ */

    

psalm / plugin-laravel example snippets


// psalm-laravel catches this:
Route::get('/search', function (Request $request) {
    $sortByColumn = $request->input('sort'); // Tainted source: user input from HTTP request
    User::where('name', $request->input('name'))
        ->orderBy($sortByColumn) // 🚨 Tainted sink: unvalidated user input used in query builder
        ->get();

// Psalm output:
// ERROR TaintedSql: Detected tainted SQL
});

// UserController.php
$user->siteSettings['articles_sort'] = $request->input('sort'); // Tainted source: user input from HTTP request
$user->save();

// ArticlesConstoller.php
Articles::query()
    ->orderBy($user->siteSettings['articles_sort']) // 🚨 Tainted sink: unvalidated user input used in query builder
    ->get();

// Psalm output:
// ERROR TaintedSql: Detected tainted SQL