-
Notifications
You must be signed in to change notification settings - Fork 15
chore: remove cjs exports and improve typescript performance #472
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
Conversation
execCmd(["tsc", "--project", tsconfigEsmFile].join(" ")), | ||
]); | ||
|
||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium
absolute path
]); | ||
|
||
await execCmd(`shx ls ${distDir}/*.{tsx,ts} | xargs rm`); | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium
absolute path
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 14 days ago
To fix the issue, we will replace the use of execCmd
with a safer alternative that avoids dynamically constructing the shell command. Specifically:
- Use
execFile
orexecFileSync
instead ofexec
to pass the command and its arguments as separate parameters. This ensures that the shell does not interpret the arguments. - Modify the
execCmd
call on line 75 to passtsconfigFile
as an argument to thetsc
command, rather than embedding it in a concatenated string.
This change will ensure that special characters in tsconfigFile
are treated as literal values and not interpreted by the shell.
-
Copy modified line R75
@@ -74,3 +74,3 @@ | ||
await execCmd(["shx", "cp", baseIconFile, distDir].join(" ")); | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); | ||
await execCmd("tsc", ["--project", tsconfigFile]); | ||
await execCmd(`shx ls ${distDir}/*.{tsx,ts} | grep -v ".d.ts$" | xargs rm`); |
|
||
await execCmd(`shx ls ${distDir}/*.{tsx,ts} | xargs rm`); | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); | ||
await execCmd(`shx ls ${distDir}/*.{tsx,ts} | grep -v ".d.ts$" | xargs rm`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium
absolute path
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 14 days ago
To fix the issue, we will replace the dynamically constructed shell command with a safer alternative that avoids shell interpretation. Specifically:
- Use
execFile
orexecFileSync
instead ofexec
to pass arguments as an array, ensuring they are not interpreted by the shell. - Replace the
shx ls
andgrep
commands with equivalent functionality implemented in JavaScript, avoiding the need for shell commands entirely.
The changes will focus on line 76, where the vulnerable shell command is executed.
-
Copy modified lines R76-R80
@@ -75,3 +75,7 @@ | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); | ||
await execCmd(`shx ls ${distDir}/*.{tsx,ts} | grep -v ".d.ts$" | xargs rm`); | ||
const files = await fs.readdir(distDir); | ||
const filesToDelete = files.filter(file => /\.(tsx|ts)$/.test(file) && !file.endsWith(".d.ts")); | ||
await Promise.all( | ||
filesToDelete.map(file => fs.rm(path.join(distDir, file))) | ||
); | ||
|
]); | ||
|
||
await removeDirsExcept(distDir, ["cjs", "esm"]); | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium
absolute path
await removeDirsExcept(distDir, ["cjs", "esm"]); | ||
await execCmd(["tsc", "--project", tsconfigFile].join(" ")); | ||
await execCmd( | ||
`shx ls ${distDir}/*.{tsx,ts} ${distDir}/**/*.{tsx,ts} | grep -v ".d.ts$" | xargs rm`, |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium
No description provided.