Skip to content

Conversation

@skoeva
Copy link
Contributor

@skoeva skoeva commented Oct 28, 2025

These changes remove usage of execSync in the scripts and replace them with execFileSync.

@skoeva skoeva self-assigned this Oct 28, 2025
@skoeva skoeva added frontend Issues related to the frontend security app quality Related to improving the quality of the app headlamp-plugin Related to the headlamp-plugin NPM package. labels Oct 28, 2025
@k8s-ci-robot k8s-ci-robot requested a review from sniok October 28, 2025 20:20
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: skoeva
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2025
@illume illume added this to the v0.38.0 milestone Oct 29, 2025
@illume
Copy link
Contributor

illume commented Oct 29, 2025

Thanks.

I want to hold off on this until after 0.37.0

@skoeva skoeva marked this pull request as draft October 29, 2025 13:40
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 29, 2025
@skoeva skoeva marked this pull request as ready for review October 31, 2025 12:30
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 31, 2025
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 31, 2025
@illume illume requested a review from Copilot November 3, 2025 11:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors shell command execution across the codebase by replacing execSync with execFileSync to improve security by avoiding shell interpretation and reducing the risk of command injection vulnerabilities. Additionally, it consolidates duplicate imports in one file.

  • Replaced execSync with execFileSync for git, npm, and make commands across multiple files
  • Updated command invocations to pass arguments as arrays instead of shell strings
  • Consolidated duplicate imports in app/scripts/start.js

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/releaser/src/utils/git.ts Converted all git commands from execSync to execFileSync with array arguments
tools/releaser/src/commands/start.ts Changed npm install command to use execFileSync
plugins/headlamp-plugin/bin/headlamp-plugin.js Updated npm commands to use execFileSync and removed an error message
frontend/make-env.js Converted git command to use execFileSync
app/scripts/start.js Consolidated duplicate child_process imports
app/scripts/build-backend.js Changed make command to use execFileSync
app/electron/main.ts Converted binary execution and Windows taskkill command to use execFileSync
Comments suppressed due to low confidence (1)

app/scripts/build-backend.js:25

  • On Windows, make is not typically available as a direct executable and may require shell interpretation or a specific make implementation (like mingw32-make). Using execFileSync without shell: true may cause failures on Windows where make is a batch file or requires shell invocation. Consider adding shell: true to the options or handling Windows separately.
  execFileSync('make', ['backend'], {
    env: {
      ...process.env, // needed otherwise important vars like PATH and GOROOT are not set
      GOARCH: arch,
      OS: osName,
    },
    cwd: '..',
  });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

execSync('npm install', { stdio: 'inherit', cwd: path.join(repoRoot, 'app') });
execFileSync('npm', ['install'], {
stdio: 'inherit',
cwd: path.join(repoRoot, 'app'),
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, npm is typically a .cmd file, not an executable. Using execFileSync('npm', ...) without shell: true will fail on Windows. Consider adding shell: true to the options or using a cross-platform solution like checking process.platform === 'win32' and adjusting the command accordingly (e.g., 'npm.cmd' on Windows).

Suggested change
cwd: path.join(repoRoot, 'app'),
cwd: path.join(repoRoot, 'app'),
shell: true,

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a real issue, I tested it in node on windows with cmd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could probably be reverted, doing this now

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these require testing. The copilot found one issue which turned out to be a real one, so I'm worried that these changes will break other things.

It might be worth considering which if any of these is a security problem really to reduce the amount of testing that needs to be done.

@skoeva skoeva marked this pull request as draft November 3, 2025 18:59
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2025
@illume illume modified the milestones: v0.38.0, v0.39.0 Nov 10, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. frontend Issues related to the frontend headlamp-plugin Related to the headlamp-plugin NPM package. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. quality Related to improving the quality of the app security size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants