A value is pasted into a raw query fragment

tx0/php:raw-query-fragment-concatenationrecommendedwarningsecurity/injectiondepth fastsecurity, cwe-89

What it finds

A value is pasted into a raw query fragment

Example from the rule's tests
<?phpfunction search($query, $name, $limit, $order, $alias, $a, $b){    $query->whereRaw("name = '$name'");tx0 reports: this value is pasted into a raw query fragment    $query->whereRaw('name = ?', [$name]);    $query->orderByRaw('score * ' . (int) $limit);    $query->whereRaw("($order > ? OR ($order = ? AND id > ?))", [$a, $a, $b]);    $query->selectRaw("count(*) as $alias");    $query->whereRaw("$order > $name", [$a]);tx0 reports: this value is pasted into a raw query fragment    return DB::raw('price * ' . $limit);tx0 reports: this value is pasted into a raw query fragment}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:raw-query-fragment-concatenation" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/php:raw-query-fragment-concatenation] reason="..."

tx0 explain tx0/php:raw-query-fragment-concatenation shows the same in the terminal. Found a false positive? Report it.