|
|
|
@ -10,17 +10,25 @@ class SQL_Injection_Test extends TestCase { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @dataProvider dataProviderForTest |
|
|
|
* @dataProvider dataProviderForTest |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function testException($a) { |
|
|
|
public function testDangerious($a) { |
|
|
|
$this->expectException(\Exception::class); |
|
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a); |
|
|
|
\tts\safer_sql::get_safer_sql_text($a); |
|
|
|
$this->assertTrue($ret['status'] == \tts\SQL_SAFETY_FLAG::dangerious); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @dataProvider filterDataProviderForTest |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function testSQLFiltering($a, $b) { |
|
|
|
|
|
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a); |
|
|
|
|
|
|
|
$this->assertEquals($ret["text"], $b); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @dataProvider safeDataProviderForTest |
|
|
|
* @dataProvider safeDataProviderForTest |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function testSafeSQL($a) { |
|
|
|
public function testSafeSQL($a) { |
|
|
|
$this->expectNotToPerformAssertions(); |
|
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a); |
|
|
|
\tts\safer_sql::get_safer_sql_text($a); |
|
|
|
$this->assertTrue($ret['status'] == \tts\SQL_SAFETY_FLAG::good); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function dataProviderForTest() { |
|
|
|
public function dataProviderForTest() { |
|
|
|
@ -32,11 +40,21 @@ class SQL_Injection_Test extends TestCase { |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function filterDataProviderForTest() { |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
["/etc/password Hello", "etcpassword Hello"], |
|
|
|
|
|
|
|
["--; Bob", " Bob"], |
|
|
|
|
|
|
|
["&& Safe", " Safe"], |
|
|
|
|
|
|
|
["Hello /var/log/apache", "Hello varlogapache"] |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function safeDataProviderForTest() { |
|
|
|
public function safeDataProviderForTest() { |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
["John walks (down the road)."], |
|
|
|
["John walks (down the road)."], |
|
|
|
["Hey, Boy - Good Work!"], |
|
|
|
["Hey, Boy - Good Work!"], |
|
|
|
["I think; I'm good!"] |
|
|
|
["I think; I'm good!"], |
|
|
|
|
|
|
|
["Go dancing by the river or play ball and see it."] |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|