Skip to content

Commit 5645a29

Browse files
authored
fix(scan): respect global evaluation result for accepted risks (#93)
1 parent 1781643 commit 5645a29

File tree

8 files changed

+4836
-26
lines changed

8 files changed

+4836
-26
lines changed

dist/index.js

Lines changed: 8 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "secure-inline-scan-action",
3-
"version": "6.2.0",
3+
"version": "6.2.1",
44
"description": "This actions performs image analysis on locally built container image and posts the result of the analysis to Sysdig Secure.",
55
"main": "index.js",
66
"scripts": {

src/domain/scanresult/ScanResult.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class ScanResult {
3434
private readonly policies: Map<string, Policy> = new Map();
3535
private readonly policyBundles: Map<string, PolicyBundle> = new Map();
3636
private readonly acceptedRisks: Map<string, AcceptedRisk> = new Map();
37+
private readonly evaluationResult: EvaluationResult;
3738

3839
constructor(
3940
public readonly scanType: ScanType,
@@ -44,7 +45,8 @@ export class ScanResult {
4445
sizeInBytes: bigint,
4546
architecture: Architecture,
4647
labels: Record<string, string>,
47-
createdAt: Date
48+
createdAt: Date,
49+
evaluationResult: EvaluationResult
4850
) {
4951
this.metadata = new Metadata(
5052
pullString,
@@ -56,6 +58,7 @@ export class ScanResult {
5658
labels,
5759
createdAt
5860
);
61+
this.evaluationResult = evaluationResult;
5962
}
6063

6164
addLayer(digest: string, index: number, size: bigint | null, command: string): Layer {
@@ -196,11 +199,6 @@ export class ScanResult {
196199
}
197200

198201
getEvaluationResult(): EvaluationResult {
199-
for (const policy of this.getPolicies()) {
200-
if (policy.getEvaluationResult().isFailed()) {
201-
return EvaluationResult.Failed;
202-
}
203-
}
204-
return EvaluationResult.Passed;
202+
return this.evaluationResult;
205203
}
206204
}

src/infrastructure/sysdig/JsonScanResultV1ToScanResultAdapter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
// Helper interfaces to provide better typing than `any` for vulnerabilities and risks
1818
export class JsonScanResultV1ToScanResultAdapter {
1919
public toScanResult(report: JsonScanResultV1): ScanResult {
20-
const scanResult = this.createScanResult(report.result.metadata);
20+
const scanResult = this.createScanResult(report);
2121
const reportResult = report.result;
2222

2323
this.addLayers(reportResult, scanResult);
@@ -29,7 +29,8 @@ export class JsonScanResultV1ToScanResultAdapter {
2929
return scanResult;
3030
}
3131

32-
private createScanResult(metadata: ReportMetadata): ScanResult {
32+
private createScanResult(report: JsonScanResultV1): ScanResult {
33+
const metadata = report.result.metadata;
3334
return new ScanResult(
3435
ScanType.Docker, // Assuming Docker scan type as in the Rust code
3536
metadata.pullString,
@@ -39,7 +40,8 @@ export class JsonScanResultV1ToScanResultAdapter {
3940
BigInt(metadata.size),
4041
Architecture.fromString(metadata.architecture),
4142
metadata.labels ?? {},
42-
new Date(metadata.createdAt)
43+
new Date(metadata.createdAt),
44+
EvaluationResult.fromString(report.result.policies.globalEvaluation)
4345
);
4446
}
4547

0 commit comments

Comments
 (0)