|
2 | 2 |
|
3 | 3 | [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5-L5) |
4 | 4 |
|
5 | | -```javascript |
| 5 | +<pre><code class="javascript"> |
6 | 6 | function cleanupTemp() { |
7 | 7 | let cmd = "rm -rf " + path.join(__dirname, "temp"); |
8 | 8 | cp.execSync(cmd); // BAD |
9 | 9 | } |
10 | 10 |
|
11 | | -``` |
| 11 | +</code></pre> |
12 | 12 |
|
13 | 13 | *This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4).* |
14 | 14 |
|
15 | 15 | ---------------------------------------- |
16 | 16 |
|
17 | 17 | [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6) |
18 | 18 |
|
19 | | -```javascript |
| 19 | +<pre><code class="javascript"> |
20 | 20 | (function() { |
21 | 21 | cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
22 | 22 | cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
23 | 23 |
|
24 | 24 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
25 | 25 |
|
26 | | -``` |
| 26 | +</code></pre> |
27 | 27 |
|
28 | 28 | *This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6).* |
29 | 29 |
|
30 | 30 | ---------------------------------------- |
31 | 31 |
|
32 | 32 | [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8) |
33 | 33 |
|
34 | | -```javascript |
| 34 | +<pre><code class="javascript"> |
35 | 35 | cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
36 | 36 |
|
37 | 37 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
38 | 38 | execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
39 | 39 |
|
40 | 40 |
|
41 | | -``` |
| 41 | +</code></pre> |
42 | 42 |
|
43 | 43 | *This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8).* |
44 | 44 |
|
45 | 45 | ---------------------------------------- |
46 | 46 |
|
47 | 47 | [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9) |
48 | 48 |
|
49 | | -```javascript |
| 49 | +<pre><code class="javascript"> |
50 | 50 |
|
51 | 51 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
52 | 52 | execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
53 | 53 |
|
54 | 54 | const safe = "\"" + path.join(__dirname, "temp") + "\""; |
55 | 55 |
|
56 | | -``` |
| 56 | +</code></pre> |
57 | 57 |
|
58 | 58 | *This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9).* |
59 | 59 |
|
|
0 commit comments