Skip to content

Commit 48d5101

Browse files
waleedlatif1claude
andauthored
fix(ci): replace dynamic secret access with explicit secret references (#4151)
* fix(ci): replace dynamic secret access with explicit secret references Resolves CodeQL "Excessive Secrets Exposure" warning by replacing secrets[matrix.ecr_repo_secret] with conditional expressions that reference only the specific secrets needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ci): add explicit ECR_REALTIME guard and use env block for secret injection - Prevent silent fallthrough to ECR_REALTIME for unrecognized secret keys - Move build-amd64 secret resolution to env: block matching build-dev pattern --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9c1b0bc commit 48d5101

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,20 @@ jobs:
8888
- name: Set up Docker Buildx
8989
uses: useblacksmith/setup-docker-builder@v1
9090

91+
- name: Resolve ECR repo name
92+
id: ecr-repo
93+
run: echo "name=$ECR_REPO" >> $GITHUB_OUTPUT
94+
env:
95+
ECR_REPO: ${{ matrix.ecr_repo_secret == 'ECR_APP' && secrets.ECR_APP || matrix.ecr_repo_secret == 'ECR_MIGRATIONS' && secrets.ECR_MIGRATIONS || matrix.ecr_repo_secret == 'ECR_REALTIME' && secrets.ECR_REALTIME || '' }}
96+
9197
- name: Build and push
9298
uses: useblacksmith/build-push-action@v2
9399
with:
94100
context: .
95101
file: ${{ matrix.dockerfile }}
96102
platforms: linux/amd64
97103
push: true
98-
tags: ${{ steps.login-ecr.outputs.registry }}/${{ secrets[matrix.ecr_repo_secret] }}:dev
104+
tags: ${{ steps.login-ecr.outputs.registry }}/${{ steps.ecr-repo.outputs.name }}:dev
99105
provenance: false
100106
sbom: false
101107

@@ -155,11 +161,17 @@ jobs:
155161
- name: Set up Docker Buildx
156162
uses: useblacksmith/setup-docker-builder@v1
157163

164+
- name: Resolve ECR repo name
165+
id: ecr-repo
166+
run: echo "name=$ECR_REPO" >> $GITHUB_OUTPUT
167+
env:
168+
ECR_REPO: ${{ matrix.ecr_repo_secret == 'ECR_APP' && secrets.ECR_APP || matrix.ecr_repo_secret == 'ECR_MIGRATIONS' && secrets.ECR_MIGRATIONS || matrix.ecr_repo_secret == 'ECR_REALTIME' && secrets.ECR_REALTIME || '' }}
169+
158170
- name: Generate tags
159171
id: meta
160172
run: |
161173
ECR_REGISTRY="${{ steps.login-ecr.outputs.registry }}"
162-
ECR_REPO="${{ secrets[matrix.ecr_repo_secret] }}"
174+
ECR_REPO="${{ steps.ecr-repo.outputs.name }}"
163175
GHCR_IMAGE="${{ matrix.ghcr_image }}"
164176
165177
if [ "${{ github.ref }}" = "refs/heads/main" ]; then

0 commit comments

Comments
 (0)