mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
JS: Add test case for flow through new Error()
This commit is contained in:
@@ -1,33 +1,67 @@
|
||||
function test(unsafe, safe) {
|
||||
try {
|
||||
throw2(source());
|
||||
throwRaw2(source());
|
||||
} catch (e) {
|
||||
sink(e);
|
||||
sink(e); // NOT OK
|
||||
}
|
||||
|
||||
try {
|
||||
throw2(unsafe);
|
||||
throwRaw2(unsafe);
|
||||
} catch (e) {
|
||||
sink(e);
|
||||
sink(e); // NOT OK
|
||||
}
|
||||
|
||||
try {
|
||||
throw2(safe);
|
||||
throwRaw2(safe);
|
||||
} catch (e) {
|
||||
sink(e); // OK
|
||||
}
|
||||
|
||||
try {
|
||||
throwError2(source());
|
||||
} catch (e) {
|
||||
sink(e); // NOT OK
|
||||
sink(e.toString()); // NOT OK
|
||||
sink(e.message); // NOT OK
|
||||
sink(e.fileName); // OK
|
||||
}
|
||||
|
||||
try {
|
||||
throwError2(unsafe);
|
||||
} catch (e) {
|
||||
sink(e); // NOT OK
|
||||
sink(e.toString()); // NOT OK
|
||||
sink(e.message); // NOT OK
|
||||
sink(e.fileName); // OK
|
||||
}
|
||||
|
||||
try {
|
||||
throwError2(safe);
|
||||
} catch (e) {
|
||||
sink(e); // NOT OK
|
||||
sink(e.toString()); // NOT OK
|
||||
sink(e.message); // NOT OK
|
||||
sink(e.fileName); // OK
|
||||
}
|
||||
}
|
||||
|
||||
function throw2(x) {
|
||||
throw1(x);
|
||||
throw1(x); // no single-call inlining
|
||||
function throwRaw2(x) {
|
||||
throwRaw1(x);
|
||||
throwRaw1(x); // no single-call inlining
|
||||
}
|
||||
|
||||
function throw1(x) {
|
||||
function throwRaw1(x) {
|
||||
throw x;
|
||||
}
|
||||
|
||||
function throwError2(x) {
|
||||
throwError1(x);
|
||||
throwError1(x); // no single-call inlining
|
||||
}
|
||||
|
||||
function throwError1(x) {
|
||||
throw new Error(x);
|
||||
}
|
||||
|
||||
test(source(), "hello");
|
||||
test("hey", "hello"); // no single-call inlining
|
||||
|
||||
|
||||
Reference in New Issue
Block a user