Skip to content

Commit 25931e8

Browse files
Merge pull request #509 from AikidoSec/zen-internals-0-1-36
Update Zen internals to v0.1.36
2 parents c2a1fa8 + c17d34a commit 25931e8

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

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

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import * as t from "tap";
33
import { readFileSync } from "fs";
44
import { escapeStringRegexp } from "../../helpers/escapeStringRegexp";
55
import { detectSQLInjection } from "./detectSQLInjection";
6+
import { SQLDialectClickHouse } from "./dialects/SQLDialectClickHouse";
7+
import { SQLDialectGeneric } from "./dialects/SQLDialectGeneric";
68
import { SQLDialectMySQL } from "./dialects/SQLDialectMySQL";
79
import { SQLDialectPostgres } from "./dialects/SQLDialectPostgres";
10+
import { SQLDialectSQLite } from "./dialects/SQLDialectSQLite";
811

912
t.test("It ignores invalid queries", async () => {
1013
isNotSqlInjection("SELECT * FROM users WHERE id = 'users\\'", "users\\");
@@ -96,7 +99,8 @@ t.test("User input is multiline", async () => {
9699
`SELECT * FROM users WHERE id = 'a'
97100
OR 1=1#'`,
98101
`a'
99-
OR 1=1#`
102+
OR 1=1#`,
103+
[new SQLDialectGeneric(), new SQLDialectMySQL()]
100104
);
101105

102106
isNotSqlInjection(
@@ -314,28 +318,46 @@ for (const file of files) {
314318
}
315319
}
316320

317-
function isSqlInjection(sql: string, input: string) {
318-
t.same(
319-
detectSQLInjection(sql, input, new SQLDialectMySQL()),
320-
true,
321-
`${sql} (mysql)`
322-
);
323-
t.same(
324-
detectSQLInjection(sql, input, new SQLDialectPostgres()),
325-
true,
326-
`${sql} (postgres)`
327-
);
321+
function isSqlInjection(
322+
sql: string,
323+
input: string,
324+
dialects = [
325+
new SQLDialectGeneric(),
326+
new SQLDialectMySQL(),
327+
new SQLDialectPostgres(),
328+
new SQLDialectSQLite(),
329+
new SQLDialectClickHouse(),
330+
]
331+
) {
332+
if (dialects.length === 0) {
333+
throw new Error("No dialects provided");
334+
}
335+
336+
for (const dialect of dialects) {
337+
t.same(
338+
detectSQLInjection(sql, input, dialect),
339+
true,
340+
`${sql} (${dialect.constructor.name})`
341+
);
342+
}
328343
}
329344

330-
function isNotSqlInjection(sql: string, input: string) {
331-
t.same(
332-
detectSQLInjection(sql, input, new SQLDialectMySQL()),
333-
false,
334-
`${sql} (mysql)`
335-
);
336-
t.same(
337-
detectSQLInjection(sql, input, new SQLDialectPostgres()),
338-
false,
339-
`${sql} (postgres)`
340-
);
345+
function isNotSqlInjection(
346+
sql: string,
347+
input: string,
348+
dialects = [
349+
new SQLDialectGeneric(),
350+
new SQLDialectMySQL(),
351+
new SQLDialectPostgres(),
352+
new SQLDialectSQLite(),
353+
new SQLDialectClickHouse(),
354+
]
355+
) {
356+
for (const dialect of dialects) {
357+
t.same(
358+
detectSQLInjection(sql, input, dialect),
359+
false,
360+
`${sql} (${dialect.constructor.name})`
361+
);
362+
}
341363
}

scripts/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const {
1111
const execAsync = promisify(exec);
1212

1313
// Zen Internals configuration
14-
const INTERNALS_VERSION = "v0.1.35";
14+
const INTERNALS_VERSION = "v0.1.36";
1515
const INTERNALS_URL = `https://github.com/AikidoSec/zen-internals/releases/download/${INTERNALS_VERSION}`;
1616
// ---
1717

0 commit comments

Comments
 (0)