Added DB_FILTER

main
Robert 3 years ago
parent 7712955de7
commit 98f34ddd42
  1. 30
      UnitTestFiles/Test/SQL_Injection_Test.php
  2. 4
      src/mockup/inputs/app/home_in.php

@ -10,17 +10,25 @@ class SQL_Injection_Test extends TestCase {
/**
* @dataProvider dataProviderForTest
*/
public function testException($a) {
$this->expectException(\Exception::class);
\tts\safer_sql::get_safer_sql_text($a);
public function testDangerious($a) {
$ret = \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
*/
public function testSafeSQL($a) {
$this->expectNotToPerformAssertions();
\tts\safer_sql::get_safer_sql_text($a);
$ret = \tts\safer_sql::get_safer_sql_text($a);
$this->assertTrue($ret['status'] == \tts\SQL_SAFETY_FLAG::good);
}
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() {
return [
["John walks (down the road)."],
["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."]
];
}

@ -8,6 +8,7 @@ use \tts\safer_io as SafeIO;
use \tts\INPUTS;
use \tts\FIELD_FILTER;
use \tts\HTML_FLAG;
use \tts\DB_FILTER;
class home_in {
@ -18,8 +19,9 @@ class home_in {
'input' => INPUTS::post, // Others: post, json (REQUIRED param)
'field' => FIELD_FILTER::raw_string, // Others: raw, (DEFAULT: string), email, url, float, int
'html' => HTML_FLAG::purify, // Others: strip, encode, purify, (DEFAULT: escape)
'rule' => 'required|max: 75' // Others: email, valid_email_domain,
'rule' => 'required|max: 75', // Others: email, valid_email_domain,
// min, max, between, same, secure (password), alphanumeric
'db' => DB_FILTER::OFF // Should be used on Login Data only
],
'last_name' =>
[

Loading…
Cancel
Save