Skip to content

Commit adb4a87

Browse files
committed
Fix tests, add more keywords
1 parent 0d2db36 commit adb4a87

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

library/vulnerabilities/attack-wave-detection/containsSQLSyntax.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ function getTestContext(path: string, query: string): Context {
99
url: `http://localhost:4000${path}`,
1010
query: {
1111
test: query,
12+
utmSource: "newsletter",
13+
utmMedium: "electronicmail",
14+
utmCampaign: "test",
15+
utmTerm: "sql_injection",
1216
},
1317
headers: {
1418
"content-type": "application/json",
@@ -23,26 +27,18 @@ function getTestContext(path: string, query: string): Context {
2327

2428
t.test("it detects SQL injection patterns", async (t) => {
2529
const testStrings = [
26-
"2; DROP TABLE users",
27-
"1 OR 1=1",
28-
"' WHERE 1=1",
2930
"' or '1'='1",
30-
"2; DELETE FROM users",
3131
"1: SELECT * FROM users WHERE '1'='1'",
3232
"', information_schema.tables",
33-
"1 UNION SELECT username, password FROM users",
3433
"1' sleep(5)",
34+
"WAITFOR DELAY 1",
3535
];
3636

3737
for (const str of testStrings) {
3838
t.ok(
3939
containsSQLSyntax(getTestContext(`/test`, str)),
4040
`Expected ${str} to match SQL injection patterns`
4141
);
42-
t.ok(
43-
containsSQLSyntax(getTestContext(`/api/user/${str}`, "")),
44-
`Expected ${str} to match SQL injection patterns`
45-
);
4642
}
4743
});
4844

library/vulnerabilities/attack-wave-detection/containsSQLSyntax.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ const keywords = [
88
"WAITFOR DELAY",
99
"SELECT LIKE(CHAR(",
1010
"INFORMATION_SCHEMA.COLUMNS",
11+
"INFORMATION_SCHEMA.TABLES",
1112
",MD5(",
1213
"DBMS_PIPE.RECEIVE_MESSAGE",
1314
"SYSIBM.SYSTABLES",
1415
"RANDOMBLOB(",
16+
"SELECT * FROM",
17+
"1'='1",
18+
"PG_SLEEP(",
19+
"UNION ALL SELECT",
1520
];
1621

1722
export function containsSQLSyntax(context: Context): boolean {

library/vulnerabilities/attack-wave-detection/paths/fileNames.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,7 @@ export const fileNames = [
297297
"iis.log",
298298
"pom.xml",
299299
"openapi.json",
300+
"vim_settings.xml",
301+
"winscp.ini",
302+
"ws_ftp.ini",
300303
];

0 commit comments

Comments
 (0)