Skip to content

Conversation

@meetdhananifynd
Copy link
Contributor

No description provided.

+process.version.split('.')[0].slice(1) >= 18;
let b = exec(
`node ${VUE_CLI_PATH} build --target lib src/index.js --name ${bundleName}`,
`node ${VUE_CLI_PATH} build --target lib src/index.js --name ${bundleName} --filename ${assetHash}_${bundleName}`,

Check failure

Code scanning / CodeQL

Uncontrolled command line

This command line depends on a [user-provided value](1).

Copilot Autofix

AI over 1 year ago

To fix the problem, we should avoid using exec with a single concatenated string that includes user input. Instead, we can use execFile or execFileSync, which allows us to pass command arguments as an array of strings. This approach is safer and mitigates the risk of command injection.

  1. Replace the exec function with execFile.
  2. Pass the command and its arguments as separate elements in an array.
  3. Ensure that the bundleName and other variables are passed as separate arguments to avoid shell interpretation.
Suggested changeset 1
src/lib/ExtensionSection.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/lib/ExtensionSection.ts b/src/lib/ExtensionSection.ts
--- a/src/lib/ExtensionSection.ts
+++ b/src/lib/ExtensionSection.ts
@@ -26,3 +26,3 @@
 import inquirer from 'inquirer';
-import { exec } from 'child_process';
+import { execFile } from 'child_process';
 import * as cheerio from 'cheerio';
@@ -549,4 +549,12 @@
                 +process.version.split('.')[0].slice(1) >= 18;
-            let b = exec(
-                `node ${VUE_CLI_PATH} build --target lib src/index.js --name ${bundleName} --filename ${assetHash}_${bundleName}`,
+            let b = execFile(
+                'node',
+                [
+                    VUE_CLI_PATH,
+                    'build',
+                    '--target', 'lib',
+                    'src/index.js',
+                    '--name', bundleName,
+                    '--filename', `${assetHash}_${bundleName}`
+                ],
                 {
EOF
@@ -26,3 +26,3 @@
import inquirer from 'inquirer';
import { exec } from 'child_process';
import { execFile } from 'child_process';
import * as cheerio from 'cheerio';
@@ -549,4 +549,12 @@
+process.version.split('.')[0].slice(1) >= 18;
let b = exec(
`node ${VUE_CLI_PATH} build --target lib src/index.js --name ${bundleName} --filename ${assetHash}_${bundleName}`,
let b = execFile(
'node',
[
VUE_CLI_PATH,
'build',
'--target', 'lib',
'src/index.js',
'--name', bundleName,
'--filename', `${assetHash}_${bundleName}`
],
{
Copilot is powered by AI and may make mistakes. Always verify output.
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.

3 participants