Repository navigation
Apply issue labels in the github-script step - #70
Merged
Merged
Conversation
The auto-label workflow passed the label list and the issue number to a
shell step through ${{ }} expressions. Security scanners flag this
pattern as a script injection risk.
Call the GitHub API from the github-script step. Remove the shell step.
Apply only the labels that exist in the repository. The name match
ignores case, so the "Trn2" rule applies the "trn2" label. The workflow
logs a warning for a label that does not exist, for example "Inf1".
yuchenjiangyj
marked this pull request as ready for review
October 13, 2026 22:20
awsjoshir
approved these changes
Oct 14, 2026
aws-maens
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Apply issue labels from the
actions/github-scriptstep. Remove the shell step that applied the labels.The old "Apply labels to issue" step put
${{ steps.analyze_content.outputs.labels }},${{ github.event.issue.number }}, and${{ github.repository }}directly into arun:script. Security scanners flag a${{ }}expression in arun:script as a script injection risk. See GitHub: Good practices for mitigating script injection attacks.The current values are not controlled by the issue author. The label list contains only fixed label names. This change removes the pattern, so that a later edit to the label logic cannot make the shell step unsafe.
Changes
github-scriptstep callsgithub.rest.issues.addLabelsafter it selects the labels.run:step. No${{ }}expression goes into a script.env:, as before.issues: write), and the label rules do not change.Behavior
Trn2rule applies the existingtrn2label.Inf1label and noInf2label. Create these labels to apply them.Testing
run:step. The script contains no${{ }}expression.AsyncFunction, the same wayactions/github-scriptruns it. The test used a mockgithubclient and the 17 labels of this repository. 6 of 6 cases passed:Crash on trn2 during inferencebug,trn2,InferenceDocs typo for inf2documentationInf2does not existinf1 questionaddLabelscall)Inf1does not existhello world$(...), backticks, and${{ }}textTrn1,Trainingbugissuesworkflow runs only from the default branch, so the test branch added a temporarypull_requesttrigger and read the title from the pull request. The test branch also addedpull-requests: write, because a label on a pull request needs this permission. A label on an issue needs onlyissues: write. 3 of 3 runs passed:Crash on trn2 during inference inf2bug,trn2,InferenceInf2does not existhello worldTest title with shell text: $(id) `id` "; exit 1 # ${{ github.token }} trn1 trainingTrn1,Training