Skip to content

Commit 1d1701d

Browse files
authored
fix(iac): unstuck scan when no problems were found (#21)
1 parent 667a79f commit 1d1701d

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
shellHook = ''
7171
npm ci
7272
'';
73-
buildInputs = [
73+
packages = [
7474
vscode
7575
nodejs
7676
typescript

src/config/configScanner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const ENDPOINT_LABELS: { [key: string]: string } = {
2727
"https://app.me2.sysdig.com": "ME Central (GCP)"
2828
};
2929

30-
export const SCANNER_VERSION : string = '1.13.0';
30+
export const SCANNER_VERSION : string = '1.22.1';
3131
const SCANNER_BASE_URL : string = 'https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/';
3232
const SCANNER_BINARY_NAME : string = 'sysdig-cli-scanner';
3333

@@ -188,4 +188,4 @@ export async function storeCredentials(context: vscode.ExtensionContext) {
188188
await context.secrets.store("sysdig-vscode-ext.secureEndpoint", secureEndpoint);
189189
await context.secrets.store("sysdig-vscode-ext.secureAPIToken", secureAPIToken);
190190
vscode.window.showInformationMessage('Successfully stored Sysdig Secure credentials');
191-
}
191+
}

src/runners/iacScanRunner.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ interface commandIACOptions {
2121

2222
interface 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

Comments
 (0)