-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from AikidoSec/AIK-2521
Move tests to separate files
- Loading branch information
Showing
5 changed files
with
64 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
These files originate from [https://github.com/payloadbox/sql-injection-payload-list](https://github.com/payloadbox/sql-injection-payload-list). |
12 changes: 12 additions & 0 deletions
12
library/src/vulnerabilities/sql-injection/queryContainsUserInput.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as t from "tap"; | ||
import { queryContainsUserInput } from "./queryContainsUserInput"; | ||
|
||
t.test("it checks if query contains user input", async () => { | ||
t.same(queryContainsUserInput("SELECT * FROM 'Jonas';", "Jonas"), true); | ||
t.same(queryContainsUserInput("Hi I'm MJoNaSs", "jonas"), true); | ||
t.same( | ||
queryContainsUserInput("Hiya, 123^&*( is a real string", "123^&*("), | ||
true | ||
); | ||
t.same(queryContainsUserInput("Roses are red", "violet"), false); | ||
}); |
31 changes: 31 additions & 0 deletions
31
library/src/vulnerabilities/sql-injection/userInputOccurrencesSafelyEncapsulated.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as t from "tap"; | ||
import { userInputOccurrencesSafelyEncapsulated } from "./userInputOccurrencesSafelyEncapsulated"; | ||
|
||
t.test( | ||
"Test the userInputOccurrencesSafelyEncapsulated() function", | ||
async () => { | ||
t.same( | ||
userInputOccurrencesSafelyEncapsulated( | ||
` Hello Hello 'UNION'and also "UNION" `, | ||
"UNION" | ||
), | ||
true | ||
); | ||
t.same(userInputOccurrencesSafelyEncapsulated(`"UNION"`, "UNION"), true); | ||
t.same(userInputOccurrencesSafelyEncapsulated(` 'UNION' `, "UNION"), true); | ||
t.same( | ||
userInputOccurrencesSafelyEncapsulated(`"UNION"'UNION'`, "UNION"), | ||
true | ||
); | ||
|
||
t.same( | ||
userInputOccurrencesSafelyEncapsulated(`'UNION'"UNION"UNION`, "UNION"), | ||
false | ||
); | ||
t.same( | ||
userInputOccurrencesSafelyEncapsulated(`'UNION'UNION"UNION"`, "UNION"), | ||
false | ||
); | ||
t.same(userInputOccurrencesSafelyEncapsulated("UNION", "UNION"), false); | ||
} | ||
); |