@@ -21,15 +21,15 @@ interface commandIACOptions {
2121
2222interface ScanData {
2323 result : {
24- findings : Array < {
25- severity : string ;
26- resources : Array < {
27- source : string ;
28- location : string ;
29- type : string ;
30- name : string ;
24+ findings ? : Array < {
25+ severity ? : string ;
26+ resources ? : Array < {
27+ source ? : string ;
28+ location ? : string ;
29+ type ? : string ;
30+ name ? : string ;
3131 } > ;
32- name : string ;
32+ name ? : string ;
3333 } > ;
3434 } ;
3535}
@@ -79,8 +79,9 @@ export async function runScan(context: vscode.ExtensionContext, binaryPath: stri
7979 loadingBar . text = "$(sync~spin) Scanning with Sysdig..." ;
8080 loadingBar . show ( ) ;
8181
82- childProcess . exec ( command , { cwd : pathToScan , env : { SECURE_API_TOKEN : secureAPIToken } } , ( error , stdout , stderr ) => {
82+ childProcess . exec ( command , { cwd : pathToScan , env : { ... process . env , SECURE_API_TOKEN : secureAPIToken } } , ( error , stdout , stderr ) => {
8383 loadingBar . hide ( ) ;
84+ outputChannel . appendLine ( stdout ) ;
8485 if ( error ) {
8586 console . error ( `exec error: ${ error } ` ) ;
8687 vscode . window . showErrorMessage ( `Execution error: ${ error } ` ) ;
@@ -122,11 +123,14 @@ function parseScanOutput(outputScanFile: string): { [key: string]: vscode.Diagno
122123 "low" : vscode . DiagnosticSeverity . Information
123124 } ;
124125
125- for ( const finding of scanData . result . findings ) {
126- const severity = severityMap [ finding . severity . toLowerCase ( ) ] ;
127- for ( const resource of finding . resources ) {
126+ for ( const finding of scanData . result . findings ?? [ ] ) {
127+ const severity = severityMap [ finding . severity ? .toLowerCase ( ) ?? "low" ] ;
128+ for ( const resource of finding . resources ?? [ ] ) {
128129 const message = finding . name + ": " + resource . location + " (" + resource . type + ": " + resource . name + ")" ;
129130 const diagnostic = new vscode . Diagnostic ( new vscode . Range ( 0 , 0 , 0 , 0 ) , message , severity ) ;
131+ if ( ! resource . source ) {
132+ continue ;
133+ }
130134 if ( ! diagnosticsMap [ resource . source ] ) {
131135 diagnosticsMap [ resource . source ] = [ ] ;
132136 }
0 commit comments