Skip to content

Commit 2542e36

Browse files
blink1073alcaeus
andauthored
Add full-report convenience action (#34)
Co-authored-by: Andreas Braun <git@alcaeus.org>
1 parent 7edc545 commit 2542e36

File tree

10 files changed

+163
-52
lines changed

10 files changed

+163
-52
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,46 @@ working directory.
192192
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
193193
```
194194

195+
### Compliance Report
196+
197+
This action will generate the SSDLC compliance report in the `S3_ASSETS` folder,
198+
called `ssdlc_compliance_report.md`.
199+
200+
```yaml
201+
- name: Setup
202+
uses: mongodb-labs/drivers-github-tools/setup@v2
203+
with:
204+
...
205+
206+
- name: Generate compliance report
207+
uses: mongodb-labs/drivers-github-tools/compliance-report@v2
208+
```
209+
210+
There are several ways to specify the security report:
211+
- By specifying an absolute URL starting with https
212+
- By specifying a relative path, which is then linked to the corresponding git blob for the tagged version
213+
- By adding the `security-report-url` to the AWS Secrets Vault
214+
215+
## Full Report
216+
217+
This action is a convenience function to handle all of the SSDLC reports and put them
218+
in the `S3_ASSETS` folder. This composite action runs the `authorized-pub`, `sbom`, `code-scanning-export`, and `compliance-report` actions.
219+
220+
```yaml
221+
- name: Setup
222+
uses: mongodb-labs/drivers-github-tools/setup@v2
223+
with:
224+
...
225+
226+
- name: Generate SSDLC Reports
227+
uses: mongodb-labs/drivers-github-tools/full-report@v2
228+
with:
229+
product_name: winkerberos
230+
release_version: ${{ inputs.version }}
231+
silk_asset_group: winkerberos
232+
dist_filenames: dist/*
233+
```
234+
195235
## Upload S3 assets
196236

197237
A number of scripts create files in the `tmp/s3_assets` folder, which then can

authorized-pub/action.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,35 @@ inputs:
99
required: true
1010
filenames:
1111
description: Artifact filename(s) to include in the report, can be a glob pattern
12-
required: true
12+
default: ""
1313
token:
1414
description: The GitHub token for the action
15-
required: true
1615

1716
runs:
1817
using: composite
1918
steps:
2019
- name: Prepare report
2120
shell: bash
2221
run: |
23-
export GH_TOKEN=${{ inputs.token }}
22+
if [ -n "${{ inputs.token }}" ]; then
23+
export GH_TOKEN=${{ inputs.token }}
24+
fi
2425
NAME=$(gh api users/${{ github.actor }} --jq '.name')
2526
export REPORT=$S3_ASSETS/authorized-publication.txt
26-
echo "Product: ${{ inputs.product_name }}" > $REPORT
27-
echo "Version: ${{ inputs.release_version }}" >> $REPORT
28-
echo "Releaser: $NAME" >> $REPORT
29-
echo "Build Source: GitHub Actions"
30-
echo "Build Number: ${{ github.run_id }}"
31-
for filename in ${{ inputs.filenames }}; do
32-
SHA=$(shasum -a 256 $filename | awk '{print $1;}')
33-
echo "Filename: $filename" >> $REPORT
34-
echo "Shasum: $SHA" >> $REPORT
35-
done
27+
export FILENAMES=${{ inputs.filenames }}
28+
cat << EOF > $REPORT
29+
Product: ${{ inputs.product_name }}
30+
Version: ${{ inputs.release_version }}
31+
Releaser: $NAME
32+
Build Source: GitHub Actions
33+
Build Number: ${{ github.run_id }}
34+
EOF
35+
if [ -z "$FILENAMES" ]; then
36+
echo "No published artifacts." >> $REPORT
37+
else
38+
for filename in ${{ inputs.filenames }}; do
39+
SHA=$(shasum -a 256 $filename | awk '{print $1;}')
40+
echo "Filename: $filename" >> $REPORT
41+
echo "Shasum: $SHA" >> $REPORT
42+
done
43+
fi

compliance-report/action.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Generate a compliance report
22
description: Generates the compliance report in the S3_ASSETS folder
33
inputs:
4-
token:
5-
description: The GitHub token for the action
6-
required: true
74
sbom_name:
85
description: The name of the SBOM file in the S3 bucket
96
default: cyclonedx.sbom.json
@@ -13,16 +10,23 @@ inputs:
1310
authorized_pub_name:
1411
description: The name of the Authorized Publication file in the S3 bucket
1512
default: authorized-publication.txt
13+
security_report_location:
14+
description: The URL or relative git path to the security report
15+
release_version:
16+
description: The published version
17+
token:
18+
description: The GitHub token for the action
1619
runs:
1720
using: composite
1821
steps:
1922
- name: Generate Compliance Report
2023
shell: bash
21-
run: |
22-
set -eux
23-
export GH_TOKEN=${{ inputs.token }}
24-
export RELEASE_CREATOR=$(gh api users/${{ github.actor }} --jq '.name')
25-
export SBOM_NAME=${{ inputs.sbom_name }}
26-
export SARIF_NAME=${{ inputs.sarif_name }}
27-
export AUTHORIZED_PUB_NAME=${{ inputs.authorized_pub_name }}
28-
bash ${{ github.action_path }}/generate.sh
24+
env:
25+
TOKEN: ${{ inputs.token }}
26+
SBOM_NAME: ${{ inputs.sbom_name }}
27+
SARIF_NAME: ${{ inputs.sarif_name }}
28+
AUTHORIZED_PUB_NAME: ${{ inputs.authorized_pub_name }}
29+
SECURITY_REPORT_LOCATION: ${{ inputs.security_report_location }}
30+
RELEASE_VERSION: ${{ inputs.release_version }}
31+
working-directory: "${{ github.action_path }}"
32+
run: ./generate.sh

compliance-report/generate.sh

100644100755
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22

33
set -eux
44

5-
cat << EOF >> ${S3_ASSETS}/ssdlc_compliance_report.md
5+
# Get release creator.
6+
cd $GITHUB_WORKSPACE
7+
if [ -n "$TOKEN" ]; then
8+
export GH_TOKEN=$TOKEN
9+
fi
10+
RELEASE_CREATOR=$(gh api users/${GITHUB_ACTOR} --jq '.name')
11+
12+
# Handle security report.
13+
SECURITY_REPORT="N/A"
14+
if [ -n "$SECURITY_REPORT_LOCATION" ]; then
15+
if [[ $SECURITY_REPORT_LOCATION == https* ]]; then
16+
SECURITY_REPORT="See $SECURITY_REPORT_LOCATION"
17+
else
18+
SECURITY_REPORT="See https://github.com/$GITHUB_REPOSITORY/blob/$RELEASE_VERSION/$SECURITY_REPORT_LOCATION"
19+
fi
20+
elif [ -n "$SECURITY_REPORT_URL" ]; then
21+
SECURITY_REPORT="See $SECURITY_REPORT_URL"
22+
fi
23+
24+
cat << EOF >> ${S3_ASSETS}/ssdlc_compliance_report.txt
625
Release Creator
726
${RELEASE_CREATOR}
827
@@ -18,6 +37,9 @@ See ${SARIF_NAME}
1837
Signature Information
1938
See ${AUTHORIZED_PUB_NAME}
2039
40+
Security Report
41+
${SECURITY_REPORT}
42+
2143
Known Vulnerabilities
2244
Any vulnerabilities that may be shown in the files referenced above have been reviewed and accepted by the appropriate approvers.
23-
EOF
45+
EOF

full-report/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Generate Full Report
2+
description: Generate all reports to be uploaded to release bucket
3+
inputs:
4+
product_name:
5+
description: The name of the product
6+
required: true
7+
release_version:
8+
description: The published version
9+
required: true
10+
silk_asset_group:
11+
description: The Silk Asset Group for the Project
12+
required: true
13+
security_report_location:
14+
description: The URL or relative git path to the security report
15+
dist_filenames:
16+
description: The distribution filename or glob pattern
17+
token:
18+
description: The GitHub access token
19+
20+
runs:
21+
using: composite
22+
steps:
23+
- name: Generate Authorized Publication Report
24+
uses: blink1073/drivers-github-tools/authorized-pub@full-report
25+
with:
26+
product_name: ${{ inputs.product_name }}
27+
release_version: ${{ inputs.release_version }}
28+
filenames: ${{ inputs.dist_filenames }}
29+
token: ${{ inputs.token }}
30+
- name: Generate SBOM File
31+
uses: mongodb-labs/drivers-github-tools/sbom@v2
32+
with:
33+
silk_asset_group: ${{ inputs.silk_asset_group }}
34+
- name: Generate Sarif File
35+
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
36+
with:
37+
ref: ${{ inputs.release_version }}
38+
output-file: ${{ env.S3_ASSETS }}/code-scanning-alerts.json
39+
- name: Generate Compliance Report
40+
uses: blink1073/drivers-github-tools/compliance-report@full-report
41+
with:
42+
release_version: ${{ inputs.release_version }}
43+
security_report_location: ${{ inputs.security_report_location }}
44+
token: ${{ inputs.token }}

python/publish/action.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ inputs:
1919
required: true
2020
token:
2121
description: "The GitHub access token"
22-
required: true
2322
dry_run:
2423
description: "Whether this is a dry run"
2524
required: true
@@ -39,24 +38,18 @@ runs:
3938
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
4039
with:
4140
filenames: dist/*
42-
- uses: mongodb-labs/drivers-github-tools/authorized-pub@v2
41+
- uses: blink1073/drivers-github-tools/full-report@full-report
4342
with:
4443
product_name: ${{ inputs.product_name }}
4544
release_version: ${{ inputs.version }}
46-
filenames: dist/*
47-
token: ${{ inputs.token }}
48-
- uses: mongodb-labs/drivers-github-tools/sbom@v2
49-
with:
45+
dist_filenames: dist/*
5046
silk_asset_group: ${{ inputs.silk_asset_group }}
51-
- name: Generate Sarif Report
52-
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
53-
with:
54-
ref: ${{ inputs.version }}
55-
- name: Generate Compliance Report
56-
uses: mongodb-labs/drivers-github-tools/compliance-report@v2
57-
with:
5847
token: ${{ inputs.token }}
59-
- name: Run publish script
48+
- uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
49+
with:
50+
version: ${{ inputs.version }}
51+
product_name: ${{ inputs.product_name }}
52+
- name: Run GitHub Publish script
6053
shell: bash
6154
run: ${{github.action_path}}/publish.sh
6255
env:

python/publish/publish.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22

33
set -eux
44

5-
cp $RELEASE_ASSETS/*.sig $S3_ASSETS
6-
mv code-scanning-alerts.json $S3_ASSETS
7-
85
if [ "$DRY_RUN" == "false" ]; then
9-
echo "Uploading Release Reports"
10-
TARGET=s3://${AWS_BUCKET}/${PRODUCT_NAME}/${VERSION}
11-
aws s3 cp $S3_ASSETS $TARGET --recursive
12-
136
echo "Creating draft release with attached files"
147
gh release create ${VERSION} --draft --verify-tag --title ${VERSION} --notes ""
158
gh release upload ${VERSION} $RELEASE_ASSETS/*.*
169
gh release view ${VERSION} >> $GITHUB_STEP_SUMMARY
1710
else
18-
echo "Dry run, not uploading to S3 or creating GitHub Release"
11+
echo "Dry run, not creating GitHub Release"
1912
ls -ltr $RELEASE_ASSETS
20-
ls -ltr $S3_ASSETS
2113
fi

setup/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ inputs:
1010
aws_secret_id:
1111
description: "The name of the aws secret to use"
1212
required: true
13+
artifactory_username:
14+
description: "The artifactory username to be used"
1315
artifactory_registry:
1416
description: "Artifactory registry to be used"
1517
default: artifactory.corp.mongodb.com
@@ -34,6 +36,7 @@ runs:
3436
id: setup
3537
run: ${{ github.action_path }}/setup.sh
3638
env:
39+
ARTIFACTORY_USERNAME_INPUT: ${{ inputs.artifactory_username }}
3740
ARTIFACTORY_REGISTRY: ${{ inputs.artifactory_registry }}
3841
ARTIFACTORY_IMAGE: ${{ inputs.artifactory_image }}
3942
AWS_SECRET_ID: ${{ inputs.aws_secret_id }}

setup/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ for var in $vars; do
1111
done
1212

1313
echo "::group::Set up artifactory"
14+
ARTIFACTORY_USERNAME=${ARTIFACTORY_USERNAME:-}
15+
if [ -n "${ARTIFACTORY_USERNAME_INPUT}" ]; then
16+
ARTIFACTORY_USERNAME=$ARTIFACTORY_USERNAME_INPUT
17+
fi
1418
echo $ARTIFACTORY_PASSWORD | podman login -u $ARTIFACTORY_USERNAME --password-stdin $ARTIFACTORY_REGISTRY
1519
echo "::endgroup::"
1620

@@ -47,6 +51,7 @@ SILKBOMB_ENVFILE=${SILKBOMB_ENVFILE:-}
4751
ARTIFACTORY_REGISTRY=$ARTIFACTORY_REGISTRY
4852
RELEASE_ASSETS=$RELEASE_ASSETS
4953
S3_ASSETS=$S3_ASSETS
54+
SECURITY_REPORT_URL=${SECURITY_REPORT_URL:-}
5055
EOF
5156

5257
echo "Set up git credentials"

tag-version/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ runs:
5151
shell: bash -eux {0}
5252
run: |
5353
if [ ${{ inputs.push_tag }} == "true" ]; then
54-
git push origin --tags
55-
echo "Pushed tag: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
54+
git push origin tag $TAG
55+
echo "Pushed tag: ${{ env.TAG }}" >> $GITHUB_STEP_SUMMARY
5656
else
57-
echo "Created tag (no push): ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
57+
echo "Created tag (no push): ${{ env.Tag }}" >> $GITHUB_STEP_SUMMARY
5858
fi

0 commit comments

Comments
 (0)