Skip to content

Commit d471c70

Browse files
authored
Add docker login for daily scan workflow image scanning (#1144)
*Description of changes:* The current daily scan's image scan workflow would often fail with the following error: ``` 2025-08-12T22:35:36Z INFO [vuln] Vulnerability scanning is enabled 2025-08-12T22:35:36Z INFO [secret] Secret scanning is enabled 2025-08-12T22:35:36Z INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning 2025-08-12T22:35:36Z INFO [secret] Please see also https://trivy.dev/v0.64/docs/scanner/secret#recommendation for faster secret detection 📣 Notices: - Version 0.65.0 of Trivy is now available, current version is 0.64.1 To suppress version checks, run Trivy scans with the --skip-version-check flag 2025-08-12T22:35:37Z FATAL Fatal error run error: image scan error: scan error: unable to initialize a scan service: unable to initialize an image scan service: unable to find the specified image "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v2.11.1" in ["docker" "containerd" "podman" "remote"]: 4 errors occurred: * docker error: unable to inspect the image (public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v2.11.1): Error response from daemon: No such image: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v2.11.1 * containerd error: failed to list images from containerd client: connection error: desc = "transport: Error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied" * podman error: unable to initialize Podman client: no podman socket found: stat /run/user/1001/podman/podman.sock: no such file or directory * remote error: GET https://public.ecr.aws/v2/aws-observability/adot-autoinstrumentation-java/manifests/sha256:7ebd362ec33ad1fa0218535540cec4db3165364fe0715b892e90afdf2374b531: TOOMANYREQUESTS: Rate exceeded ``` Turns out the issue is related to making unauthenticated GET request calls to public ECR images. We make these calls both in the `pr_build` (explanation can be found in the code comment) and in `owasp.yml`. Likely, our GET requests to pull the ADOT image are being throttled as a result. https://github.com/aws-observability/aws-otel-java-instrumentation/blob/7ffb3d4f9200b10f7701926ff240dd5c0b36d136/.github/actions/image_scan/action.yml#L24 - Adding an intermediary step to log-in to ECR before making the GET request calls for `owasp.yml` image scanning. **Testing** 200 Image Scan test runs with docker login (0 failed jobs): https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/16922020570/job/47950156083 200 Image Scan test runs w/o docker login (1 failed job, rest didn't run): https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/16922512730/job/47951639594 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3f34807 commit d471c70

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.github/actions/image_scan/action.yml

Lines changed: 6 additions & 0 deletions
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

.github/workflows/owasp.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,25 @@ jobs:
7878
if: ${{ steps.dep_scan.outcome != 'success' }}
7979
run: less dependency-check-report.html
8080

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

89101
- name: Perform low image scan on v1
90102
if: always()
@@ -93,6 +105,7 @@ jobs:
93105
with:
94106
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v1.33.0"
95107
severity: 'MEDIUM,LOW,UNKNOWN'
108+
logout: 'false'
96109

97110
- name: Perform high image scan on v2
98111
if: always()
@@ -101,6 +114,7 @@ jobs:
101114
with:
102115
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v2.11.2"
103116
severity: 'CRITICAL,HIGH'
117+
logout: 'false'
104118

105119
- name: Perform low image scan on v2
106120
if: always()
@@ -109,6 +123,7 @@ jobs:
109123
with:
110124
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v2.11.2"
111125
severity: 'MEDIUM,LOW,UNKNOWN'
126+
logout: 'false'
112127

113128
- name: Configure AWS Credentials for emitting metrics
114129
if: always()

.github/workflows/pr-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ jobs:
147147
with:
148148
image-ref: ${{ env.TEST_TAG }}
149149
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
150+
logout: 'true'
150151

151152
- name: Test docker image
152153
if: ${{ matrix.os == 'ubuntu-latest' }}

0 commit comments

Comments
 (0)