-
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.
feat: Only build payload paths on attack
+ Find multiple occurrences in same source
- Loading branch information
1 parent
7c3c217
commit b563640
Showing
27 changed files
with
317 additions
and
215 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
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
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,59 @@ | ||
import * as t from "tap"; | ||
import { getPathsToPayload as get } from "./attackPath"; | ||
|
||
t.test("it gets paths to payload", async (t) => { | ||
const testObj1 = { | ||
a: { | ||
b: { | ||
c: "payload", | ||
}, | ||
}, | ||
d: [12, "test", "payload"], | ||
}; | ||
|
||
t.same(get("payload", testObj1), [".a.b.c", ".d.[2]"]); | ||
t.same(get("test", testObj1), [".d.[1]"]); | ||
t.same(get("notfound", testObj1), []); | ||
|
||
t.same(get("payload", "payload"), ["."]); | ||
t.same(get("test", "payload"), []); | ||
|
||
t.same(get("", undefined), []); | ||
t.same(get("", null), []); | ||
t.same( | ||
get("", () => {}), | ||
[] | ||
); | ||
|
||
t.same( | ||
get("string", [ | ||
"string", | ||
1, | ||
true, | ||
null, | ||
undefined, | ||
{ test: "test" }, | ||
"string", | ||
]), | ||
[".[0]", ".[6]"] | ||
); | ||
|
||
// Concatenates array values | ||
t.same(get("test,test2", ["test", "test2"]), ["."]); | ||
t.same(get("test,test2", { test: { x: ["test", "test2"] } }), [".test.x"]); | ||
}); | ||
|
||
t.test("it works with jwt", async (t) => { | ||
const testObj2 = { | ||
a: { | ||
x: ["test", "notfoundx"], | ||
b: { | ||
c: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.uG3R-hTeSn-DUddaexdXHw4pvXwKdyxqsD2k0BZrbd4", | ||
}, | ||
}, | ||
}; | ||
|
||
t.same(get("John Doe", testObj2), [".a.b.c<jwt>.name"]); | ||
t.same(get("1234567890", testObj2), [".a.b.c<jwt>.sub"]); | ||
t.same(get("notfound", testObj2), []); | ||
}); |
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
Oops, something went wrong.