|
16 | 16 | <summary>Path with 5 steps</summary> |
17 | 17 |
|
18 | 18 | 1. [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#L4-L4) |
19 | | - <pre><code class="javascript"> path = require("path"); |
20 | | - function cleanupTemp() { |
21 | | - let cmd = "rm -rf " + path.join(<strong>__dirname</strong>, "temp"); |
22 | | - cp.execSync(cmd); // BAD |
23 | | - } |
24 | | - </code></pre> |
25 | | - |
| 19 | + <pre><code class="javascript"> path = require("path"); |
| 20 | + function cleanupTemp() { |
| 21 | + let cmd = "rm -rf " + path.join(<strong>__dirname</strong>, "temp"); |
| 22 | + cp.execSync(cmd); // BAD |
| 23 | + } |
| 24 | + </code></pre> |
| 25 | + |
26 | 26 | 2. [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#L4-L4) |
27 | | - <pre><code class="javascript"> path = require("path"); |
28 | | - function cleanupTemp() { |
29 | | - let cmd = "rm -rf " + <strong>path.join(__dirname, "temp")</strong>; |
30 | | - cp.execSync(cmd); // BAD |
31 | | - } |
32 | | - </code></pre> |
33 | | - |
| 27 | + <pre><code class="javascript"> path = require("path"); |
| 28 | + function cleanupTemp() { |
| 29 | + let cmd = "rm -rf " + <strong>path.join(__dirname, "temp")</strong>; |
| 30 | + cp.execSync(cmd); // BAD |
| 31 | + } |
| 32 | + </code></pre> |
| 33 | + |
34 | 34 | 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#L4-L4) |
35 | | - <pre><code class="javascript"> path = require("path"); |
36 | | - function cleanupTemp() { |
37 | | - let cmd = <strong>"rm -rf " + path.join(__dirname, "temp")</strong>; |
38 | | - cp.execSync(cmd); // BAD |
39 | | - } |
40 | | - </code></pre> |
41 | | - |
| 35 | + <pre><code class="javascript"> path = require("path"); |
| 36 | + function cleanupTemp() { |
| 37 | + let cmd = <strong>"rm -rf " + path.join(__dirname, "temp")</strong>; |
| 38 | + cp.execSync(cmd); // BAD |
| 39 | + } |
| 40 | + </code></pre> |
| 41 | + |
42 | 42 | 4. [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#L4-L4) |
43 | | - <pre><code class="javascript"> path = require("path"); |
44 | | - function cleanupTemp() { |
45 | | - let <strong>cmd = "rm -rf " + path.join(__dirname, "temp")</strong>; |
46 | | - cp.execSync(cmd); // BAD |
47 | | - } |
48 | | - </code></pre> |
49 | | - |
| 43 | + <pre><code class="javascript"> path = require("path"); |
| 44 | + function cleanupTemp() { |
| 45 | + let <strong>cmd = "rm -rf " + path.join(__dirname, "temp")</strong>; |
| 46 | + cp.execSync(cmd); // BAD |
| 47 | + } |
| 48 | + </code></pre> |
| 49 | + |
50 | 50 | 5. [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) |
51 | | - <pre><code class="javascript">function cleanupTemp() { |
52 | | - let cmd = "rm -rf " + path.join(__dirname, "temp"); |
53 | | - cp.execSync(<strong>cmd</strong>); // BAD |
54 | | - } |
55 | | - </code></pre> |
56 | | - |
| 51 | + <pre><code class="javascript">function cleanupTemp() { |
| 52 | + let cmd = "rm -rf " + path.join(__dirname, "temp"); |
| 53 | + cp.execSync(<strong>cmd</strong>); // BAD |
| 54 | + } |
| 55 | + </code></pre> |
| 56 | + |
57 | 57 |
|
58 | 58 | </details> |
59 | 59 |
|
|
76 | 76 | <summary>Path with 3 steps</summary> |
77 | 77 |
|
78 | 78 | 1. [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) |
79 | | - <pre><code class="javascript">(function() { |
80 | | - cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
81 | | - cp.execSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // BAD |
82 | | - |
83 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
84 | | - </code></pre> |
85 | | - |
| 79 | + <pre><code class="javascript">(function() { |
| 80 | + cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
| 81 | + cp.execSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // BAD |
| 82 | + |
| 83 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 84 | + </code></pre> |
| 85 | + |
86 | 86 | 2. [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) |
87 | | - <pre><code class="javascript">(function() { |
88 | | - cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
89 | | - cp.execSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // BAD |
90 | | - |
91 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
92 | | - </code></pre> |
93 | | - |
| 87 | + <pre><code class="javascript">(function() { |
| 88 | + cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
| 89 | + cp.execSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // BAD |
| 90 | + |
| 91 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 92 | + </code></pre> |
| 93 | + |
94 | 94 | 3. [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) |
95 | | - <pre><code class="javascript">(function() { |
96 | | - cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
97 | | - cp.execSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // BAD |
98 | | - |
99 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
100 | | - </code></pre> |
101 | | - |
| 95 | + <pre><code class="javascript">(function() { |
| 96 | + cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
| 97 | + cp.execSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // BAD |
| 98 | + |
| 99 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 100 | + </code></pre> |
| 101 | + |
102 | 102 |
|
103 | 103 | </details> |
104 | 104 |
|
|
121 | 121 | <summary>Path with 3 steps</summary> |
122 | 122 |
|
123 | 123 | 1. [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) |
124 | | - <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
125 | | - |
126 | | - execa.shell('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
127 | | - execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
128 | | - |
129 | | - </code></pre> |
130 | | - |
| 124 | + <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
| 125 | + |
| 126 | + execa.shell('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
| 127 | + execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 128 | + |
| 129 | + </code></pre> |
| 130 | + |
131 | 131 | 2. [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) |
132 | | - <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
133 | | - |
134 | | - execa.shell('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
135 | | - execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
136 | | - |
137 | | - </code></pre> |
138 | | - |
| 132 | + <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
| 133 | + |
| 134 | + execa.shell('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
| 135 | + execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 136 | + |
| 137 | + </code></pre> |
| 138 | + |
139 | 139 | 3. [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) |
140 | | - <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
141 | | - |
142 | | - execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
143 | | - execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
144 | | - |
145 | | - </code></pre> |
146 | | - |
| 140 | + <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
| 141 | + |
| 142 | + execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
| 143 | + execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 144 | + |
| 145 | + </code></pre> |
| 146 | + |
147 | 147 |
|
148 | 148 | </details> |
149 | 149 |
|
|
166 | 166 | <summary>Path with 3 steps</summary> |
167 | 167 |
|
168 | 168 | 1. [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) |
169 | | - <pre><code class="javascript"> |
170 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
171 | | - execa.shellSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
172 | | - |
173 | | - const safe = "\"" + path.join(__dirname, "temp") + "\""; |
174 | | - </code></pre> |
175 | | - |
| 169 | + <pre><code class="javascript"> |
| 170 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 171 | + execa.shellSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
| 172 | + |
| 173 | + const safe = "\"" + path.join(__dirname, "temp") + "\""; |
| 174 | + </code></pre> |
| 175 | + |
176 | 176 | 2. [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) |
177 | | - <pre><code class="javascript"> |
178 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
179 | | - execa.shellSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
180 | | - |
181 | | - const safe = "\"" + path.join(__dirname, "temp") + "\""; |
182 | | - </code></pre> |
183 | | - |
| 177 | + <pre><code class="javascript"> |
| 178 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 179 | + execa.shellSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
| 180 | + |
| 181 | + const safe = "\"" + path.join(__dirname, "temp") + "\""; |
| 182 | + </code></pre> |
| 183 | + |
184 | 184 | 3. [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) |
185 | | - <pre><code class="javascript"> |
186 | | - execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
187 | | - execa.shellSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
188 | | - |
189 | | - const safe = "\"" + path.join(__dirname, "temp") + "\""; |
190 | | - </code></pre> |
191 | | - |
| 185 | + <pre><code class="javascript"> |
| 186 | + execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
| 187 | + execa.shellSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
| 188 | + |
| 189 | + const safe = "\"" + path.join(__dirname, "temp") + "\""; |
| 190 | + </code></pre> |
| 191 | + |
192 | 192 |
|
193 | 193 | </details> |
194 | 194 |
|
|
0 commit comments