Skip to content

Commit 4d06b22

Browse files
committed
chore: pin all self-refs to full SHAs and update release flow
Signed-off-by: Derek Misler <derek.misler@docker.com> chore: remove confused reaction from reply-to-feedback workflow Remove the second confused emoji reaction that was added when reply generation failed. Consistent with the previous commit - failures are already logged in workflow runs. chore: remove confused reaction on thread-build failure The confused emoji reaction was confusing users when thread context building failed. Remove the step entirely - failures are already logged in the workflow run. fix: address code review findings - Add --paginate flag to consumer repo search to handle >100 repos - Add validation for SHA-pinned refs without version comments - Replace unsafe heredoc PR body with printf to prevent command injection - Add trap-based cleanup for temp directories to prevent resource leaks - Move ROOT_COMMENT_ID validation to shared step for both auth paths Fixes identified in strict code review: - HIGH: Consumer repo pagination truncation - MEDIUM: Command injection via FILE_PATH in PR body - MEDIUM: Weak validation pattern for SHA pinning - MEDIUM: Temp directory leaks on errors - MEDIUM: Missing ROOT_COMMENT_ID validation in authorized path chore: remove redundant token validation step Assisted-By: docker-agent
1 parent 0f40129 commit 4d06b22

File tree

9 files changed

+294
-143
lines changed

9 files changed

+294
-143
lines changed

.github/workflows/release.yml

Lines changed: 249 additions & 57 deletions
Large diffs are not rendered by default.

.github/workflows/reply-to-feedback.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -327,28 +327,3 @@ jobs:
327327
github-token: ${{ steps.app-token.outputs.token || github.token }}
328328
skip-auth: "true" # Org membership already verified above
329329

330-
# ----------------------------------------------------------------
331-
# Failure handling
332-
# ----------------------------------------------------------------
333-
- name: React on failure
334-
if: >-
335-
always() &&
336-
steps.meta.outputs.proceed == 'true' &&
337-
steps.auth.outputs.authorized == 'true' &&
338-
(steps.checkout.outcome == 'failure' || steps.thread.outcome == 'failure' || steps.run-reply.outcome == 'failure')
339-
continue-on-error: true
340-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
341-
env:
342-
COMMENT_ID: ${{ steps.meta.outputs.comment_id }}
343-
REPO: ${{ steps.meta.outputs.repo }}
344-
with:
345-
github-token: ${{ steps.app-token.outputs.token || github.token }}
346-
script: |
347-
const [owner, repo] = process.env.REPO.split('/');
348-
await github.rest.reactions.createForPullRequestReviewComment({
349-
owner,
350-
repo,
351-
comment_id: parseInt(process.env.COMMENT_ID, 10),
352-
content: 'confused'
353-
});
354-
console.log('😕 Reply failed — added confused reaction');

.github/workflows/review-pr.yml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
# jobs:
1414
# review:
15-
# uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
15+
# uses: docker/cagent-action/.github/workflows/review-pr.yml@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
1616
# # Scoped to the job so other jobs in this workflow aren't over-permissioned
1717
# permissions:
1818
# contents: read # Read repository files and PR diffs
@@ -179,7 +179,7 @@ jobs:
179179
if: steps.membership.outputs.is_member == 'true'
180180
id: run-review
181181
continue-on-error: true # Don't fail the calling workflow if the review errors
182-
uses: docker/cagent-action/review-pr@latest
182+
uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
183183
with:
184184
pr-number: ${{ inputs.pr-number || github.event.pull_request.number }}
185185
additional-prompt: ${{ inputs.additional-prompt }}
@@ -301,7 +301,7 @@ jobs:
301301
if: steps.membership.outputs.is_member == 'true'
302302
id: run-review
303303
continue-on-error: true # Don't fail the calling workflow if the review errors
304-
uses: docker/cagent-action/review-pr@latest
304+
uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
305305
with:
306306
pr-number: ${{ inputs.pr-number || github.event.issue.number }}
307307
comment-id: ${{ inputs.comment-id || github.event.comment.id }}
@@ -457,6 +457,21 @@ jobs:
457457
echo "⏭️ Not a reply to agent comment, skipping"
458458
fi
459459
460+
- name: Validate root comment ID
461+
if: steps.check.outputs.is_agent == 'true'
462+
shell: bash
463+
env:
464+
ROOT_COMMENT_ID: ${{ steps.check.outputs.root_comment_id }}
465+
run: |
466+
if [ -z "$ROOT_COMMENT_ID" ]; then
467+
echo "::error::ROOT_COMMENT_ID is not set"
468+
exit 1
469+
fi
470+
if ! [[ "$ROOT_COMMENT_ID" =~ ^[0-9]+$ ]]; then
471+
echo "::error::ROOT_COMMENT_ID is not a valid integer: '$ROOT_COMMENT_ID'"
472+
exit 1
473+
fi
474+
460475
- name: Check authorization
461476
if: steps.check.outputs.is_agent == 'true'
462477
id: auth
@@ -509,16 +524,6 @@ jobs:
509524
ROOT_COMMENT_ID: ${{ steps.check.outputs.root_comment_id }}
510525
AUTHOR: ${{ github.event.comment.user.login }}
511526
run: |
512-
# Validate ROOT_COMMENT_ID is a valid integer before using it
513-
if [ -z "$ROOT_COMMENT_ID" ]; then
514-
echo "::error::ROOT_COMMENT_ID is not set"
515-
exit 1
516-
fi
517-
518-
if ! [[ "$ROOT_COMMENT_ID" =~ ^[0-9]+$ ]]; then
519-
echo "::error::ROOT_COMMENT_ID is not a valid integer: '$ROOT_COMMENT_ID'"
520-
exit 1
521-
fi
522527
523528
jq -n \
524529
--arg body "Sorry @$AUTHOR, conversational replies are currently available to repository collaborators only. Your feedback has still been captured and will be used to improve future reviews.
@@ -639,7 +644,7 @@ jobs:
639644
- name: Run reply
640645
if: steps.check.outputs.is_agent == 'true' && steps.auth.outputs.authorized == 'true'
641646
continue-on-error: true
642-
uses: docker/cagent-action/review-pr/reply@latest
647+
uses: docker/cagent-action/review-pr/reply@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
643648
with:
644649
thread-context: ${{ steps.thread.outputs.prompt }}
645650
comment-id: ${{ github.event.comment.id }}
@@ -652,20 +657,3 @@ jobs:
652657
mistral-api-key: ${{ secrets.MISTRAL_API_KEY }}
653658
github-token: ${{ steps.app-token.outputs.token || github.token }}
654659
skip-auth: "true" # Org membership already verified above
655-
656-
- name: React on thread-build failure
657-
if: >-
658-
always() &&
659-
steps.check.outputs.is_agent == 'true' &&
660-
steps.auth.outputs.authorized == 'true' &&
661-
steps.thread.outcome == 'failure'
662-
continue-on-error: true
663-
shell: bash
664-
env:
665-
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
666-
REPO: ${{ github.repository }}
667-
COMMENT_ID: ${{ github.event.comment.id }}
668-
run: |
669-
gh api "repos/$REPO/pulls/comments/$COMMENT_ID/reactions" \
670-
-f content="confused" --silent || true
671-
echo "😕 Thread context build failed — added confused reaction"

.github/workflows/update-cagent-version.yml renamed to .github/workflows/update-docker-agent-version.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update Docker Agent version
22

33
on:
44
repository_dispatch:
5-
types: [cagent-release]
5+
types: [docker-agent-release]
66
workflow_dispatch:
77
inputs:
88
version:
@@ -13,28 +13,24 @@ on:
1313
jobs:
1414
update-version:
1515
runs-on: ubuntu-latest
16-
env:
17-
HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }}
1816
steps:
1917
- name: Generate GitHub App token
20-
if: env.HAS_APP_SECRETS == 'true'
2118
id: app-token
22-
continue-on-error: true
2319
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
2420
with:
2521
app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }}
2622
private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }}
2723

2824
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2925
with:
30-
token: ${{ steps.app-token.outputs.token || secrets.RELEASE_TOKEN }}
26+
token: ${{ steps.app-token.outputs.token }}
3127

3228
- name: Determine version
3329
id: version
3430
env:
3531
DISPATCH_VERSION: ${{ github.event.client_payload.version }}
3632
INPUT_VERSION: ${{ inputs.version }}
37-
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.RELEASE_TOKEN }}
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3834
run: |
3935
if [ -n "$INPUT_VERSION" ]; then
4036
VERSION="$INPUT_VERSION"
@@ -52,7 +48,7 @@ jobs:
5248
5349
- name: Validate version exists
5450
env:
55-
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.RELEASE_TOKEN }}
51+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
5652
VERSION: ${{ steps.version.outputs.version }}
5753
run: |
5854
echo "Validating that $VERSION exists as a release on docker/docker-agent..."
@@ -91,7 +87,7 @@ jobs:
9187
- name: Create or update PR
9288
if: steps.check.outputs.skip != 'true'
9389
env:
94-
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.RELEASE_TOKEN }}
90+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
9591
VERSION: ${{ steps.version.outputs.version }}
9692
CURRENT: ${{ steps.check.outputs.current }}
9793
run: |

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A GitHub Action for running [Docker Agent](https://github.com/docker/docker-agen
77
1. **Add the action to your workflow**:
88

99
```yaml
10-
- uses: docker/cagent-action@latest
10+
- uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
1111
with:
1212
agent: path/to/agent.yaml
1313
prompt: "Analyze this code"
@@ -62,7 +62,7 @@ permissions:
6262

6363
jobs:
6464
review:
65-
uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
65+
uses: docker/cagent-action/.github/workflows/review-pr.yml@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
6666
# Scoped to the job so other jobs in this workflow aren't over-permissioned
6767
permissions:
6868
contents: read # Read repository files and PR diffs
@@ -84,7 +84,7 @@ See the [full PR Review documentation](review-pr/README.md) for more details.
8484

8585
```yaml
8686
- name: Run Custom Agent
87-
uses: docker/cagent-action@latest
87+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
8888
with:
8989
agent: ./agents/my-agent.yaml
9090
prompt: "Analyze the codebase"
@@ -95,7 +95,7 @@ See the [full PR Review documentation](review-pr/README.md) for more details.
9595

9696
```yaml
9797
- name: Run Docker Agent with Custom Settings
98-
uses: docker/cagent-action@latest
98+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
9999
with:
100100
agent: docker/code-analyzer
101101
prompt: "Analyze this codebase"
@@ -115,7 +115,7 @@ See the [full PR Review documentation](review-pr/README.md) for more details.
115115
```yaml
116116
- name: Run Docker Agent
117117
id: agent
118-
uses: docker/cagent-action@latest
118+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
119119
with:
120120
agent: docker/code-analyzer
121121
prompt: "Analyze this codebase"
@@ -245,14 +245,14 @@ jobs:
245245
- uses: actions/checkout@v4
246246
247247
- name: Security Review
248-
uses: docker/cagent-action@latest
248+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
249249
with:
250250
agent: docker/github-action-security-scanner
251251
prompt: "Analyze for security issues"
252252
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
253253
254254
- name: Code Quality Analysis
255-
uses: docker/cagent-action@latest
255+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
256256
with:
257257
agent: docker/code-quality-analyzer
258258
prompt: "Analyze code quality and best practices"
@@ -285,7 +285,7 @@ jobs:
285285
- uses: actions/checkout@v4
286286
287287
- name: Run Agent
288-
uses: docker/cagent-action@latest
288+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
289289
with:
290290
agent: ${{ github.event.inputs.agent }}
291291
prompt: ${{ github.event.inputs.prompt }}

review-pr/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ permissions:
2323

2424
jobs:
2525
review:
26-
uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
26+
uses: docker/cagent-action/.github/workflows/review-pr.yml@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
2727
# Scoped to the job so other jobs in this workflow aren't over-permissioned
2828
permissions:
2929
contents: read # Read repository files and PR diffs
@@ -146,7 +146,7 @@ jobs:
146146
fetch-depth: 0
147147
ref: refs/pull/${{ github.event.issue.number }}/head
148148
149-
- uses: docker/cagent-action/review-pr@latest
149+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
150150
with:
151151
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
152152
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -163,7 +163,7 @@ The recommended approach is to add an `AGENTS.md` file to your repository root.
163163
For workflow-level overrides or guidelines that apply across multiple repos, use the `additional-prompt` input:
164164

165165
```yaml
166-
- uses: docker/cagent-action/review-pr@latest
166+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
167167
with:
168168
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
169169
additional-prompt: |
@@ -174,7 +174,7 @@ For workflow-level overrides or guidelines that apply across multiple repos, use
174174
```
175175
176176
```yaml
177-
- uses: docker/cagent-action/review-pr@latest
177+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
178178
with:
179179
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
180180
additional-prompt: |
@@ -186,7 +186,7 @@ For workflow-level overrides or guidelines that apply across multiple repos, use
186186
187187
```yaml
188188
# Project-specific conventions
189-
- uses: docker/cagent-action/review-pr@latest
189+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
190190
with:
191191
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
192192
additional-prompt: |
@@ -207,31 +207,31 @@ Override for more thorough or cost-effective reviews:
207207

208208
```yaml
209209
# Anthropic (default provider)
210-
- uses: docker/cagent-action/review-pr@latest
210+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
211211
with:
212212
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
213213
model: anthropic/claude-opus-4 # More thorough reviews
214214
```
215215

216216
```yaml
217217
# OpenAI Codex
218-
- uses: docker/cagent-action/review-pr@latest
218+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
219219
with:
220220
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
221221
model: openai/codex-mini
222222
```
223223

224224
```yaml
225225
# Google Gemini
226-
- uses: docker/cagent-action/review-pr@latest
226+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
227227
with:
228228
google-api-key: ${{ secrets.GOOGLE_API_KEY }}
229229
model: gemini/gemini-2.0-flash
230230
```
231231

232232
```yaml
233233
# xAI Grok
234-
- uses: docker/cagent-action/review-pr@latest
234+
- uses: docker/cagent-action/review-pr@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
235235
with:
236236
xai-api-key: ${{ secrets.XAI_API_KEY }}
237237
model: xai/grok-2

review-pr/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ runs:
676676
- name: Process pending feedback
677677
if: steps.lock-check.outputs.skip != 'true' && steps.pending-feedback.outputs.has_feedback == 'true'
678678
continue-on-error: true
679-
uses: docker/cagent-action@latest
679+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
680680
with:
681681
agent: ${{ github.action_path }}/agents/pr-review-feedback.yaml
682682
prompt: |
@@ -779,7 +779,7 @@ runs:
779779
- name: Run PR Review
780780
if: steps.lock-check.outputs.skip != 'true'
781781
id: run-review
782-
uses: docker/cagent-action@latest
782+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
783783
with:
784784
agent: ${{ github.action_path }}/agents/pr-review.yaml
785785
prompt: ${{ steps.context.outputs.review_prompt }}

review-pr/reply/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ runs:
7171
- name: Run reply agent
7272
id: run-reply
7373
continue-on-error: true
74-
uses: docker/cagent-action@latest
74+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
7575
with:
7676
agent: ${{ github.action_path }}/../agents/pr-review-reply.yaml
7777
prompt: ${{ inputs.thread-context }}

security/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ All tests must pass before deployment.
220220
```yaml
221221
- name: Run Agent
222222
id: agent
223-
uses: docker/cagent-action@latest
223+
uses: docker/cagent-action@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
224224
with:
225225
agent: my-agent
226226
prompt: "Analyze the logs"

0 commit comments

Comments
 (0)