Skip to content

Commit 9b00c4b

Browse files
committed
tmp: Report finding without stack
1 parent 6af8ef4 commit 9b00c4b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

packages/bug-detectors/internal/prototype-pollution.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ function detectPrototypePollutionOfBasicObjects(
335335
if (!currentProtoSnapshots[i]) {
336336
reportFinding(
337337
`Prototype Pollution: Prototype of ${BASIC_OBJECT_NAMES[i]} changed.`,
338+
false,
338339
);
339340
return;
340341
}
@@ -345,6 +346,7 @@ function detectPrototypePollutionOfBasicObjects(
345346
if (equalityResult) {
346347
reportFinding(
347348
`Prototype Pollution: Prototype of ${BASIC_OBJECT_NAMES[i]} changed. ${equalityResult}`,
349+
false,
348350
);
349351
return;
350352
}

packages/core/finding.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ export function clearFirstFinding(): Finding | undefined {
4343
* Save the first finding reported by any bug detector.
4444
*
4545
* @param findingMessage - The finding to be saved.
46+
* @param containStack - Whether the finding should contain a stack trace or not.
4647
*/
47-
export function reportFinding(findingMessage: string): Finding | undefined {
48+
export function reportFinding(
49+
findingMessage: string,
50+
containStack = true,
51+
): Finding | undefined {
4852
// After saving the first finding, ignore all subsequent errors.
4953
if (getFirstFinding()) {
5054
return;
5155
}
5256
const reportedFinding = new Finding(findingMessage);
57+
if (!containStack) {
58+
reportedFinding.stack = findingMessage;
59+
}
5360
setJazzerJsGlobal(firstFinding, reportedFinding);
5461
return reportedFinding;
5562
}
@@ -59,9 +66,13 @@ export function reportFinding(findingMessage: string): Finding | undefined {
5966
* potentially abort the current execution.
6067
*
6168
* @param findingMessage - The finding to be saved and thrown.
69+
* @param containStack - Whether the finding should contain a stack trace or not.
6270
*/
63-
export function reportAndThrowFinding(findingMessage: string): void | never {
64-
throw reportFinding(findingMessage);
71+
export function reportAndThrowFinding(
72+
findingMessage: string,
73+
containStack = true,
74+
): void | never {
75+
throw reportFinding(findingMessage, containStack);
6576
}
6677

6778
/**

0 commit comments

Comments
 (0)