Potential fix for code scanning alert no. 100: Code injection - #263
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Lukas Burgholzer <burgholzer@me.com>
📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis pull request updates a GitHub Actions workflow configuration file to introduce an environment variable Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Potential fix for https://github.com/munich-quantum-toolkit/workflows/security/code-scanning/100
To fix this issue, we must ensure that untrusted user input (
inputs.runs-on) is not interpolated or injected directly into shell commands in therun:section. The safest fix is to pass the input value into an environment variable (e.g.,RUNS_ON) and then reference that variable using shell-variable expansion ($RUNS_ON) within the command. This ensures any dangerous characters in the input are interpreted as literal filenames, not as shell metacharacters.Steps:
${{ inputs.runs-on }}to instead reference a shell environment variable.RUNS_ON) using theenv:keyword in the step, assigning it to the input value.run:command, replacecoverage-${{ inputs.runs-on }}.xmlwithcoverage-$RUNS_ON.xml.inputs.runs-onin shell code (here, lines 80 and 83). Artifact names and paths passed to actions don't need this change unless they're used as shell commands.Suggested fixes powered by Copilot Autofix. Review carefully before merging.