@@ -15,7 +15,8 @@ import {
1515const defaultSeverity = 'Warning' ;
1616
1717export function extractAnalysisAlerts (
18- sarifLog : sarif . Log
18+ sarifLog : sarif . Log ,
19+ fileLinkPrefix : string
1920) : {
2021 alerts : AnalysisAlert [ ] ,
2122 errors : string [ ]
@@ -26,7 +27,7 @@ export function extractAnalysisAlerts(
2627 for ( const run of sarifLog . runs ?? [ ] ) {
2728 for ( const result of run . results ?? [ ] ) {
2829 try {
29- alerts . push ( ...extractResultAlerts ( run , result ) ) ;
30+ alerts . push ( ...extractResultAlerts ( run , result , fileLinkPrefix ) ) ;
3031 } catch ( e ) {
3132 errors . push ( `Error when processing SARIF result: ${ e } ` ) ;
3233 continue ;
@@ -39,14 +40,15 @@ export function extractAnalysisAlerts(
3940
4041function extractResultAlerts (
4142 run : sarif . Run ,
42- result : sarif . Result
43+ result : sarif . Result ,
44+ fileLinkPrefix : string
4345) : AnalysisAlert [ ] {
4446 const alerts : AnalysisAlert [ ] = [ ] ;
4547
46- const message = getMessage ( result ) ;
48+ const message = getMessage ( result , fileLinkPrefix ) ;
4749 const rule = tryGetRule ( run , result ) ;
4850 const severity = tryGetSeverity ( run , result , rule ) || defaultSeverity ;
49- const codeFlows = getCodeFlows ( result ) ;
51+ const codeFlows = getCodeFlows ( result , fileLinkPrefix ) ;
5052 const shortDescription = getShortDescription ( rule , message ! ) ;
5153
5254 for ( const location of result . locations ?? [ ] ) {
@@ -60,7 +62,10 @@ function extractResultAlerts(
6062 const analysisAlert : AnalysisAlert = {
6163 message,
6264 shortDescription,
63- filePath,
65+ fileLink : {
66+ fileLinkPrefix,
67+ filePath,
68+ } ,
6469 severity,
6570 codeSnippet,
6671 highlightedRegion,
@@ -177,7 +182,8 @@ function getHighlightedRegion(region: sarif.Region): HighlightedRegion {
177182}
178183
179184function getCodeFlows (
180- result : sarif . Result
185+ result : sarif . Result ,
186+ fileLinkPrefix : string
181187) : CodeFlow [ ] {
182188 const codeFlows = [ ] ;
183189
@@ -195,7 +201,10 @@ function getCodeFlows(
195201 : undefined ;
196202
197203 threadFlows . push ( {
198- filePath,
204+ fileLink : {
205+ fileLinkPrefix,
206+ filePath,
207+ } ,
199208 codeSnippet,
200209 highlightedRegion
201210 } as ThreadFlow ) ;
@@ -209,7 +218,7 @@ function getCodeFlows(
209218 return codeFlows ;
210219}
211220
212- function getMessage ( result : sarif . Result ) : AnalysisMessage {
221+ function getMessage ( result : sarif . Result , fileLinkPrefix : string ) : AnalysisMessage {
213222 const tokens : AnalysisMessageToken [ ] = [ ] ;
214223
215224 const messageText = result . message ! . text ! ;
@@ -224,7 +233,10 @@ function getMessage(result: sarif.Result): AnalysisMessage {
224233 t : 'location' ,
225234 text : messagePart . text ,
226235 location : {
227- filePath : relatedLocation ! . physicalLocation ! . artifactLocation ! . uri ! ,
236+ fileLink : {
237+ fileLinkPrefix : fileLinkPrefix ,
238+ filePath : relatedLocation ! . physicalLocation ! . artifactLocation ! . uri ! ,
239+ } ,
228240 highlightedRegion : getHighlightedRegion ( relatedLocation ! . physicalLocation ! . region ! ) ,
229241 }
230242 } ) ;
0 commit comments