Potential fix for code scanning alert no. 1: Code injection #52
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.
Potential fix for https://github.com/codeharborhub/dsa/security/code-scanning/1
To fix this code injection risk, the issue body must not be injected into the shell script using the
${{ ... }}expression syntax inside therun:block. Instead, assign the untrusted input to an environment variable using GitHub Actionsenv:at the step level, and then read it using standard shell variable expansion ("$ISSUE_BODY"). This way, the expression is evaluated by the Actions runner before the shell starts, and the shell sees only the resolved value via its own variable mechanism, which prevents expression-level injection.Concretely, in the
Validate Issue Contentstep (lines 34–41), add anenv:section that setsISSUE_BODY: ${{ github.event.issue.body }}and modify therun:script to useissue_body="$ISSUE_BODY"or just reference$ISSUE_BODYdirectly instead of${{ github.event.issue.body }}. The string checks remain the same. Similarly, in theCheck for Security and Truststep (lines 43–49), introduce anenv:section withISSUE_BODY: ${{ github.event.issue.body }}and useissue_body="$ISSUE_BODY"in the script. No changes are required to other steps because the reported injection is specifically on line 37; we will keep the rest of the functionality intact.These changes all occur within
.github/workflows/issue_creation_workflow.ymlunder the two affected steps. No additional methods or external libraries are necessary; we only adjust YAML structure and shell variable usage.Suggested fixes powered by Copilot Autofix. Review carefully before merging.