Skip to content

Commit eca8bf5

Browse files
committed
JS: Do simple modeling of process.stdin as threat-model source
1 parent 34b86c3 commit eca8bf5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ extensions:
66
extensible: sourceModel
77
data:
88
- ['fs', 'Member[promises].Member[readFile].ReturnValue.Member[then].Argument[0].Parameter[0]', 'file']
9+
- ['global', 'Member[process].Member[stdin].Member[read].ReturnValue', 'stdin']
10+
- ['global', 'Member[process].Member[stdin].Member[on,addListener].WithStringArgument[0=data].Argument[1].Parameter[0]', 'stdin']

javascript/ql/test/library-tests/threat-models/sources/sources.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ rl_file.on("line", (line) => {
9494
// ------ reading from stdin ------
9595

9696
// Accessing stdin using process.stdin
97-
process.stdin.on('data', (data) => { // $ MISSING: threat-source=stdin
98-
SINK(data); // $ MISSING: hasFlow
97+
process.stdin.on('data', (data) => { // $ threat-source=stdin
98+
SINK(data); // $ hasFlow
9999
});
100100

101-
const stdin_line = process.stdin.read(); // $ MISSING: threat-source=stdin
102-
SINK(stdin_line); // $ MISSING: hasFlow
101+
const stdin_line = process.stdin.read(); // $ threat-source=stdin
102+
SINK(stdin_line); // $ hasFlow
103103

104104
// Accessing stdin using readline
105105
const readline = require('readline');

0 commit comments

Comments
 (0)