Skip to content

Commit 1e6c61d

Browse files
committed
chore: fix integration tests and improve check tree display in the HTML report
1 parent 7cdd82e commit 1e6c61d

File tree

4 files changed

+67
-77
lines changed

4 files changed

+67
-77
lines changed

scripts/dev_scripts/integration_tests.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@ do
289289
check_or_update_expected_output $COMPARE_JSON_OUT $JSON_RESULT_DIR/$i $JSON_EXPECT_DIR/$i || log_fail
290290
done
291291

292+
echo -e "\n----------------------------------------------------------------------------------"
293+
echo "micronaut-projects/micronaut-test: Analyzing the repo path when automatic dependency resolution is skipped"
294+
echo "and all provenance checks are excluded."
295+
echo -e "----------------------------------------------------------------------------------\n"
296+
JSON_RESULT=$WORKSPACE/output/reports/github_com/micronaut-projects/micronaut-test/micronaut-test.json
297+
JSON_EXPECTED=$WORKSPACE/tests/e2e/expected_results/micronaut-test/micronaut-test_provenance_checks_excluded.json
298+
DEFAULTS_FILE=$WORKSPACE/tests/e2e/configurations/exclude_provenance_checks.ini
299+
300+
$RUN_MACARON -dp $DEFAULTS_FILE analyze -rp https://github.com/micronaut-projects/micronaut-test/ -d 7679d10b4073a3b842b6c56877c35fa8cd10acff --skip-deps || log_fail
301+
302+
check_or_update_expected_output $COMPARE_JSON_OUT $JSON_RESULT $JSON_EXPECTED || log_fail
303+
292304
# TODO: uncomment the test below after resolving https://github.com/oracle/macaron/issues/60.
293305
# echo -e "\n----------------------------------------------------------------------------------"
294306
# echo "micronaut-projects/micronaut-test: Check the resolved dependency output with config for cyclonedx gradle plugin (default)."
@@ -569,7 +581,7 @@ rm -rf "$SOURCE_REPO"
569581
rm -rf "$TARGET_REPO"
570582

571583
echo -e "\n----------------------------------------------------------------------------------"
572-
echo "Test running the analysis with all checks excluded."
584+
echo "Running the analysis with all checks excluded should returns an error code."
573585
echo -e "----------------------------------------------------------------------------------\n"
574586
$RUN_MACARON -dp tests/e2e/configurations/exclude_all_checks.ini analyze -rp https://github.com/apache/maven --skip-deps
575587

@@ -626,18 +638,6 @@ then
626638
log_fail
627639
fi
628640

629-
echo -e "\n----------------------------------------------------------------------------------"
630-
echo "slsa-framework/slsa-verifier: Analyzing the repo path when automatic dependency resolution is skipped"
631-
echo "and provenance checks are excluded."
632-
echo -e "----------------------------------------------------------------------------------\n"
633-
JSON_RESULT=$WORKSPACE/output/reports/github_com/slsa-framework/slsa-verifier/slsa-verifier.json
634-
JSON_EXPECTED=$WORKSPACE/tests/e2e/expected_results/slsa-verifier/slsa-verifier_provenance_checks_excluded.json
635-
DEFAULTS_FILE=$WORKSPACE/tests/e2e/configurations/exclude_provenance_checks.ini
636-
637-
$RUN_MACARON -dp $DEFAULTS_FILE analyze -rp https://github.com/slsa-framework/slsa-verifier -b main -d fc50b662fcfeeeb0e97243554b47d9b20b14efac --skip-deps || log_fail
638-
639-
check_or_update_expected_output $COMPARE_JSON_OUT $JSON_RESULT $JSON_EXPECTED || log_fail
640-
641641
# Testing the CUE provenance expectation verifier.
642642
echo -e "\n----------------------------------------------------------------------------------"
643643
echo "Test verifying CUE provenance expectation."

src/macaron/output_reporter/templates/base_template.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@
293293
display: inline-block;
294294
margin-right: 6px;
295295
}
296-
297-
.check-tree-node-excluded {
298-
text-decoration-line: line-through;
299-
}
300-
301-
.check-tree-node-excluded::before {
302-
content: "\2514";
303-
color: black;
304-
display: inline-block;
305-
margin-right: 6px;
306-
}
307-
308296
</style>
309297
</head>
310298

src/macaron/output_reporter/templates/macaron.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,24 +164,24 @@
164164
{% endcall %}
165165
{% endmacro %}
166166

167+
{#
168+
The `check-tree-node` class will add a small symbol before the check ID
169+
indicating a non-root node. Therefore, we don't apply it for the checks without
170+
parent (i.e the first level checks).
171+
#}
167172
{% macro render_run_checks(check_tree, run_checks) %}
168173
<ul class="tree-view-nested-list">
169-
{% for key, first_level in check_tree.items() %}
174+
{% for key, next_level in check_tree.items() recursive %}
170175
<li>
171-
<div>{{ key }}</div>
176+
<div
177+
class="{% if loop.depth0 != 0 %}check-tree-node{% endif %}"
178+
{% if key not in run_checks %}
179+
style="text-decoration-line: line-through;"
180+
{% endif %}>
181+
{{ key }}
182+
</div>
172183
<ul>
173-
{% for key, next_level in first_level.items() recursive %}
174-
<li>
175-
{% if key not in run_checks %}
176-
<div class="check-tree-node-excluded">{{ key }}</div>
177-
{% else %}
178-
<div class="check-tree-node">{{ key }}</div>
179-
{% endif %}
180-
<ul>
181-
{{ loop(next_level.items()) | indent(2 * 4) }}
182-
</ul>
183-
</li>
184-
{% endfor %}
184+
{{ loop(next_level.items()) | indent(2 * 4) }}
185185
</ul>
186186
</li>
187187
{% endfor %}

tests/e2e/expected_results/slsa-verifier/slsa-verifier_provenance_checks_excluded.json renamed to tests/e2e/expected_results/micronaut-test/micronaut-test_provenance_checks_excluded.json

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"metadata": {
3-
"timestamps": "2024-02-10 12:49:17",
3+
"timestamps": "2024-02-11 15:51:21",
44
"has_passing_check": true,
55
"run_checks": [
66
"mcn_infer_artifact_pipeline_1",
7-
"mcn_trusted_builder_level_three_1",
7+
"mcn_build_as_code_1",
88
"mcn_version_control_system_1",
99
"mcn_build_service_1",
1010
"mcn_build_script_1",
11-
"mcn_build_as_code_1"
11+
"mcn_trusted_builder_level_three_1"
1212
],
1313
"check_tree": {
1414
"mcn_version_control_system_1": {
@@ -30,12 +30,12 @@
3030
},
3131
"target": {
3232
"info": {
33-
"full_name": "pkg:github.com/slsa-framework/slsa-verifier@fc50b662fcfeeeb0e97243554b47d9b20b14efac",
34-
"local_cloned_path": "git_repos/github_com/slsa-framework/slsa-verifier",
35-
"remote_path": "https://github.com/slsa-framework/slsa-verifier",
36-
"branch": "main",
37-
"commit_hash": "fc50b662fcfeeeb0e97243554b47d9b20b14efac",
38-
"commit_date": "2022-10-04T01:00:02+00:00"
33+
"full_name": "pkg:github.com/micronaut-projects/micronaut-test@7679d10b4073a3b842b6c56877c35fa8cd10acff",
34+
"local_cloned_path": "git_repos/github_com/micronaut-projects/micronaut-test",
35+
"remote_path": "https://github.com/micronaut-projects/micronaut-test",
36+
"branch": null,
37+
"commit_hash": "7679d10b4073a3b842b6c56877c35fa8cd10acff",
38+
"commit_date": "2023-11-07T06:43:31+01:00"
3939
},
4040
"provenances": {
4141
"is_inferred": true,
@@ -47,23 +47,23 @@
4747
"predicateType": "https://slsa.dev/provenance/v0.2",
4848
"predicate": {
4949
"builder": {
50-
"id": "slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.2.0"
50+
"id": "https://github.com/micronaut-projects/micronaut-test/blob/7679d10b4073a3b842b6c56877c35fa8cd10acff/.github/workflows/gradle.yml"
5151
},
52-
"buildType": "Trusted github_actions",
52+
"buildType": "Custom github_actions",
5353
"invocation": {
5454
"configSource": {
55-
"uri": "https://github.com/slsa-framework/slsa-verifier@refs/heads/main",
55+
"uri": "https://github.com/micronaut-projects/micronaut-test@refs/heads/None",
5656
"digest": {
57-
"sha1": "fc50b662fcfeeeb0e97243554b47d9b20b14efac"
57+
"sha1": "7679d10b4073a3b842b6c56877c35fa8cd10acff"
5858
},
59-
"entryPoint": "https://github.com/slsa-framework/slsa-verifier/blob/fc50b662fcfeeeb0e97243554b47d9b20b14efac/.github/workflows/release.yml"
59+
"entryPoint": "https://github.com/micronaut-projects/micronaut-test/blob/7679d10b4073a3b842b6c56877c35fa8cd10acff/.github/workflows/gradle.yml"
6060
},
6161
"parameters": {},
6262
"environment": {}
6363
},
6464
"buildConfig": {
65-
"jobID": "<STRING>",
66-
"stepID": "<STRING>"
65+
"jobID": "build",
66+
"stepID": "\ud83d\udce6 Publish to Sonatype Snapshots"
6767
},
6868
"metadata": {
6969
"buildInvocationId": "",
@@ -85,14 +85,14 @@
8585
}
8686
}
8787
],
88-
"npm Registry": []
88+
"Maven Central Registry": []
8989
}
9090
},
9191
"checks": {
9292
"summary": {
9393
"DISABLED": 0,
94-
"FAILED": 1,
95-
"PASSED": 5,
94+
"FAILED": 2,
95+
"PASSED": 4,
9696
"SKIPPED": 0,
9797
"UNKNOWN": 0
9898
},
@@ -104,7 +104,12 @@
104104
"Build as code - SLSA Level 3"
105105
],
106106
"justification": [
107-
"Check mcn_build_as_code_1 is set to PASSED because mcn_trusted_builder_level_three_1 PASSED."
107+
{
108+
"The target repository uses build tool gradle to deploy": "https://github.com/micronaut-projects/micronaut-test/blob/7679d10b4073a3b842b6c56877c35fa8cd10acff/.github/workflows/gradle.yml",
109+
"The build is triggered by": "https://github.com/micronaut-projects/micronaut-test/blob/7679d10b4073a3b842b6c56877c35fa8cd10acff/.github/workflows/gradle.yml"
110+
},
111+
"Deploy command: ['./gradlew', 'publishToSonatype', 'docs', '--no-daemon']",
112+
"However, could not find a passing workflow run."
108113
],
109114
"result_type": "PASSED"
110115
},
@@ -130,23 +135,6 @@
130135
],
131136
"result_type": "PASSED"
132137
},
133-
{
134-
"check_id": "mcn_trusted_builder_level_three_1",
135-
"check_description": "Check whether the target uses a trusted SLSA level 3 builder.",
136-
"slsa_requirements": [
137-
"Hermetic - SLSA Level 4",
138-
"Isolated - SLSA Level 3",
139-
"Parameterless - SLSA Level 4",
140-
"Ephemeral environment - SLSA Level 3"
141-
],
142-
"justification": [
143-
{
144-
"Found trusted builder GitHub Actions: slsa-framework/slsa-github-generator/.github/workflows/[email protected] triggered by": "https://github.com/slsa-framework/slsa-verifier/blob/fc50b662fcfeeeb0e97243554b47d9b20b14efac/.github/workflows/release.yml"
145-
},
146-
"However, could not find a passing workflow run."
147-
],
148-
"result_type": "PASSED"
149-
},
150138
{
151139
"check_id": "mcn_version_control_system_1",
152140
"check_description": "Check whether the target repo uses a version control system.",
@@ -155,7 +143,7 @@
155143
],
156144
"justification": [
157145
{
158-
"This is a Git repository": "https://github.com/slsa-framework/slsa-verifier"
146+
"This is a Git repository": "https://github.com/micronaut-projects/micronaut-test"
159147
}
160148
],
161149
"result_type": "PASSED"
@@ -170,6 +158,20 @@
170158
"Unable to find a publishing timestamp for the artifact."
171159
],
172160
"result_type": "FAILED"
161+
},
162+
{
163+
"check_id": "mcn_trusted_builder_level_three_1",
164+
"check_description": "Check whether the target uses a trusted SLSA level 3 builder.",
165+
"slsa_requirements": [
166+
"Hermetic - SLSA Level 4",
167+
"Isolated - SLSA Level 3",
168+
"Parameterless - SLSA Level 4",
169+
"Ephemeral environment - SLSA Level 3"
170+
],
171+
"justification": [
172+
"Could not find a trusted level 3 builder as a GitHub Actions workflow."
173+
],
174+
"result_type": "FAILED"
173175
}
174176
]
175177
}

0 commit comments

Comments
 (0)