mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
JS: Track taint through exceptions
This commit is contained in:
33
javascript/ql/test/library-tests/TaintTracking/exceptions.js
Normal file
33
javascript/ql/test/library-tests/TaintTracking/exceptions.js
Normal file
@@ -0,0 +1,33 @@
|
||||
function test(unsafe, safe) {
|
||||
try {
|
||||
throw2(source());
|
||||
} catch (e) {
|
||||
sink(e);
|
||||
}
|
||||
|
||||
try {
|
||||
throw2(unsafe);
|
||||
} catch (e) {
|
||||
sink(e);
|
||||
}
|
||||
|
||||
try {
|
||||
throw2(safe);
|
||||
} catch (e) {
|
||||
sink(e); // OK
|
||||
}
|
||||
}
|
||||
|
||||
function throw2(x) {
|
||||
throw1(x);
|
||||
throw1(x); // no single-call inlining
|
||||
}
|
||||
|
||||
function throw1(x) {
|
||||
throw x;
|
||||
}
|
||||
|
||||
|
||||
test(source(), "hello");
|
||||
test("hey", "hello"); // no single-call inlining
|
||||
|
||||
Reference in New Issue
Block a user