Skip to content

Commit b47fa77

Browse files
committed
JS: Add tests for stdin threat-model sources
1 parent 2b6c27e commit b47fa77

File tree

1 file changed

+29
-0
lines changed
  • javascript/ql/test/library-tests/threat-models/sources

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,32 @@ const rl_file = readline.createInterface({
8989
rl_file.on("line", (line) => {
9090
SINK(line); // $ MISSING: hasFlow
9191
});
92+
93+
94+
// ------ reading from stdin ------
95+
96+
// Accessing stdin using process.stdin
97+
process.stdin.on('data', (data) => { // $ MISSING: threat-source=stdin
98+
SINK(data); // $ MISSING: hasFlow
99+
});
100+
101+
const stdin_line = process.stdin.read(); // $ MISSING: threat-source=stdin
102+
SINK(stdin_line); // $ MISSING: hasFlow
103+
104+
// Accessing stdin using readline
105+
const readline = require('readline');
106+
const rl_stdin = readline.createInterface({
107+
input: process.stdin // $ MISSING: threat-source=stdin
108+
});
109+
rl_stdin.question('<question>', (answer) => {
110+
SINK(answer); // $ MISSING: hasFlow
111+
});
112+
113+
function handler(answer) {
114+
SINK(answer); // $ MISSING: hasFlow
115+
}
116+
rl_stdin.question('<question>', handler);
117+
118+
rl_stdin.on("line", (line) => {
119+
SINK(line); // $ MISSING: hasFlow
120+
});

0 commit comments

Comments
 (0)