Skip to content

Commit d234c27

Browse files
committed
chore: fix the result of witness_provenance_l1_check in case no witness provenance discovered
Signed-off-by: Nathan Nguyen <[email protected]>
1 parent e519b9a commit d234c27

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

src/macaron/slsa_analyzer/checks/provenance_witness_l1_check.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ def run_check(self, ctx: AnalyzeContext, check_result: CheckResult) -> CheckResu
169169

170170
verified_artifact_assets.extend(artifact_assets)
171171

172-
check_result["justification"].append("Successfully verified the following artifacts:")
173-
for asset in verified_artifact_assets:
174-
check_result["justification"].append(f"* {asset.url}")
175-
176-
check_result["result_tables"].append(ProvenanceWitnessL1Table())
177-
return CheckResultType.PASSED
172+
# If Macaron cannot discover any witness provenance, we "fail" the check.
173+
# Here, there status ``FAILED`` means: Macaron fails to discover any witness provenance.
174+
# This is consistent with how Souffle works: facts in Souffle usually represent things that exist.
175+
if len(verified_artifact_assets) > 0:
176+
check_result["justification"].append("Successfully verified the following artifacts:")
177+
for asset in verified_artifact_assets:
178+
check_result["justification"].append(f"* {asset.url}")
179+
check_result["result_tables"].append(ProvenanceWitnessL1Table())
180+
return CheckResultType.PASSED
181+
182+
check_result["justification"].append("Failed to discover any witness provenance.")
183+
return CheckResultType.FAILED
178184

179185

180186
registry.register(ProvenanceWitnessL1Check())

tests/e2e/expected_results/micronaut-core/micronaut-core.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@
752752
"checks": {
753753
"summary": {
754754
"DISABLED": 0,
755-
"FAILED": 1,
756-
"PASSED": 7,
755+
"FAILED": 2,
756+
"PASSED": 6,
757757
"SKIPPED": 0,
758758
"UNKNOWN": 1
759759
},
@@ -846,8 +846,10 @@
846846
"Provenance content - Identifies artifacts - SLSA Level 1",
847847
"Provenance content - Identifies builder - SLSA Level 1"
848848
],
849-
"justification": [],
850-
"result_type": "PASSED"
849+
"justification": [
850+
"Failed to discover any witness provenance."
851+
],
852+
"result_type": "FAILED"
851853
},
852854
{
853855
"check_id": "mcn_version_control_system_1",

tests/e2e/expected_results/slsa-verifier/slsa-verifier_cue_PASS.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,8 +1683,8 @@
16831683
"checks": {
16841684
"summary": {
16851685
"DISABLED": 0,
1686-
"FAILED": 0,
1687-
"PASSED": 9,
1686+
"FAILED": 1,
1687+
"PASSED": 8,
16881688
"SKIPPED": 0,
16891689
"UNKNOWN": 0
16901690
},
@@ -1777,8 +1777,10 @@
17771777
"Provenance content - Identifies artifacts - SLSA Level 1",
17781778
"Provenance content - Identifies builder - SLSA Level 1"
17791779
],
1780-
"justification": [],
1781-
"result_type": "PASSED"
1780+
"justification": [
1781+
"Failed to discover any witness provenance."
1782+
],
1783+
"result_type": "FAILED"
17821784
},
17831785
{
17841786
"check_id": "mcn_trusted_builder_level_three_1",

tests/e2e/expected_results/urllib3/urllib3.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@
271271
"checks": {
272272
"summary": {
273273
"DISABLED": 0,
274-
"FAILED": 1,
275-
"PASSED": 8,
274+
"FAILED": 2,
275+
"PASSED": 7,
276276
"SKIPPED": 0,
277277
"UNKNOWN": 0
278278
},
@@ -365,8 +365,10 @@
365365
"Provenance content - Identifies artifacts - SLSA Level 1",
366366
"Provenance content - Identifies builder - SLSA Level 1"
367367
],
368-
"justification": [],
369-
"result_type": "PASSED"
368+
"justification": [
369+
"Failed to discover any witness provenance."
370+
],
371+
"result_type": "FAILED"
370372
},
371373
{
372374
"check_id": "mcn_version_control_system_1",

tests/e2e/expected_results/urllib3/urllib3_cue_invalid.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@
271271
"checks": {
272272
"summary": {
273273
"DISABLED": 0,
274-
"FAILED": 1,
275-
"PASSED": 7,
274+
"FAILED": 2,
275+
"PASSED": 6,
276276
"SKIPPED": 0,
277277
"UNKNOWN": 1
278278
},
@@ -365,8 +365,10 @@
365365
"Provenance content - Identifies artifacts - SLSA Level 1",
366366
"Provenance content - Identifies builder - SLSA Level 1"
367367
],
368-
"justification": [],
369-
"result_type": "PASSED"
368+
"justification": [
369+
"Failed to discover any witness provenance."
370+
],
371+
"result_type": "FAILED"
370372
},
371373
{
372374
"check_id": "mcn_version_control_system_1",

0 commit comments

Comments
 (0)