socket 0.14.40-alpha.7 → 0.14.40-alpha.9

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.
package/bin/cli.js CHANGED
@@ -3,23 +3,27 @@
3
3
 
4
4
  const constants = require('../dist/constants')
5
5
 
6
- const { DIST_TYPE, distPath } = constants
6
+ const { DIST_TYPE } = constants
7
7
 
8
+ // When Node 18 is dropped and experimental-require-module warning are no longer
9
+ // a thing we can just use the require(`${constants.distPath}/cli.js`) code path.
8
10
  if (DIST_TYPE === 'require') {
9
- require(`${distPath}/cli.js`)
11
+ // Lazily access constants.distPath.
12
+ require(`${constants.distPath}/cli.js`)
10
13
  } else {
11
14
  const path = require('node:path')
12
15
  const spawn = require('@npmcli/promise-spawn')
13
-
14
- const { abortSignal, distPath, execPath } = constants
16
+ const { abortSignal } = constants
15
17
 
16
18
  process.exitCode = 1
17
19
  const spawnPromise = spawn(
18
- execPath,
20
+ // Lazily access constants.execPath
21
+ constants.execPath,
19
22
  [
20
23
  // Lazily access constants.nodeNoWarningsFlags.
21
24
  ...constants.nodeNoWarningsFlags,
22
- path.join(distPath, 'cli.js'),
25
+ // Lazily access constants.distPath.
26
+ path.join(constants.distPath, 'cli.js'),
23
27
  ...process.argv.slice(2)
24
28
  ],
25
29
  {
package/dist/constants.js CHANGED
@@ -20,6 +20,7 @@ const LOCK_EXT = '.lock';
20
20
  const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
21
21
  const NPX = 'npx';
22
22
  const PNPM = 'pnpm';
23
+ const SOCKET_CLI_DEBUG = 'SOCKET_CLI_DEBUG';
23
24
  const SOCKET_CLI_FIX_PACKAGE_LOCK_FILE = 'SOCKET_CLI_FIX_PACKAGE_LOCK_FILE';
24
25
  const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
25
26
  const SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE';
@@ -30,6 +31,8 @@ const LAZY_DIST_TYPE = () => registryConstants.SUPPORTS_NODE_REQUIRE_MODULE ? 'm
30
31
  const LAZY_ENV = () => Object.freeze({
31
32
  // Lazily access registryConstants.ENV.
32
33
  ...registryConstants.ENV,
34
+ // Flag set to help debug Socket CLI.
35
+ [SOCKET_CLI_DEBUG]: env.envAsBoolean(process.env[SOCKET_CLI_DEBUG]),
33
36
  // Flag set by the "fix" command to accept the package alerts prompt with
34
37
  // "Y(es)" in the SafeArborist reify method.
35
38
  [SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]: env.envAsBoolean(process.env[SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]),
@@ -74,6 +77,7 @@ const constants = createConstantsObject({
74
77
  NPM_REGISTRY_URL,
75
78
  NPX,
76
79
  PNPM,
80
+ SOCKET_CLI_DEBUG,
77
81
  SOCKET_CLI_FIX_PACKAGE_LOCK_FILE,
78
82
  SOCKET_CLI_ISSUES_URL,
79
83
  SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE,
@@ -20,8 +20,8 @@ var yargsParse = _socketInterop(require('yargs-parser'));
20
20
  var npm$1 = require('@socketsecurity/registry/lib/npm');
21
21
  var words = require('@socketsecurity/registry/lib/words');
22
22
  var constants = require('./constants.js');
23
- var spawn = _socketInterop(require('@npmcli/promise-spawn'));
24
23
  var spinner = require('@socketsecurity/registry/lib/spinner');
24
+ var spawn = _socketInterop(require('@npmcli/promise-spawn'));
25
25
  var meow = _socketInterop(require('meow'));
26
26
  var sdk = require('./sdk.js');
27
27
  var isInteractive = _socketInterop(require('is-interactive'));
@@ -219,22 +219,46 @@ const cdxgen = {
219
219
  };
220
220
 
221
221
  const {
222
- SOCKET_CLI_FIX_PACKAGE_LOCK_FILE,
223
- abortSignal: abortSignal$3,
224
- execPath: execPath$1,
225
- rootBinPath: rootBinPath$1
222
+ abortSignal: abortSignal$3
223
+ } = constants;
224
+ async function shadowNpmInstall(opts) {
225
+ const {
226
+ flags = [],
227
+ ...spawnOptions
228
+ } = {
229
+ __proto__: null,
230
+ ...opts
231
+ };
232
+ // Lazily access constants.ENV.
233
+ const {
234
+ SOCKET_CLI_DEBUG
235
+ } = constants.ENV;
236
+ return await spawn(
237
+ // Lazily access constants.execPath.
238
+ constants.execPath, [
239
+ // Lazily access constants.rootBinPath.
240
+ path.join(constants.rootBinPath, 'npm-cli.js'), 'install', ...(SOCKET_CLI_DEBUG ? ['silent'] : []), ...flags], {
241
+ signal: abortSignal$3,
242
+ // Lazily access constants.ENV.
243
+ stdio: SOCKET_CLI_DEBUG ? 'inherit' : 'ignore',
244
+ ...spawnOptions,
245
+ env: {
246
+ ...process.env,
247
+ ...spawnOptions.env
248
+ }
249
+ });
250
+ }
251
+
252
+ const {
253
+ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE
226
254
  } = constants;
227
255
  const fix = {
228
256
  description: 'Fix "fixable" Socket alerts',
229
257
  async run() {
230
- const wrapperPath = path.join(rootBinPath$1, 'npm-cli.js');
231
258
  const spinner$1 = new spinner.Spinner().start();
232
259
  try {
233
- await spawn(execPath$1, [wrapperPath, 'install'], {
234
- signal: abortSignal$3,
235
- stdio: 'inherit',
260
+ await shadowNpmInstall({
236
261
  env: {
237
- ...process.env,
238
262
  [SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]: '1'
239
263
  }
240
264
  });
@@ -1024,9 +1048,7 @@ const {
1024
1048
  VLT,
1025
1049
  YARN_BERRY,
1026
1050
  YARN_CLASSIC,
1027
- abortSignal: abortSignal$2,
1028
- execPath,
1029
- rootBinPath
1051
+ abortSignal: abortSignal$2
1030
1052
  } = constants;
1031
1053
  const COMMAND_TITLE = 'Socket Optimize';
1032
1054
  const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/7025';
@@ -1721,20 +1743,20 @@ const optimize = {
1721
1743
  spinner$1.start(`Updating ${lockName}...`);
1722
1744
  try {
1723
1745
  if (isNpm) {
1724
- const wrapperPath = path.join(rootBinPath, 'npm-cli.js');
1725
- const npmSpawnOptions = {
1726
- signal: abortSignal$2,
1727
- stdio: 'inherit',
1746
+ await shadowNpmInstall({
1728
1747
  env: {
1729
- ...process.env,
1730
1748
  [SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
1731
1749
  }
1732
- };
1733
- await spawn(execPath, [wrapperPath, 'install'], npmSpawnOptions);
1750
+ });
1734
1751
  // TODO: This is a temporary workaround for a `npm ci` bug where it
1735
1752
  // will error out after Socket Optimize generates a lock file. More
1736
1753
  // investigation is needed.
1737
- await spawn(execPath, [wrapperPath, 'install', '--ignore-scripts', '--package-lock-only'], npmSpawnOptions);
1754
+ await shadowNpmInstall({
1755
+ flags: ['--ignore-scripts', '--package-lock-only'],
1756
+ env: {
1757
+ [SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
1758
+ }
1759
+ });
1738
1760
  } else {
1739
1761
  // All package managers support the "install" command.
1740
1762
  await spawn(agentExecPath, ['install'], {
@@ -6,6 +6,7 @@ type Constants = {
6
6
  readonly BINARY_LOCK_EXT: '.lockb';
7
7
  readonly BUN: 'bun';
8
8
  readonly ENV: RegistryEnv & {
9
+ SOCKET_CLI_DEBUG: boolean;
9
10
  SOCKET_CLI_FIX_PACKAGE_LOCK_FILE: boolean;
10
11
  SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
11
12
  };
@@ -14,6 +15,7 @@ type Constants = {
14
15
  readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org';
15
16
  readonly NPX: 'npx';
16
17
  readonly PNPM: 'pnpm';
18
+ readonly SOCKET_CLI_DEBUG: 'SOCKET_CLI_DEBUG';
17
19
  readonly SOCKET_CLI_FIX_PACKAGE_LOCK_FILE: 'SOCKET_CLI_FIX_PACKAGE_LOCK_FILE';
18
20
  readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-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kCAAkC,CAAA;IAC7E,QAAQ,CAAC,qBAAqB,EAAE,gDAAgD,CAAA;IAChF,QAAQ,CAAC,gDAAgD,EAAE,kDAAkD,CAAA;IAC7G,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAA;IACjC,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,GAAG,OAAO,iBAAiB,CAAA;AAkF5B,QAAA,MAAM,SAAS,WA8Cd,CAAA"}
@@ -505,18 +505,14 @@ function walk(diff_) {
505
505
  action
506
506
  } = diff;
507
507
  if (action) {
508
- // The `oldNode`, i.e. `actual` node, may be `undefined` if there is no
509
- // node_modules folder.
508
+ // The `pkgNode`, i.e. the `ideal` node, will be `undefined` if the diff
509
+ // action is 'REMOVE'
510
+ // The `oldNode`, i.e. the `actual` node, will be `undefined` if the diff
511
+ // action is 'ADD'.
510
512
  const {
511
513
  actual: oldNode,
512
514
  ideal: pkgNode
513
515
  } = diff;
514
- if (!oldNode) {
515
- console.log('oldNode', oldNode);
516
- }
517
- if (!pkgNode) {
518
- console.log('pkgNode', pkgNode);
519
- }
520
516
  let existing;
521
517
  let keep = false;
522
518
  if (action === 'CHANGE') {
@@ -47,17 +47,19 @@ async function installLinks(realBinPath, binName) {
47
47
 
48
48
  const {
49
49
  NPM,
50
- abortSignal,
51
- distPath,
52
- execPath,
53
- shadowBinPath
50
+ abortSignal
54
51
  } = constants;
55
- const injectionPath = path.join(distPath, 'npm-injection.js');
56
52
  async function shadow(binName, binArgs = process.argv.slice(2)) {
57
53
  process.exitCode = 1;
58
- const spawnPromise = spawn(execPath, [
54
+ const spawnPromise = spawn(
55
+ // Lazily access constants.execPath.
56
+ constants.execPath, [
59
57
  // Lazily access constants.nodeNoWarningsFlags.
60
- ...constants.nodeNoWarningsFlags, '--require', injectionPath, await installLinks(shadowBinPath, binName), ...binArgs,
58
+ ...constants.nodeNoWarningsFlags, '--require',
59
+ // Lazily access constants.distPath.
60
+ path.join(constants.distPath, 'npm-injection.js'),
61
+ // Lazily access constants.shadowBinPath.
62
+ await installLinks(constants.shadowBinPath, binName), ...binArgs,
61
63
  // Add the `--quiet` and `--no-progress` flags to fix input being swallowed
62
64
  // by the spinner when running the command with recent versions of npm.
63
65
  ...(binName === NPM && binArgs.includes('install') && !binArgs.includes('--no-progress') && !binArgs.includes('--quiet') ? ['--no-progress', '--quiet'] : [])], {
@@ -20,8 +20,8 @@ var yargsParse = _socketInterop(require('yargs-parser'));
20
20
  var npm$1 = require('@socketsecurity/registry/lib/npm');
21
21
  var words = require('@socketsecurity/registry/lib/words');
22
22
  var constants = require('./constants.js');
23
- var spawn = _socketInterop(require('@npmcli/promise-spawn'));
24
23
  var spinner = require('@socketsecurity/registry/lib/spinner');
24
+ var spawn = _socketInterop(require('@npmcli/promise-spawn'));
25
25
  var sdk = require('./sdk.js');
26
26
  var prompts = require('@socketsecurity/registry/lib/prompts');
27
27
  var fs$1 = require('node:fs/promises');
@@ -215,22 +215,46 @@ const cdxgen = {
215
215
  };
216
216
 
217
217
  const {
218
- SOCKET_CLI_FIX_PACKAGE_LOCK_FILE,
219
- abortSignal: abortSignal$3,
220
- execPath: execPath$1,
221
- rootBinPath: rootBinPath$1
218
+ abortSignal: abortSignal$3
219
+ } = constants;
220
+ async function shadowNpmInstall(opts) {
221
+ const {
222
+ flags = [],
223
+ ...spawnOptions
224
+ } = {
225
+ __proto__: null,
226
+ ...opts
227
+ };
228
+ // Lazily access constants.ENV.
229
+ const {
230
+ SOCKET_CLI_DEBUG
231
+ } = constants.ENV;
232
+ return await spawn(
233
+ // Lazily access constants.execPath.
234
+ constants.execPath, [
235
+ // Lazily access constants.rootBinPath.
236
+ path.join(constants.rootBinPath, 'npm-cli.js'), 'install', ...(SOCKET_CLI_DEBUG ? ['silent'] : []), ...flags], {
237
+ signal: abortSignal$3,
238
+ // Lazily access constants.ENV.
239
+ stdio: SOCKET_CLI_DEBUG ? 'inherit' : 'ignore',
240
+ ...spawnOptions,
241
+ env: {
242
+ ...process.env,
243
+ ...spawnOptions.env
244
+ }
245
+ });
246
+ }
247
+
248
+ const {
249
+ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE
222
250
  } = constants;
223
251
  const fix = {
224
252
  description: 'Fix "fixable" Socket alerts',
225
253
  async run() {
226
- const wrapperPath = path.join(rootBinPath$1, 'npm-cli.js');
227
254
  const spinner$1 = new spinner.Spinner().start();
228
255
  try {
229
- await spawn(execPath$1, [wrapperPath, 'install'], {
230
- signal: abortSignal$3,
231
- stdio: 'inherit',
256
+ await shadowNpmInstall({
232
257
  env: {
233
- ...process.env,
234
258
  [SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]: '1'
235
259
  }
236
260
  });
@@ -1020,9 +1044,7 @@ const {
1020
1044
  VLT,
1021
1045
  YARN_BERRY,
1022
1046
  YARN_CLASSIC,
1023
- abortSignal: abortSignal$2,
1024
- execPath,
1025
- rootBinPath
1047
+ abortSignal: abortSignal$2
1026
1048
  } = constants;
1027
1049
  const COMMAND_TITLE = 'Socket Optimize';
1028
1050
  const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/7025';
@@ -1717,20 +1739,20 @@ const optimize = {
1717
1739
  spinner$1.start(`Updating ${lockName}...`);
1718
1740
  try {
1719
1741
  if (isNpm) {
1720
- const wrapperPath = path.join(rootBinPath, 'npm-cli.js');
1721
- const npmSpawnOptions = {
1722
- signal: abortSignal$2,
1723
- stdio: 'inherit',
1742
+ await shadowNpmInstall({
1724
1743
  env: {
1725
- ...process.env,
1726
1744
  [SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
1727
1745
  }
1728
- };
1729
- await spawn(execPath, [wrapperPath, 'install'], npmSpawnOptions);
1746
+ });
1730
1747
  // TODO: This is a temporary workaround for a `npm ci` bug where it
1731
1748
  // will error out after Socket Optimize generates a lock file. More
1732
1749
  // investigation is needed.
1733
- await spawn(execPath, [wrapperPath, 'install', '--ignore-scripts', '--package-lock-only'], npmSpawnOptions);
1750
+ await shadowNpmInstall({
1751
+ flags: ['--ignore-scripts', '--package-lock-only'],
1752
+ env: {
1753
+ [SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
1754
+ }
1755
+ });
1734
1756
  } else {
1735
1757
  // All package managers support the "install" command.
1736
1758
  await spawn(agentExecPath, ['install'], {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,iBAAiB,MAAM,wCAAwC,CAAA;AAGtE,KAAK,WAAW,GAAG,OAAO,iBAAiB,CAAC,GAAG,CAAA;AAE/C,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAA;IAChD,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;IAClC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG;QAC1B,gCAAgC,EAAE,OAAO,CAAA;QACzC,gDAAgD,EAAE,OAAO,CAAA;KAC1D,CAAA;IACD,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,QAAQ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AA"}
@@ -505,18 +505,14 @@ function walk(diff_) {
505
505
  action
506
506
  } = diff;
507
507
  if (action) {
508
- // The `oldNode`, i.e. `actual` node, may be `undefined` if there is no
509
- // node_modules folder.
508
+ // The `pkgNode`, i.e. the `ideal` node, will be `undefined` if the diff
509
+ // action is 'REMOVE'
510
+ // The `oldNode`, i.e. the `actual` node, will be `undefined` if the diff
511
+ // action is 'ADD'.
510
512
  const {
511
513
  actual: oldNode,
512
514
  ideal: pkgNode
513
515
  } = diff;
514
- if (!oldNode) {
515
- console.log('oldNode', oldNode);
516
- }
517
- if (!pkgNode) {
518
- console.log('pkgNode', pkgNode);
519
- }
520
516
  let existing;
521
517
  let keep = false;
522
518
  if (action === 'CHANGE') {
@@ -47,17 +47,19 @@ async function installLinks(realBinPath, binName) {
47
47
 
48
48
  const {
49
49
  NPM,
50
- abortSignal,
51
- distPath,
52
- execPath,
53
- shadowBinPath
50
+ abortSignal
54
51
  } = constants;
55
- const injectionPath = path.join(distPath, 'npm-injection.js');
56
52
  async function shadow(binName, binArgs = process.argv.slice(2)) {
57
53
  process.exitCode = 1;
58
- const spawnPromise = spawn(execPath, [
54
+ const spawnPromise = spawn(
55
+ // Lazily access constants.execPath.
56
+ constants.execPath, [
59
57
  // Lazily access constants.nodeNoWarningsFlags.
60
- ...constants.nodeNoWarningsFlags, '--require', injectionPath, await installLinks(shadowBinPath, binName), ...binArgs,
58
+ ...constants.nodeNoWarningsFlags, '--require',
59
+ // Lazily access constants.distPath.
60
+ path.join(constants.distPath, 'npm-injection.js'),
61
+ // Lazily access constants.shadowBinPath.
62
+ await installLinks(constants.shadowBinPath, binName), ...binArgs,
61
63
  // Add the `--quiet` and `--no-progress` flags to fix input being swallowed
62
64
  // by the spinner when running the command with recent versions of npm.
63
65
  ...(binName === NPM && binArgs.includes('install') && !binArgs.includes('--no-progress') && !binArgs.includes('--quiet') ? ['--no-progress', '--quiet'] : [])], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket",
3
- "version": "0.14.40-alpha.7",
3
+ "version": "0.14.40-alpha.9",
4
4
  "description": "CLI tool for Socket.dev",
5
5
  "homepage": "http://github.com/SocketDev/socket-cli",
6
6
  "license": "MIT",
@@ -58,10 +58,10 @@
58
58
  "@apideck/better-ajv-errors": "^0.3.6",
59
59
  "@cyclonedx/cdxgen": "^11.0.10",
60
60
  "@npmcli/promise-spawn": "^8.0.2",
61
- "@socketregistry/hyrious__bun.lockb": "1.0.9",
62
- "@socketregistry/yocto-spinner": "^1.0.2",
61
+ "@socketregistry/hyrious__bun.lockb": "1.0.10",
62
+ "@socketregistry/yocto-spinner": "^1.0.3",
63
63
  "@socketsecurity/config": "^2.1.3",
64
- "@socketsecurity/registry": "^1.0.67",
64
+ "@socketsecurity/registry": "^1.0.68",
65
65
  "@socketsecurity/sdk": "^1.4.5",
66
66
  "blessed": "^0.1.81",
67
67
  "blessed-contrib": "^4.11.0",
@@ -70,7 +70,7 @@
70
70
  "cmd-shim": "^7.0.0",
71
71
  "has-flag": "^4.0.0",
72
72
  "hpagent": "^1.2.0",
73
- "ignore": "^7.0.1",
73
+ "ignore": "^7.0.3",
74
74
  "is-interactive": "^2.0.0",
75
75
  "is-unicode-supported": "^2.1.0",
76
76
  "meow": "^13.2.0",
@@ -110,7 +110,7 @@
110
110
  "@types/micromatch": "^4.0.9",
111
111
  "@types/mocha": "^10.0.10",
112
112
  "@types/mock-fs": "^4.13.4",
113
- "@types/node": "^22.10.5",
113
+ "@types/node": "^22.10.6",
114
114
  "@types/npmcli__arborist": "^5.6.11",
115
115
  "@types/npmcli__promise-spawn": "^6.0.3",
116
116
  "@types/proc-log": "^3.0.4",