npm-scan-plus 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/npm-scan-wrap +17 -9
  2. package/package.json +1 -1
package/bin/npm-scan-wrap CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * npm-scan wrapper - Automatically scans before and after npm install
5
- * Usage: npm-scan-wrap install <packages>
6
- * npm-scan-wrap install
4
+ * npm-scan-plus wrapper - Automatically scans before and after npm install
5
+ * Usage: npm-scan-plus-wrap install <packages>
6
+ * npm-scan-plus-wrap install
7
7
  */
8
8
 
9
9
  const { spawn } = require('child_process');
@@ -14,9 +14,16 @@ const SCANNER_PATH = path.join(__dirname, '../dist/cli/index.js');
14
14
 
15
15
  async function runScanner(args) {
16
16
  return new Promise((resolve, reject) => {
17
- const scanner = spawn('node', [SCANNER_PATH, ...args], {
18
- stdio: 'inherit',
19
- shell: true
17
+ // Properly quote arguments to prevent injection
18
+ const safeArgs = args.map(arg => {
19
+ if (arg.includes(' ') || arg.includes('"') || arg.includes("'")) {
20
+ return `"${arg.replace(/"/g, '\\"')}"`;
21
+ }
22
+ return arg;
23
+ });
24
+
25
+ const scanner = spawn('node', [SCANNER_PATH, ...safeArgs], {
26
+ stdio: 'inherit'
20
27
  });
21
28
 
22
29
  scanner.on('close', (code) => {
@@ -28,10 +35,11 @@ async function runScanner(args) {
28
35
 
29
36
  async function runNpm(args) {
30
37
  return new Promise((resolve, reject) => {
31
- const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
32
- const install = spawn(npm, args, {
38
+ // Use npm.cmd on Windows, avoid shell: true
39
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
40
+
41
+ const install = spawn(npmCmd, args, {
33
42
  stdio: 'inherit',
34
- shell: true,
35
43
  env: { ...process.env, NPM_CONFIG_AUDIT: 'false' }
36
44
  });
37
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-scan-plus",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Security scanner for npm packages - pre and post-install scanning for malicious code, supply chain attacks, and obfuscated code",
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.ts",