Skip to content

fix: set generate-authors shell command built from environment values #2471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

odaysec
Copy link
Contributor

@odaysec odaysec commented Jun 11, 2025

import { execSync } from 'child_process';

return execSync(
`git log --reverse --format='%aN <%aE>' --use-mailmap -- ${packagePath}`,

Fix the issue should avoid dynamically constructing the shell command as a single string. Instead, we can use execFileSync, which allows us to pass the command and its arguments separately. This approach ensures that the arguments are not interpreted by the shell, mitigating the risk of command injection.

Specifically:

  1. Replace the use of execSync with execFileSync in the getAuthorsGitLog function.
  2. Pass the git command and its arguments as separate parameters to execFileSync.
  3. Ensure that packagePath is passed as an argument, rather than interpolated into the command string.

Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Just going to point out that while there's nothing inherently wrong with this PR, it is effectively a no-op and just adds noise for maintainers, since the way this script is used ensures that it only operates on known and trusted inputs

@addaleax addaleax merged commit aaca8df into mongodb-js:main Jun 16, 2025
124 of 132 checks passed
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