File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed
extensions/ql-vscode/src/variant-analysis Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ export function tryGetRule(
168168 return undefined ;
169169}
170170
171+ function getFilePath (
172+ physicalLocation : sarif . PhysicalLocation ,
173+ ) : string | undefined {
174+ const filePath = physicalLocation . artifactLocation ?. uri ;
175+ if ( filePath === undefined || filePath === "" || filePath === "file:/" ) {
176+ return undefined ;
177+ }
178+ return filePath ;
179+ }
180+
171181function getCodeSnippet (
172182 contextRegion ?: sarif . Region ,
173183 region ?: sarif . Region ,
@@ -244,7 +254,7 @@ function getCodeFlows(
244254 for ( const threadFlowLocation of threadFlow . locations ) {
245255 const physicalLocation =
246256 threadFlowLocation ! . location ! . physicalLocation ! ;
247- const filePath = physicalLocation ! . artifactLocation ! . uri ! ;
257+ const filePath = getFilePath ( physicalLocation ) ;
248258 const codeSnippet = getCodeSnippet (
249259 physicalLocation . contextRegion ,
250260 physicalLocation . region ,
@@ -253,14 +263,16 @@ function getCodeFlows(
253263 ? getHighlightedRegion ( physicalLocation . region )
254264 : undefined ;
255265
256- threadFlows . push ( {
257- fileLink : {
258- fileLinkPrefix,
259- filePath,
260- } ,
261- codeSnippet,
262- highlightedRegion,
263- } ) ;
266+ if ( filePath !== undefined ) {
267+ threadFlows . push ( {
268+ fileLink : {
269+ fileLinkPrefix,
270+ filePath,
271+ } ,
272+ codeSnippet,
273+ highlightedRegion,
274+ } ) ;
275+ }
264276 }
265277 }
266278
You can’t perform that action at this time.
0 commit comments