-
Notifications
You must be signed in to change notification settings - Fork 94
fix: mitigate prompt injection in issue triage workflows #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,9 @@ | |
app-id: '${{ vars.APP_ID }}' | ||
private-key: '${{ secrets.APP_PRIVATE_KEY }}' | ||
|
||
- name: 'Run Gemini Issue Triage' | ||
- name: 'Suggest Labels' | ||
uses: './' | ||
id: 'gemini_issue_triage' | ||
id: 'suggest_labels' | ||
env: | ||
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
ISSUE_TITLE: '${{ github.event.issue.title }}' | ||
|
@@ -78,8 +78,7 @@ | |
"maxSessionTurns": 25, | ||
"coreTools": [ | ||
"run_shell_command(echo)", | ||
"run_shell_command(gh label list)", | ||
"run_shell_command(gh issue edit)" | ||
"run_shell_command(gh label list)" | ||
], | ||
"telemetry": { | ||
"enabled": true, | ||
|
@@ -90,9 +89,7 @@ | |
## Role | ||
|
||
You are an issue triage assistant. Analyze the current GitHub issue | ||
and apply the most appropriate existing labels. Use the available | ||
tools to gather information; do not ask for information to be | ||
provided. | ||
and suggest the most appropriate existing labels. | ||
|
||
## Steps | ||
|
||
|
@@ -102,22 +99,54 @@ | |
3. Classify issues by their kind (bug, enhancement, documentation, | ||
cleanup, etc) and their priority (p0, p1, p2, p3). Set the | ||
labels accoridng to the format `kind/*` and `priority/*` patterns. | ||
4. Apply the selected labels to this issue using: | ||
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"` | ||
5. If the "status/needs-triage" label is present, remove it using: | ||
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"` | ||
4. Output the labels as a comma-separated string. For example: "kind/bug,priority/p1". | ||
If the "status/needs-triage" label should be removed, include "remove:status/needs-triage" in the output string. | ||
|
||
## Guidelines | ||
|
||
- Only use labels that already exist in the repository | ||
- Do not add comments or modify the issue content | ||
- Triage only the current issue | ||
- Assign all applicable labels based on the issue content | ||
- Reference all shell variables as "${VAR}" (with quotes and braces) | ||
- Output only the comma-separated string of labels. | ||
- If no labels are applicable, output an empty string. | ||
|
||
- name: 'Apply Labels' | ||
if: |- | ||
${{ steps.suggest_labels.outputs.result }} | ||
env: | ||
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
LABELS_TO_APPLY: '${{ steps.suggest_labels.outputs.result }}' | ||
Check failure on line 118 in .github/workflows/gemini-issue-automated-triage.yml
|
||
ISSUE_NUMBER: '${{ github.event.issue.number }}' | ||
run: | | ||
set -euo pipefail | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need all this bash? It seems pretty brittle... I wonder if we could export JSON or something machine-parseable instead? Alternatively, could we use the action-script action to do this in node, which would likely be a bit cleaner? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented this approach in #171 |
||
|
||
ADD_LABELS="" | ||
REMOVE_LABELS="" | ||
|
||
# Separate labels to add and remove | ||
for label in $(echo "${LABELS_TO_APPLY}" | tr ',' ' '); do | ||
if [[ $label == remove:* ]]; then | ||
REMOVE_LABELS="${REMOVE_LABELS},${label#remove:}" | ||
else | ||
ADD_LABELS="${ADD_LABELS},${label}" | ||
fi | ||
done | ||
|
||
# Remove leading commas | ||
ADD_LABELS="${ADD_LABELS#,}" | ||
REMOVE_LABELS="${REMOVE_LABELS#,}" | ||
|
||
if [[ -n "${ADD_LABELS}" ]]; then | ||
gh issue edit "${ISSUE_NUMBER}" --add-label "${ADD_LABELS}" | ||
fi | ||
|
||
if [[ -n "${REMOVE_LABELS}" ]]; then | ||
gh issue edit "${ISSUE_NUMBER}" --remove-label "${REMOVE_LABELS}" | ||
fi | ||
|
||
- name: 'Post Issue Triage Failure Comment' | ||
if: |- | ||
${{ failure() && steps.gemini_issue_triage.outcome == 'failure' }} | ||
${{ failure() && steps.suggest_labels.outcome == 'failure' }} | ||
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' | ||
with: | ||
github-token: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this too by fetching labels upfront? then we can also remove
gh label list