Skip to content

Commit

Permalink
chore: fix the result of witness_provenance_l1_check in case no witne…
Browse files Browse the repository at this point in the history
…ss provenance discovered

Signed-off-by: Nathan Nguyen <[email protected]>
  • Loading branch information
nathanwn committed Aug 20, 2023
1 parent e519b9a commit d234c27
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
18 changes: 12 additions & 6 deletions src/macaron/slsa_analyzer/checks/provenance_witness_l1_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,18 @@ def run_check(self, ctx: AnalyzeContext, check_result: CheckResult) -> CheckResu

verified_artifact_assets.extend(artifact_assets)

check_result["justification"].append("Successfully verified the following artifacts:")
for asset in verified_artifact_assets:
check_result["justification"].append(f"* {asset.url}")

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

check_result["justification"].append("Failed to discover any witness provenance.")
return CheckResultType.FAILED


registry.register(ProvenanceWitnessL1Check())
10 changes: 6 additions & 4 deletions tests/e2e/expected_results/micronaut-core/micronaut-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@
"checks": {
"summary": {
"DISABLED": 0,
"FAILED": 1,
"PASSED": 7,
"FAILED": 2,
"PASSED": 6,
"SKIPPED": 0,
"UNKNOWN": 1
},
Expand Down Expand Up @@ -846,8 +846,10 @@
"Provenance content - Identifies artifacts - SLSA Level 1",
"Provenance content - Identifies builder - SLSA Level 1"
],
"justification": [],
"result_type": "PASSED"
"justification": [
"Failed to discover any witness provenance."
],
"result_type": "FAILED"
},
{
"check_id": "mcn_version_control_system_1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,8 @@
"checks": {
"summary": {
"DISABLED": 0,
"FAILED": 0,
"PASSED": 9,
"FAILED": 1,
"PASSED": 8,
"SKIPPED": 0,
"UNKNOWN": 0
},
Expand Down Expand Up @@ -1777,8 +1777,10 @@
"Provenance content - Identifies artifacts - SLSA Level 1",
"Provenance content - Identifies builder - SLSA Level 1"
],
"justification": [],
"result_type": "PASSED"
"justification": [
"Failed to discover any witness provenance."
],
"result_type": "FAILED"
},
{
"check_id": "mcn_trusted_builder_level_three_1",
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/expected_results/urllib3/urllib3.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@
"checks": {
"summary": {
"DISABLED": 0,
"FAILED": 1,
"PASSED": 8,
"FAILED": 2,
"PASSED": 7,
"SKIPPED": 0,
"UNKNOWN": 0
},
Expand Down Expand Up @@ -365,8 +365,10 @@
"Provenance content - Identifies artifacts - SLSA Level 1",
"Provenance content - Identifies builder - SLSA Level 1"
],
"justification": [],
"result_type": "PASSED"
"justification": [
"Failed to discover any witness provenance."
],
"result_type": "FAILED"
},
{
"check_id": "mcn_version_control_system_1",
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/expected_results/urllib3/urllib3_cue_invalid.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@
"checks": {
"summary": {
"DISABLED": 0,
"FAILED": 1,
"PASSED": 7,
"FAILED": 2,
"PASSED": 6,
"SKIPPED": 0,
"UNKNOWN": 1
},
Expand Down Expand Up @@ -365,8 +365,10 @@
"Provenance content - Identifies artifacts - SLSA Level 1",
"Provenance content - Identifies builder - SLSA Level 1"
],
"justification": [],
"result_type": "PASSED"
"justification": [
"Failed to discover any witness provenance."
],
"result_type": "FAILED"
},
{
"check_id": "mcn_version_control_system_1",
Expand Down

0 comments on commit d234c27

Please sign in to comment.