Skip to content

Commit b8cabda

Browse files
authored
[DPE-5350][DPE-5416] Add sbom generation in CI (#107)
1 parent 11ea444 commit b8cabda

File tree

3 files changed

+73
-11
lines changed

3 files changed

+73
-11
lines changed

.github/workflows/trivy.yml

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ on:
33
push:
44
branches:
55
- 3.4-22.04/edge
6+
- dpe-5350-3.4 # tmp to test new action.
67
pull_request:
78
jobs:
89
build:
910
uses: ./.github/workflows/build.yaml
1011
scan:
11-
name: Trivy scan
12+
name: Trivy scan and sbom generation
1213
needs: build
1314
runs-on: ubuntu-20.04
1415
steps:
@@ -46,4 +47,22 @@ jobs:
4647
uses: github/codeql-action/upload-sarif@v2
4748
if: always()
4849
with:
49-
sarif_file: 'trivy-results.sarif'
50+
sarif_file: 'trivy-results.sarif'
51+
52+
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
53+
uses: aquasecurity/[email protected]
54+
with:
55+
scan-type: 'image'
56+
format: 'spdx-json'
57+
output: 'dependency-results.sbom.json'
58+
image-ref: 'trivy/charmed-spark:test'
59+
github-pat: ${{ secrets.GITHUB_TOKEN }}
60+
severity: "MEDIUM,HIGH,CRITICAL"
61+
scanners: "vuln"
62+
63+
- name: Upload trivy report as a Github artifact
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: trivy-sbom-report
67+
path: '${{ github.workspace }}/dependency-results.sbom.json'
68+
retention-days: 90

tests/integration/setup-aws-cli.sh

+32-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,41 @@
22

33
# Install AWS CLI
44
sudo snap install aws-cli --classic
5-
5+
set -x
66

77
get_s3_endpoint(){
8-
# Get S3 endpoint from MinIO
9-
kubectl get service minio -n minio-operator -o jsonpath='{.spec.clusterIP}'
8+
# Print the endpoint where the S3 bucket is exposed on.
9+
kubectl get service minio -n minio-operator -o jsonpath='{.spec.clusterIP}'
10+
}
11+
12+
13+
get_s3_access_key(){
14+
# Print the S3 Access Key by reading it from K8s secret or by outputting the default value
15+
kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null
16+
if [ $? -eq 0 ]; then
17+
# echo "Use access-key from secret"
18+
access_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d)
19+
else
20+
# echo "use default access-key"
21+
access_key="minio"
22+
fi
23+
echo "$access_key"
1024
}
1125

1226

27+
get_s3_secret_key(){
28+
# Print the S3 Secret Key by reading it from K8s secret or by outputting the default value
29+
kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null
30+
if [ $? -eq 0 ]; then
31+
# echo "Use access-key from secret"
32+
secret_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d)
33+
else
34+
# echo "use default access-key"
35+
secret_key="minio123"
36+
fi
37+
echo "$secret_key"
38+
}
39+
1340
wait_and_retry(){
1441
# Retry a command for a number of times by waiting a few seconds.
1542

@@ -37,8 +64,8 @@ wait_and_retry get_s3_endpoint
3764

3865
S3_ENDPOINT=$(get_s3_endpoint)
3966
DEFAULT_REGION="us-east-2"
40-
ACCESS_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d)
41-
SECRET_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d)
67+
ACCESS_KEY=$(get_s3_access_key)
68+
SECRET_KEY=$(get_s3_secret_key)
4269

4370
# Configure AWS CLI credentials
4471
aws configure set aws_access_key_id $ACCESS_KEY

tests/integration/utils/s3-utils.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,30 @@ get_s3_endpoint(){
2020

2121

2222
get_s3_access_key(){
23-
# Print the S3 Access Key by reading it from K8s secret
24-
kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d
23+
# Print the S3 Access Key by reading it from K8s secret or by outputting the default value
24+
kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null
25+
if [ $? -eq 0 ]; then
26+
# echo "Use access-key from secret"
27+
access_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d)
28+
else
29+
# echo "use default access-key"
30+
access_key="minio"
31+
fi
32+
echo "$access_key"
2533
}
2634

2735

2836
get_s3_secret_key(){
29-
# Print the S3 Secret Key by reading it from K8s secret
30-
kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d
37+
# Print the S3 Secret Key by reading it from K8s secret or by outputting the default value
38+
kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null
39+
if [ $? -eq 0 ]; then
40+
# echo "Use access-key from secret"
41+
secret_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d)
42+
else
43+
# echo "use default access-key"
44+
secret_key="minio123"
45+
fi
46+
echo "$secret_key"
3147
}
3248

3349

0 commit comments

Comments
 (0)