Skip to content

Commit f2e73da

Browse files
authored
Merge pull request #196 from LerianStudio/fix/coderabbit-pr195-review-findings
fix(security): address CodeRabbit PR#195 review findings
2 parents 34df442 + cca07e7 commit f2e73da

9 files changed

Lines changed: 25 additions & 15 deletions

File tree

.cursor/rules/reusable-workflows.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ runs-on: self-hosted
127127

128128
Every reusable workflow must:
129129
- support `workflow_call` (for external callers)
130-
- support `workflow_dispatch` (for manual testing)
131130
- expose explicit `inputs` — never rely on implicit context
131+
- **must NOT** include a `workflow_dispatch` trigger — if manual/interactive dispatch is needed, create a separate self-workflow under `.github/workflows/self-*`
132132
- **always include a `dry_run` input** (`type: boolean`, `default: false`) so the workflow can be safely tested before applying real changes
133133

134134
```yaml

.github/workflows/build.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ on:
123123
type: boolean
124124
default: false
125125
docker_build_args:
126-
description: 'Newline-separated Docker build arguments to pass to docker build (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api"). Forwarded to docker/build-push-action build-args.'
126+
description: 'Newline-separated Docker build arguments (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api"). For sensitive values (tokens, keys, passwords), use BuildKit secrets instead — build arguments are visible in image history.'
127127
type: string
128128
required: false
129129
default: ''
@@ -139,7 +139,6 @@ on:
139139
permissions:
140140
contents: read
141141
packages: write
142-
id-token: write
143142

144143
jobs:
145144
prepare:
@@ -208,6 +207,10 @@ jobs:
208207
if: needs.prepare.outputs.has_builds == 'true'
209208
runs-on: ${{ inputs.runner_type }}
210209
name: Build ${{ matrix.app.name }}
210+
permissions:
211+
contents: read
212+
packages: write
213+
id-token: write
211214
strategy:
212215
max-parallel: 2
213216
fail-fast: false
@@ -320,7 +323,7 @@ jobs:
320323
ENABLE_GHCR: ${{ inputs.enable_ghcr }}
321324
DOCKERHUB_ORG: ${{ inputs.dockerhub_org }}
322325
APP_NAME: ${{ matrix.app.name }}
323-
GHCR_ORG: ${{ steps.normalize.outputs.owner_lower }}
326+
GHCR_ORG: ${{ inputs.ghcr_org || steps.normalize.outputs.owner_lower }}
324327
run: |
325328
REFS=""
326329
@@ -341,7 +344,7 @@ jobs:
341344
342345
- name: Sign container images with cosign
343346
if: inputs.enable_cosign_sign
344-
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@feat/cosign-sign
347+
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@v1.23.0
345348
with:
346349
image-refs: ${{ steps.cosign-refs.outputs.refs }}
347350

.github/workflows/go-release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ on:
7575
permissions:
7676
contents: write
7777
packages: write
78-
id-token: write
7978

8079
jobs:
8180
release:
@@ -144,6 +143,10 @@ jobs:
144143
docker:
145144
name: Build and Push Docker Image
146145
runs-on: ${{ inputs.runner_type }}
146+
permissions:
147+
contents: read
148+
packages: write
149+
id-token: write
147150
needs: release
148151
if: inputs.enable_docker && startsWith(github.ref, 'refs/tags/v')
149152

@@ -194,7 +197,7 @@ jobs:
194197
195198
- name: Sign container images with cosign
196199
if: inputs.enable_cosign_sign
197-
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@feat/cosign-sign
200+
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@v1.23.0
198201
with:
199202
image-refs: ${{ steps.cosign-refs.outputs.refs }}
200203

.github/workflows/pr-security-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ on:
6868
type: boolean
6969
default: true
7070
docker_build_args:
71-
description: 'Newline-separated Docker build arguments to pass to docker build (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api"). Forwarded to docker/build-push-action build-args.'
71+
description: 'Newline-separated Docker build arguments (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api"). For sensitive values (tokens, keys, passwords), use BuildKit secrets instead — build arguments are visible in image history.'
7272
type: string
7373
required: false
7474
default: ''

.github/workflows/typescript-build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ on:
148148
permissions:
149149
contents: read
150150
packages: write
151-
id-token: write
152151

153152
jobs:
154153
prepare:
@@ -250,6 +249,10 @@ jobs:
250249
if: needs.prepare.outputs.has_builds == 'true'
251250
runs-on: ${{ inputs.runner_type }}
252251
name: Build ${{ matrix.app.name }}
252+
permissions:
253+
contents: read
254+
packages: write
255+
id-token: write
253256
strategy:
254257
max-parallel: 2
255258
fail-fast: false
@@ -333,7 +336,7 @@ jobs:
333336
334337
- name: Sign container images with cosign
335338
if: inputs.enable_cosign_sign && !inputs.dry_run && steps.cosign-refs.outputs.refs != ''
336-
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@feat/cosign-sign
339+
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@v1.23.0
337340
with:
338341
image-refs: ${{ steps.cosign-refs.outputs.refs }}
339342

docs/build-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ jobs:
225225

226226
```bash
227227
cosign verify \
228-
--certificate-identity-regexp=".*" \
228+
--certificate-identity-regexp="^https://github.com/LerianStudio/.*/.github/workflows/.*@refs/heads/.*$" \
229229
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
230230
docker.io/lerianstudio/my-app@sha256:abc123...
231231
```

docs/go-release-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ jobs:
204204

205205
```bash
206206
cosign verify \
207-
--certificate-identity-regexp=".*" \
207+
--certificate-identity-regexp="^https://github.com/LerianStudio/.*/.github/workflows/.*@refs/heads/.*$" \
208208
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
209209
ghcr.io/myorg/my-app@sha256:abc123...
210210
```

docs/typescript-build.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ on:
3737
permissions:
3838
contents: read
3939
packages: write
40+
id-token: write # required for cosign keyless signing
4041

4142
jobs:
4243
build:
@@ -230,7 +231,7 @@ jobs:
230231
231232
```bash
232233
cosign verify \
233-
--certificate-identity-regexp=".*" \
234+
--certificate-identity-regexp="^https://github.com/LerianStudio/.*/.github/workflows/.*@refs/heads/.*$" \
234235
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
235236
ghcr.io/lerianstudio/my-app@sha256:abc123...
236237
```

src/security/cosign-sign/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Sign container image
4747
uses: LerianStudio/github-actions-shared-workflows/src/security/cosign-sign@v1.x.x
4848
with:
49-
image-refs: myorg/myapp@${{ steps.build-push.outputs.digest }}
49+
image-refs: docker.io/myorg/myapp@${{ steps.build-push.outputs.digest }}
5050
```
5151
5252
### Signing multiple registries
@@ -64,7 +64,7 @@ jobs:
6464
6565
```bash
6666
cosign verify \
67-
--certificate-identity-regexp=".*" \
67+
--certificate-identity-regexp="^https://github.com/LerianStudio/.*/.github/workflows/.*@refs/heads/.*$" \
6868
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
6969
docker.io/myorg/myapp@sha256:abc123...
7070
```

0 commit comments

Comments
 (0)