Skip to content
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

fix: correct directory in wasm update #108

Closed
wants to merge 2 commits into from
Closed

Conversation

marco-ippolito
Copy link
Member

@marco-ippolito marco-ippolito force-pushed the fix/wasm-update branch 3 times, most recently from b9fd333 to 0acc9ee Compare November 4, 2024 09:25
@marco-ippolito
Copy link
Member Author

it seems this is not the right solution


try {
for (const command of commands) {
execSync(command, { stdio: "inherit" });

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2).
This autofix suggestion was applied.
Show autofix suggestion Hide autofix suggestion

Copilot Autofix AI 2 months ago

To fix the problem, we should avoid dynamically constructing shell commands with environment values that can be interpreted by the shell. Instead, we should use the execFileSync method to pass the command and its arguments separately, which prevents the shell from interpreting special characters.

Specifically, we need to:

  1. Split the commands in the commands array into the command and its arguments.
  2. Use execFileSync to execute the commands with the arguments passed as an array.
Suggested changeset 1
tools/build-wasm.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tools/build-wasm.js b/tools/build-wasm.js
--- a/tools/build-wasm.js
+++ b/tools/build-wasm.js
@@ -67,7 +67,7 @@
 const commands = [
-	`cd ${wasmBindingPath}`,
-	"cargo install --locked wasm-pack",
-	"export PATH=/home/node/.cargo/bin:$PATH",
-	`sh ${wasmBindingPath}/scripts/build.sh`,
-	`cp -r ${wasmBindingPath}/pkg/* ${ROOT}/lib`,
+	["sh", "-c", `cd ${wasmBindingPath}`],
+	["cargo", "install", "--locked", "wasm-pack"],
+	["sh", "-c", "export PATH=/home/node/.cargo/bin:$PATH"],
+	["sh", `${wasmBindingPath}/scripts/build.sh`],
+	["cp", "-r", `${wasmBindingPath}/pkg/*`, `${ROOT}/lib`],
 ];
@@ -75,4 +75,4 @@
 try {
-	for (const command of commands) {
-		execSync(command, { stdio: "inherit" });
+	for (const [cmd, ...args] of commands) {
+		execFileSync(cmd, args, { stdio: "inherit" });
 	}
EOF
@@ -67,7 +67,7 @@
const commands = [
`cd ${wasmBindingPath}`,
"cargo install --locked wasm-pack",
"export PATH=/home/node/.cargo/bin:$PATH",
`sh ${wasmBindingPath}/scripts/build.sh`,
`cp -r ${wasmBindingPath}/pkg/* ${ROOT}/lib`,
["sh", "-c", `cd ${wasmBindingPath}`],
["cargo", "install", "--locked", "wasm-pack"],
["sh", "-c", "export PATH=/home/node/.cargo/bin:$PATH"],
["sh", `${wasmBindingPath}/scripts/build.sh`],
["cp", "-r", `${wasmBindingPath}/pkg/*`, `${ROOT}/lib`],
];
@@ -75,4 +75,4 @@
try {
for (const command of commands) {
execSync(command, { stdio: "inherit" });
for (const [cmd, ...args] of commands) {
execFileSync(cmd, args, { stdio: "inherit" });
}
Copilot is powered by AI and may make mistakes. Always verify output.
@marco-ippolito marco-ippolito committed this autofix suggestion 2 months ago.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
…alues

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@marco-ippolito
Copy link
Member Author

@mhdawson I gave it a try but I cannot figure out how to fix this

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.

1 participant