8000 Restrict pipe detection to calls with 1-2 arguments · github/codeql@03d1f9a · GitHub
[go: up one dir, main page]

Skip to content

Commit 03d1f9a

Browse files
committed
Restrict pipe detection to calls with 1-2 arguments
1 parent 30f2815 commit 03d1f9a

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

javascript/ql/src/Quality/UnhandledStreamPipe.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import javascript
1515
* A call to the `pipe` method on a Node.js stream.
1616
*/
1717
class PipeCall extends DataFlow::MethodCallNode {
18-
PipeCall() { this.getMethodName() = "pipe" }
18+
PipeCall() { this.getMethodName() = "pipe" and this.getNumArgument() = [1, 2] }
1919

2020
/** Gets the source stream (receiver of the pipe call). */
2121
DataFlow::Node getSourceStream() { result = this.getReceiver() }

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
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:163:5:163:20 | notStream.pipe() | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
13-
| test.js:167:5:167:36 | notStre ... , arg3) | 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ function test() {
160160
}
161161
{ // Calling custom pipe method with no arguments
162162
const notStream = getNotAStream();
163-
notStream.pipe(); // $SPURIOUS:Alert
163+
notStream.pipe();
164164
}
165165
{ // Calling custom pipe method with more then 2 arguments
166166
const notStream = getNotAStream();
167-
notStream.pipe(arg1, arg2, arg3); // $SPURIOUS:Alert
167+
notStream.pipe(arg1, arg2, arg3);
168168
}
169169
}

0 commit comments

Comments
 (0)
0