Conversation
| workspace: TF_WORKSPACE_APPS | ||
| env: | ||
| TF_WORKSPACE: ${{ matrix.workspace }} | ||
| TF_WORKSPACE: ${{ secrets[matrix.workspace] }} |
Check warning
Code scanning / CodeQL
Excessive Secrets Exposure Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
In general, the fix is to avoid dynamically indexing into secrets and instead reference only the specific secrets that are required, using static names. For matrix workflows, that usually means either (1) mapping each matrix entry to a concrete secret name and using conditionals or distinct jobs, or (2) if the value is not truly secret, storing it in a non‑secret context like vars or the matrix definition itself.
For this workflow, TF_WORKSPACE appears to be a Terraform Cloud workspace identifier, not a secret. The cleanest fix that does not change behavior is:
- Move the workspace values from secrets into non‑secret configuration (the matrix itself).
- Set
TF_WORKSPACEdirectly from the matrix value instead of fromsecrets[...].
Concretely, within .github/workflows/run-apply.yml:
- Change the
matrix.includeentries so thatworkspacecontains the actual Terraform Cloud workspace name (e.g.,coreandapps, or whatever the current secret values are) instead of the names of secrets. - Update the
envblock to setTF_WORKSPACE: ${{ matrix.workspace }}instead ofTF_WORKSPACE: ${{ secrets[matrix.workspace] }}.
This removes the dynamic secret access and ensures the runner only receives the explicitly referenced secrets (TF_API_TOKEN and TF_ORGANIZATION), preserving existing functionality of choosing a workspace per matrix entry.
| @@ -23,11 +23,11 @@ | ||
| matrix: | ||
| include: | ||
| - name: core | ||
| workspace: TF_WORKSPACE_CORE | ||
| workspace: core | ||
| - name: apps | ||
| workspace: TF_WORKSPACE_APPS | ||
| workspace: apps | ||
| env: | ||
| TF_WORKSPACE: ${{ secrets[matrix.workspace] }} | ||
| TF_WORKSPACE: ${{ matrix.workspace }} | ||
| CONFIG_DIRECTORY: "./" | ||
|
|
||
| steps: |
No description provided.