Skip to content

Commit 1f566a0

Browse files
authored
Add docker login for daily scan workflow image scanning (#451)
*Description of changes:* Python 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 a51b226 commit 1f566a0

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/actions/artifacts_build/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,5 @@ runs:
104104
uses: ./.github/actions/image_scan
105105
with:
106106
image-ref: ${{ inputs.image_uri_with_tag }}
107-
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
107+
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
108+
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,25 @@ jobs:
7777
if: ${{ steps.dep_scan.outcome != 'success' }}
7878
run: less dependency-check-report.html
7979

80+
- name: Configure AWS credentials for image scan
81+
uses: aws-actions/configure-aws-credentials@v4
82+
with:
83+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
84+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
85+
86+
- name: Login to Public ECR
87+
uses: docker/login-action@v3
88+
with:
89+
registry: public.ecr.aws
90+
8091
- name: Perform high image scan
8192
if: always()
8293
id: high_scan
8394
uses: ./.github/actions/image_scan
8495
with:
8596
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.10.1"
8697
severity: 'CRITICAL,HIGH'
98+
logout: 'false'
8799

88100
- name: Perform low image scan
89101
if: always()
@@ -92,6 +104,7 @@ jobs:
92104
with:
93105
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.10.1"
94106
severity: 'MEDIUM,LOW,UNKNOWN'
107+
logout: 'false'
95108

96109
- name: Configure AWS Credentials for emitting metrics
97110
if: always()

0 commit comments

Comments
 (0)