Skip to content

Commit ef47503

Browse files
authored
Merge pull request #667 from AikidoSec/non-utf8
Add unit tests with non UTF-8 chars
2 parents bfae4b3 + 86037b8 commit ef47503

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

library/vulnerabilities/sql-injection/detectSQLInjection.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,40 @@ t.test("It does not match GROUP keyword", async () => {
265265
isNotSqlInjection(query, "ASC");
266266
});
267267

268+
t.test("It works with non-UTF-8 characters and emojis", async () => {
269+
isSqlInjection(
270+
"SELECT * FROM users WHERE id = 'a \udce9'\nOR 1=1 --'",
271+
"a \udce9'\nOR 1=1 --"
272+
);
273+
isSqlInjection(
274+
"SELECT * FROM users WHERE id = 'a \uD800'\nOR 1=1 --'",
275+
"a \uD800'\nOR 1=1 --"
276+
);
277+
isSqlInjection(
278+
"SELECT * FROM users WHERE id = 'a \uDFFF'\nOR 1=1 --'",
279+
"a \uDFFF'\nOR 1=1 --"
280+
);
281+
isSqlInjection(
282+
"SELECT * FROM users WHERE id = 'a \uDFFF\uDFFF'\nOR 1=1 --'",
283+
"a \uDFFF\uDFFF'\nOR 1=1 --"
284+
);
285+
isSqlInjection(
286+
"SELECT * FROM users WHERE id = 'a \uDFAB'\nOR 1=1 --'",
287+
"a \uDFAB'\nOR 1=1 --"
288+
);
289+
isSqlInjection(
290+
"SELECT * FROM users WHERE id = 'a 😀'\nOR 1=1 --'",
291+
"a 😀'\nOR 1=1 --"
292+
);
293+
isSqlInjection(
294+
"SELECT * FROM users WHERE id = 'a 🛡️'\nOR 1=1 --'",
295+
"a 🛡️'\nOR 1=1 --"
296+
);
297+
298+
isNotSqlInjection("SELECT * FROM users WHERE id = 'a \uD800'", "a \uD800");
299+
isNotSqlInjection("SELECT * FROM users WHERE id = 'a 🛡️'", "a 🛡️");
300+
});
301+
268302
const files = [
269303
// Taken from https://github.com/payloadbox/sql-injection-payload-list/tree/master
270304
join(__dirname, "payloads", "Auth_Bypass.txt"),

0 commit comments

Comments
 (0)