Skip to content

Commit 43d7436

Browse files
authored
Add docker login for daily scan workflow image scanning (#247)
*Description of changes:* JavaScript version of this PR: aws-observability/aws-otel-java-instrumentation#1144 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent f09106e commit 43d7436

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/actions/artifacts_build/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,5 @@ runs:
103103
uses: ./.github/actions/image_scan
104104
with:
105105
image-ref: ${{ inputs.image_uri_with_tag }}
106-
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
106+
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
107+
logout: 'true'

.github/actions/image_scan/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ inputs:
1111
severity:
1212
required: true
1313
description: "List of severities that will cause a failure"
14+
logout:
15+
required: true
16+
description: |
17+
Whether to logout of public AWS ECR. Set to 'true' for PR workflows to avoid potential call failures,
18+
'false' for daily scans which has a higher bar for passing regularly and specifically wants to sign in.
1419
1520
runs:
1621
using: "composite"
@@ -22,6 +27,7 @@ runs:
2227
# ensure we can make unauthenticated call. This is important for making the pr_build workflow run on
2328
# PRs created from forked repos.
2429
- name: Logout of public AWS ECR
30+
if: inputs.logout == 'true'
2531
shell: bash
2632
run: docker logout public.ecr.aws
2733

@@ -30,4 +36,4 @@ runs:
3036
with:
3137
image-ref: ${{ inputs.image-ref }}
3238
severity: ${{ inputs.severity }}
33-
exit-code: '1'
39+
exit-code: '1'

.github/workflows/daily-scan.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,35 @@ jobs:
6666
- name: Print dependency scan results on failure
6767
if: ${{ steps.dep_scan.outcome != 'success' }}
6868
run: less dependency-check-report.html
69+
70+
- name: Configure AWS credentials for image scan
71+
uses: aws-actions/configure-aws-credentials@v4
72+
with:
73+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
74+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
75+
76+
- name: Login to Public ECR
77+
uses: docker/login-action@v3
78+
with:
79+
registry: public.ecr.aws
6980

70-
# TODO: Update image to public once available
7181
- name: Perform high image scan
7282
if: always()
7383
id: high_scan
7484
uses: ./.github/actions/image_scan
7585
with:
7686
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-node:v0.7.0"
7787
severity: 'CRITICAL,HIGH'
88+
logout: 'false'
7889

79-
# TODO: Update image to public once available
8090
- name: Perform low image scan
8191
if: always()
8292
id: low_scan
8393
uses: ./.github/actions/image_scan
8494
with:
8595
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-node:v0.7.0"
8696
severity: 'MEDIUM,LOW,UNKNOWN'
97+
logout: 'false'
8798

8899
- name: Configure AWS Credentials for emitting metrics
89100
if: always()

0 commit comments

Comments
 (0)