Skip to content

Commit 9ddf91d

Browse files
committed
ci(translator): split inference/mutation jobs and sanitize warning log
Security: split single translate job into two separate jobs: - detect-and-translate: holds only models: read — inference runs without a write-capable token, so attacker-controlled issue content cannot be used to trigger mutations during the LLM call - apply-translation: holds only issues: write — write access is only granted after inference is complete and the output has been passed as a job output Privacy: replace core.warning that echoed the full raw AI response (which mirrors issue body content including any secrets or PII) with a fixed message that logs only the response length as metadata
1 parent 510208b commit 9ddf91d

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

‎.github/workflows/issue-translator.yml‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ on:
55
types:
66
- opened
77

8-
permissions:
9-
issues: write
10-
models: read
11-
128
jobs:
13-
translate:
14-
name: Translate non-English issue
9+
detect-and-translate:
10+
name: Detect language and translate
1511
concurrency:
1612
group: issue-translator-${{ github.event.issue.number }}
1713
cancel-in-progress: false
1814
runs-on: ubuntu-latest
15+
permissions:
16+
models: read # inference only — no write access during attacker-controlled input
17+
outputs:
18+
response: ${{ steps.ai.outputs.response }}
1919

2020
steps:
21-
- name: Detect language and translate
21+
- name: Run inference
2222
id: ai
2323
uses: actions/ai-inference@b81b2afb8390ee6839b494a404766bef6493c7d9 # v1
2424
with:
@@ -58,10 +58,18 @@ jobs:
5858
"translated_body": "<English body or empty string>"
5959
}
6060
61-
- name: Apply translation
61+
apply-translation:
62+
name: Apply translation
63+
needs: detect-and-translate
64+
if: needs.detect-and-translate.result == 'success'
65+
runs-on: ubuntu-latest
66+
permissions:
67+
issues: write # write access only after inference is complete
68+
steps:
69+
- name: Update issue with translation
6270
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
6371
env:
64-
AI_RESPONSE: ${{ steps.ai.outputs.response }}
72+
AI_RESPONSE: ${{ needs.detect-and-translate.outputs.response }}
6573
with:
6674
script: |
6775
const { owner, repo } = context.repo;
@@ -81,7 +89,8 @@ jobs:
8189
parsed = JSON.parse(stripped);
8290
}
8391
} catch (err) {
84-
core.warning(`AI response was not valid JSON: ${raw}`);
92+
// Log only metadata — never echo raw content which may include secrets or PII
93+
core.warning(`AI response could not be parsed as JSON (response length: ${raw.length})`);
8594
return;
8695
}
8796
@@ -114,7 +123,7 @@ jobs:
114123
core.info('Title was already edited after the event; skipping title update.');
115124
} else if (liveIssue.title !== title) {
116125
await github.rest.issues.update({ owner, repo, issue_number, title });
117-
core.info(`Title updated to: ${title}`);
126+
core.info('Title updated to English translation.');
118127
}
119128
120129
if (!body) {
@@ -142,4 +151,4 @@ jobs:
142151
body,
143152
].join('\n'),
144153
});
145-
core.info(`Posted ${lang} → English translation on #${issue_number}.`);
154+
core.info(`Posted ${lang} to English translation on #${issue_number}.`);

0 commit comments

Comments
 (0)