Skip to content

Commit 298ef9a

Browse files
committed
Now able to track error handler registration via instance properties
1 parent f843cc0 commit 298ef9a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

javascript/ql/src/Quality/UnhandledStreamPipe.ql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ private predicate hasErrorHandlerRegistered(PipeCall pipeCall) {
227227
stream = base.getAPropertyRead(propName) and
228228
base.getAPropertyRead(propName).getAMethodCall(_) instanceof ErrorHandlerRegistration
229229
)
230+
or
231+
exists(DataFlow::PropWrite propWrite, DataFlow::SourceNode instance |
232+
propWrite.getRhs().getALocalSource() = stream and
233+
instance = propWrite.getBase().getALocalSource() and
234+
instance.getAPropertyRead(propWrite.getPropertyName()).getAMethodCall(_) instanceof
235+
ErrorHandlerRegistration
236+
)
230237
)
231238
)
232239
or

javascript/ql/test/query-tests/Quality/UnhandledStreamPipe/test.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616
| tst.js:44:5:44:40 | wrapper ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
1717
| tst.js:52:5:52:37 | source. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
1818
| tst.js:59:18:59:39 | stream. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
19-
| tst.js:73:5:73:40 | wrapper ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
2019
| tst.js:111:5:111:26 | stream. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |

javascript/ql/test/query-tests/Quality/UnhandledStreamPipe/tst.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class StreamWrapper2 {
7070
function zip5() {
7171
const zipStream = createWriteStream(zipPath);
7272
let wrapper = new StreamWrapper2();
73-
wrapper.outputStream.pipe(zipStream); // $SPURIOUS:Alert
73+
wrapper.outputStream.pipe(zipStream);
7474
zipStream.on('error', e);
7575
}
7676

0 commit comments

Comments
 (0)