Skip to content

Commit 9b6eddd

Browse files
committed
MRVA: Expand path results individually
1 parent ed84825 commit 9b6eddd

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

extensions/ql-vscode/src/remote-queries/remote-queries-markdown-generation.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ function generateMarkdownForPathResults(
178178
interpretedResult: AnalysisAlert,
179179
language: string
180180
): MarkdownFile {
181-
const pathLines: MarkdownFile = [];
181+
const lines: MarkdownFile = [];
182+
lines.push('#### Paths', '');
182183
for (const codeFlow of interpretedResult.codeFlows) {
184+
const pathLines: MarkdownFile = [];
183185
const stepCount = codeFlow.threadFlows.length;
184-
pathLines.push(`#### Path with ${stepCount} steps`);
186+
const title = `Path with ${stepCount} steps`;
185187
for (let i = 0; i < stepCount; i++) {
186188
const threadFlow = codeFlow.threadFlows[i];
187189
const link = createMarkdownRemoteFileRef(
@@ -198,8 +200,11 @@ function generateMarkdownForPathResults(
198200
const codeSnippetIndented = codeSnippet.map((line) => ` ${line}`);
199201
pathLines.push(`${i + 1}. ${link}`, ...codeSnippetIndented);
200202
}
203+
lines.push(
204+
...buildExpandableMarkdownSection(title, pathLines)
205+
);
201206
}
202-
return buildExpandableMarkdownSection('Show paths', pathLines);
207+
return lines;
203208
}
204209

205210
function generateMarkdownForRawResults(

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/results-repo1.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
*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).*
1212

13+
#### Paths
14+
1315
<details>
14-
<summary>Show paths</summary>
16+
<summary>Path with 5 steps</summary>
1517

16-
#### Path with 5 steps
1718
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)
1819
<pre><code class="javascript"> path = require("path");
1920
function cleanupTemp() {
@@ -69,10 +70,11 @@
6970

7071
*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).*
7172

73+
#### Paths
74+
7275
<details>
73-
<summary>Show paths</summary>
76+
<summary>Path with 3 steps</summary>
7477

75-
#### Path with 3 steps
7678
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)
7779
<pre><code class="javascript">(function() {
7880
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
@@ -113,10 +115,11 @@
113115

114116
*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).*
115117

118+
#### Paths
119+
116120
<details>
117-
<summary>Show paths</summary>
121+
<summary>Path with 3 steps</summary>
118122

119-
#### Path with 3 steps
120123
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)
121124
<pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
122125

@@ -157,10 +160,11 @@
157160

158161
*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).*
159162

163+
#### Paths
164+
160165
<details>
161-
<summary>Show paths</summary>
166+
<summary>Path with 3 steps</summary>
162167

163-
#### Path with 3 steps
164168
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)
165169
<pre><code class="javascript">
166170
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/results-repo2.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
*This shell command depends on an uncontrolled [absolute path](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39).*
1313

14+
#### Paths
15+
1416
<details>
15-
<summary>Show paths</summary>
17+
<summary>Path with 7 steps</summary>
1618

17-
#### Path with 7 steps
1819
1. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
1920
<pre><code class="javascript">
2021
const meteorLocalFolder = '.meteor';
@@ -83,7 +84,12 @@
8384
}
8485
</code></pre>
8586

86-
#### Path with 2 steps
87+
88+
</details>
89+
90+
<details>
91+
<summary>Path with 2 steps</summary>
92+
8793
1. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
8894
<pre><code class="javascript">
8995
const meteorLocalFolder = '.meteor';

0 commit comments

Comments
 (0)