Skip to content

Commit 31e91bb

Browse files
authored
Fix another query simulation leading to query error (#550)
1 parent f95a90b commit 31e91bb

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

tests/rules/SyntaxErrorInQueryMethodRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,9 @@ public function testBug547(): void
309309
{
310310
$this->analyse([__DIR__ . '/data/bug-547.php'], []);
311311
}
312+
313+
public function testBug548(): void
314+
{
315+
$this->analyse([__DIR__ . '/data/bug-548.php'], []);
316+
}
312317
}

tests/rules/UnresolvableQueryMethodRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public function testBug536(): void
6969
$this->analyse([__DIR__ . '/data/bug-536.php'], []);
7070
}
7171

72+
public function testBug548(): void
73+
{
74+
$this->analyse([__DIR__ . '/data/bug-548.php'], []);
75+
}
76+
7277
public function testBug547(): void
7378
{
7479
$this->analyse([__DIR__ . '/data/bug-547.php'], []);

tests/rules/data/bug-548.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Bug548;
4+
5+
use PDO;
6+
7+
function taintEscapedAndInferencePlaceholder(PDO $pdo, string $s, int $start, int $max)
8+
{
9+
10+
$pdo->query('SELECT * FROM ' . X::escapeIdentifier($s) . ' LIMIT ' . $start . ',' . $max, PDO::FETCH_ASSOC);
11+
}
12+
13+
class X {
14+
/**
15+
* Escapes and adds backsticks around.
16+
*
17+
* @param string $name
18+
*
19+
* @return string
20+
*
21+
* @psalm-taint-escape sql
22+
*/
23+
public static function escapeIdentifier($name)
24+
{
25+
return '';
26+
}
27+
28+
}

0 commit comments

Comments
 (0)