Skip to content

Commit 8b63356

Browse files
authored
Added attest of approval to kosli (#27)
* Added attestation of approval * Added custom type schema
1 parent 4a03793 commit 8b63356

File tree

3 files changed

+108
-19
lines changed

3 files changed

+108
-19
lines changed

.github/workflows/build-deploy-backend.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ jobs:
139139
- name: Debug
140140
run: |
141141
echo "### Approval Actor for stage: ${{ steps.get-approver.outputs.approver }}" >> $GITHUB_STEP_SUMMARY
142-
cat ${{ steps.get-approver.outputs.approval-json-file }} >> $GITHUB_STEP_SUMMARY
143142
144143
semver-tag:
145144
needs: [build,deploy-stage]
@@ -210,7 +209,7 @@ jobs:
210209
secrets: inherit
211210

212211
get-approver-for-production:
213-
needs: deploy-production
212+
needs: [setup, deploy-production]
214213
runs-on: ubuntu-latest
215214
steps:
216215
- uses: actions/checkout@v4
@@ -221,4 +220,14 @@ jobs:
221220
with:
222221
gh-audit-log-reader-token: ${{ secrets.READ_AUDIT_LOG }}
223222

224-
223+
- name: Report approval to kosli
224+
run: |
225+
kosli attest custom \
226+
--type=approval-github-workflow \
227+
--name release-approval \
228+
--flow ${{ env.KOSLI_FLOW }} \
229+
--trail ${{ needs.setup.outputs.kosli-trail }} \
230+
--attestation-data ${{ steps.get-approver.outputs.approval-json-file }} \
231+
--annotate Approver="${{ steps.get-approver.outputs.approver }}"
232+
233+
echo "### Approval Actor for production: ${{ steps.get-approver.outputs.approver }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/setup-kosli.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,11 @@ jobs:
3333
--template-file kosli-flow-templates/backend-template.yml
3434

3535

36-
# ### Custom attestation types ###
37-
# - name: Create veracode-scan-executed attestation type
38-
# run:
39-
# kosli create attestation-type veracode-scan-executed
40-
# --description "Attest that veracode scan was executed"
41-
# --schema custom-attestation-types/veracode-scan-schema.json
42-
# --jq '.scan_status == "SUCCESS"'
43-
#
44-
# - name: Create veracode-scan-vulnerability-summary attestation type
45-
# run:
46-
# kosli create attestation-type veracode-scan-vulnerability-summary
47-
# --description "Attest that veracode scan has no vulnerabilities"
48-
# --schema custom-attestation-types/veracode-scan-schema.json
49-
# --jq '.scan_status == "SUCCESS"'
50-
# --jq 'all(.severity_summary[]; . == 0)'
51-
# --jq 'all(.gob_summary[]; . == 0)'
36+
### Custom attestation types ###
37+
- name: Create approval-github-workflow attestation type
38+
run:
39+
kosli create attestation-type approval-github-workflow
40+
--description "Approval from GitHub workflow"
41+
--schema custom-attestation-types/approval-github-workflow.yml
42+
--jq '.action == "workflows.approve_workflow_job"'
43+
--jq '.actor != ""'
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "GitHub Audit Log Approval Entry",
4+
"type": "object",
5+
"properties": {
6+
"@timestamp": {
7+
"type": "integer",
8+
"description": "Timestamp in milliseconds since epoch"
9+
},
10+
"_document_id": {
11+
"type": "string"
12+
},
13+
"action": {
14+
"type": "string",
15+
"enum": ["workflows.approve_workflow_job"]
16+
},
17+
"actor": {
18+
"type": "string"
19+
},
20+
"actor_id": {
21+
"type": "integer"
22+
},
23+
"actor_is_bot": {
24+
"type": "boolean"
25+
},
26+
"business": {
27+
"type": "string"
28+
},
29+
"business_id": {
30+
"type": "integer"
31+
},
32+
"created_at": {
33+
"type": "integer",
34+
"description": "Timestamp in milliseconds since epoch"
35+
},
36+
"operation_type": {
37+
"type": "string",
38+
"enum": ["modify"]
39+
},
40+
"org": {
41+
"type": "string"
42+
},
43+
"org_id": {
44+
"type": "integer"
45+
},
46+
"public_repo": {
47+
"type": "boolean"
48+
},
49+
"repo": {
50+
"type": "string"
51+
},
52+
"repo_id": {
53+
"type": "integer"
54+
},
55+
"request_access_security_header": {
56+
"type": ["string", "null"]
57+
},
58+
"run_number": {
59+
"type": "integer"
60+
},
61+
"user_agent": {
62+
"type": "string"
63+
},
64+
"workflow_run_id": {
65+
"type": "integer"
66+
}
67+
},
68+
"required": [
69+
"@timestamp",
70+
"_document_id",
71+
"action",
72+
"actor",
73+
"actor_id",
74+
"actor_is_bot",
75+
"business",
76+
"business_id",
77+
"created_at",
78+
"operation_type",
79+
"org",
80+
"org_id",
81+
"public_repo",
82+
"repo",
83+
"repo_id",
84+
"run_number",
85+
"user_agent",
86+
"workflow_run_id"
87+
]
88+
}

0 commit comments

Comments
 (0)