Skip to content

Potential fix for code scanning alert no. 12: Shell command built from environment values#5

Merged
Tanker187 merged 1 commit intomainfrom
alert-autofix-12
Feb 11, 2026
Merged

Potential fix for code scanning alert no. 12: Shell command built from environment values#5
Tanker187 merged 1 commit intomainfrom
alert-autofix-12

Conversation

@Tanker187
Copy link
Owner

Potential fix for https://github.com/Tanker187/vite/security/code-scanning/12

In general, you should avoid concatenating filesystem paths or environment-derived values into a single shell command string. Instead, call the underlying program directly and pass dynamic parts as arguments, bypassing the shell so that special characters in paths cannot alter the command structure.

Here, the only problematic use is const buildCommand = ${viteBinPath} buildpassed to `execaCommand(buildCommand, ...)`. We can replace this with a non‑shell call to `execa` that takes `viteBinPath` as the executable and `['build']` as its argument list. That way, `viteBinPath` is never parsed by a shell; it’s used directly as a program path, and `"build"` is a separate argument. To preserve logging, we can keep a human‑readable string for error messages (e.g.const buildCommandDisplay = `"${viteBinPath}" build"``) while using the safer API for execution.

Concretely in playground/cli/__tests__/serve.ts:

  • Import execa instead of (or alongside) execaCommand.
  • Inside the if (isBuild) block, replace:
    • const buildCommand = ${viteBinPath} build`` with:
      • a display string for logging; and
      • a safe call like execa(viteBinPath, ['build'], { ... }).
  • Update the error logging to use the display string instead of the now‑removed buildCommand variable.

No changes are needed in playground/vitestSetup.ts.

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

…m environment values

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Repository owner locked and limited conversation to collaborators Feb 11, 2026
@Tanker187 Tanker187 self-assigned this Feb 11, 2026
@Tanker187 Tanker187 marked this pull request as ready for review February 11, 2026 07:20
@Tanker187 Tanker187 merged commit 8990887 into main Feb 11, 2026
8 of 21 checks passed
@Tanker187 Tanker187 deleted the alert-autofix-12 branch February 11, 2026 07:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant