Skip to content

Potential fix for code scanning alert no. 1: Shell command built from environment values - #323

Open
Tatsat (Tats) Mishra 🐉 (Tatsinnit) wants to merge 1 commit into
mainfrom
alert-autofix-1
Open

Tatsat (Tats) Mishra 🐉 (Tatsinnit) wants to merge 1 commit into
mainfrom
alert-autofix-1

Conversation

@Tatsinnit

Copy link
Copy Markdown
Member

Potential fix for https://github.com/Azure/k8s-bake/security/code-scanning/1

To fix this without changing intended behavior, validate toolPath inside execCommand before calling getExecOutput:

  1. Resolve to an absolute real path (fs.realpathSync) to normalize symlinks.
  2. Require absolute path and require basename to match known allowed tool names (helm, kubectl, kompose, with optional .exe).
  3. Verify target exists and is a file (fs.statSync(...).isFile()).
  4. Reject anything failing validation with a clear error.

Best place: src/utilities.ts, inside execCommand, immediately before line 42 sink call.
No new dependency is needed; existing fs import is already present, and add Node built-in path import.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… environment values

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Tatsinnit
Tatsat (Tats) Mishra 🐉 (Tatsinnit) marked this pull request as ready for review November 29, 2026 23:42
Comment thread src/utilities.ts
)
}

const result = await getExecOutput(resolvedToolPath, args, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants