Skip to content

Commit 3d443c5

Browse files
committed
Add test cases for non-stream field accesses and methods before and after pipe operations
1 parent 03d1f9a commit 3d443c5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
| test.js:116:5:116:21 | stream.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
1010
| test.js:125:5:125:26 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
1111
| test.js:143:5:143:62 | stream. ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
12+
| test.js:171:5:171:50 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
13+
| test.js:175:5:175:39 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
14+
| test.js:179:17:179:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
15+
| test.js:183:17:183:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
16+
| test.js:193:5:193:32 | copyStr ... nation) | 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/test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,36 @@ function test() {
166166
const notStream = getNotAStream();
167167
notStream.pipe(arg1, arg2, arg3);
168168
}
169+
{ // Member access on a non-stream after pipe
170+
const notStream = getNotAStream();
171+
const val = notStream.pipe(writable).someMember; // $SPURIOUS:Alert
172+
}
173+
{ // Member access on a stream after pipe
174+
const notStream = getNotAStream();
175+
const val = notStream.pipe(writable).readable; // $Alert
176+
}
177+
{ // Method access on a non-stream after pipe
178+
const notStream = getNotAStream();
179+
const val = notStream.pipe(writable).someMethod();
180+
}
181+
{ // Pipe on fs readStream
182+
const fs = require('fs');
183+
const stream = fs.createReadStream('file.txt');
184+
const copyStream = stream;
185+
copyStream.pipe(destination); // $Alert
186+
}
187+
{
188+
const notStream = getNotAStream();
189+
const something = notStream.someNotStreamPropertyAccess;
190+
const val = notStream.pipe(writable); // $SPURIOUS:Alert
191+
}
192+
{
193+
const notStream = getNotAStream();
194+
const something = notStream.someNotStreamPropertyAccess();
195+
const val = notStream.pipe(writable); // $SPURIOUS:Alert
196+
}
197+
{
198+
const notStream = getNotAStream();
199+
notStream.pipe(map(() => {})); // $SPURIOUS:Alert
200+
}
169201
}

0 commit comments

Comments
 (0)