@socketsecurity/cli 0.14.134 → 0.14.136

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.
@@ -8,57 +8,6 @@ const path = require('node:path')
8
8
  const vendor = require('./vendor.js')
9
9
  const shadowNpmPaths = require('./shadow-npm-paths.js')
10
10
  const constants = require('./constants.js')
11
- require('node:fs')
12
- require('node:os')
13
- require('node:fs/promises')
14
- require('node:buffer')
15
- require('node:util')
16
- require('node:path')
17
- require('node:fs')
18
- require('node:tty')
19
- require('node:https')
20
- require('node:http')
21
- require('node:url')
22
- require('node:process')
23
- require('node:events')
24
- require('node:http')
25
- require('node:https')
26
- require('node:readline')
27
- require('@socketsecurity/registry/lib/constants/abort-signal')
28
- require('node:util')
29
- require('node:url')
30
- require('node:fs/promises')
31
- require('node:child_process')
32
- require('node:os')
33
- require('node:tty')
34
- require('node:crypto')
35
- require('node:constants')
36
- require('node:stream')
37
- require('node:assert')
38
- require('node:stream')
39
- require('node:string_decoder')
40
- require('node:path/win32')
41
- require('node:module')
42
- require('node:events')
43
- require('node:buffer')
44
- require('node:string_decoder')
45
- require('node:child_process')
46
- require('node:module')
47
- require('@socketsecurity/registry/lib/logger')
48
- require('@socketsecurity/registry/lib/path')
49
- require('@socketsecurity/registry/lib/words')
50
- require('./shadow-npm-inject.js')
51
- require('@socketsecurity/registry/lib/arrays')
52
- require('@socketsecurity/registry')
53
- require('@socketsecurity/registry/lib/objects')
54
- require('@socketsecurity/registry/lib/constants')
55
- require('@socketsecurity/registry/lib/prompts')
56
- require('@socketsecurity/registry/lib/strings')
57
- require('@socketsecurity/registry/lib/fs')
58
- require('@socketsecurity/registry/lib/packages')
59
- require('node:timers/promises')
60
- require('@socketsecurity/registry/lib/sorts')
61
- require('@socketsecurity/registry/lib/env')
62
11
 
63
12
  const { CLI, NPX } = constants
64
13
  async function installLinks(realBinPath, binName) {
@@ -153,5 +102,5 @@ async function shadowBin(binName, args = process.argv.slice(2)) {
153
102
  }
154
103
 
155
104
  module.exports = shadowBin
156
- //# debugId=313e790a-5075-4e29-8eaf-c781fda83d6e
105
+ //# debugId=c07c77d4-8583-4c6b-9a6a-0361d5c81ac7
157
106
  //# sourceMappingURL=shadow-bin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shadow-bin.js","sources":["../src/shadow/npm/link.ts","../src/shadow/npm/bin.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\n\nimport cmdShim from 'cmd-shim'\n\nimport {\n getNpmBinPath,\n getNpxBinPath,\n isNpmBinPathShadowed,\n isNpxBinPathShadowed\n} from './paths'\nimport constants from '../../constants'\n\nconst { CLI, NPX } = constants\n\nexport async function installLinks(\n realBinPath: string,\n binName: 'npm' | 'npx'\n): Promise<string> {\n const isNpx = binName === NPX\n // Find package manager being shadowed by this process.\n const binPath = isNpx ? getNpxBinPath() : getNpmBinPath()\n // Lazily access constants.WIN32.\n const { WIN32 } = constants\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n const shadowed = isNpx ? isNpxBinPathShadowed() : isNpmBinPathShadowed()\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n // Lazily access constants.rootDistPath.\n path.join(constants.rootDistPath, `${binName}-${CLI}.js`),\n path.join(realBinPath, binName)\n )\n }\n const { env } = process\n env['PATH'] = `${realBinPath}${path.delimiter}${env['PATH']}`\n }\n return binPath\n}\n","import process from 'node:process'\n\nimport { isDebug } from '@socketsecurity/registry/lib/debug'\nimport {\n isLoglevelFlag,\n isProgressFlag\n} from '@socketsecurity/registry/lib/npm'\nimport { spawn } from '@socketsecurity/registry/lib/spawn'\n\nimport { installLinks } from './link'\nimport constants from '../../constants'\n\nconst { SOCKET_CLI_SAFE_BIN, SOCKET_CLI_SAFE_PROGRESS, SOCKET_IPC_HANDSHAKE } =\n constants\n\nexport default async function shadowBin(\n binName: 'npm' | 'npx',\n args = process.argv.slice(2)\n) {\n process.exitCode = 1\n const useDebug = isDebug()\n const terminatorPos = args.indexOf('--')\n const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n const progressArg = rawBinArgs.findLast(isProgressFlag) !== '--no-progress'\n const binArgs = rawBinArgs.filter(a => !isProgressFlag(a))\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n const isSilent = !useDebug && !binArgs.some(isLoglevelFlag)\n // The default value of loglevel is \"notice\". We default to \"error\" which is\n // two levels quieter.\n const logLevelArgs = isSilent ? ['--loglevel', 'error'] : []\n const spawnPromise = spawn(\n // Lazily access constants.execPath.\n constants.execPath,\n [\n // Lazily access constants.nodeHardenFlags.\n ...constants.nodeHardenFlags,\n // Lazily access constants.nodeNoWarningsFlags.\n ...constants.nodeNoWarningsFlags,\n // Lazily access process.env['INLINED_SOCKET_CLI_SENTRY_BUILD'].\n ...(process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']\n ? [\n '--require',\n // Lazily access constants.distInstrumentWithSentryPath.\n constants.distInstrumentWithSentryPath\n ]\n : []),\n '--require',\n // Lazily access constants.distShadowNpmInjectPath.\n constants.distShadowNpmInjectPath,\n // Lazily access constants.shadowBinPath.\n await installLinks(constants.shadowBinPath, binName),\n // Add '--no-progress' to fix input being swallowed by the npm spinner.\n '--no-progress',\n // Add '--loglevel=error' if a loglevel flag is not provided and the\n // SOCKET_CLI_DEBUG environment variable is not truthy.\n ...logLevelArgs,\n ...binArgs,\n ...otherArgs\n ],\n {\n // 'inherit' + 'ipc'\n stdio: [0, 1, 2, 'ipc']\n }\n )\n // See https://nodejs.org/api/all.html#all_child_process_event-exit.\n spawnPromise.process.on('exit', (code, signalName) => {\n if (signalName) {\n process.kill(process.pid, signalName)\n } else if (code !== null) {\n // eslint-disable-next-line n/no-process-exit\n process.exit(code)\n }\n })\n spawnPromise.process.send({\n [SOCKET_IPC_HANDSHAKE]: {\n [SOCKET_CLI_SAFE_BIN]: binName,\n [SOCKET_CLI_SAFE_PROGRESS]: progressArg\n }\n })\n await spawnPromise\n}\n"],"names":["NPX","WIN32","env","SOCKET_IPC_HANDSHAKE","constants","process","spawnPromise"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;AAAaA;AAAI;AAEV;AAIL;AACA;;AAEA;;AACQC;AAAM;AACd;;AAEE;AACF;;AAEA;;AAEE;AACE;AACE;;AAIJ;;AACQC;AAAI;AACZA;AACF;AACA;AACF;;AC9BA;;;AAAuDC;AAAqB;AAG7D;;AAKb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGE;;AAGE;;AAEA;;AAEA;;AASA;AACAC;AACA;AACA;AACA;;AAEA;AACA;;AAMA;;AAEF;AAEF;;AAEE;;AAEA;AACE;AACAC;AACF;AACF;AACAC;AACE;;AAEE;AACF;AACF;AACA;AACF;;","debugId":"313e790a-5075-4e29-8eaf-c781fda83d6e"}
1
+ {"version":3,"file":"shadow-bin.js","sources":["../src/shadow/npm/link.ts","../src/shadow/npm/bin.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\n\nimport cmdShim from 'cmd-shim'\n\nimport {\n getNpmBinPath,\n getNpxBinPath,\n isNpmBinPathShadowed,\n isNpxBinPathShadowed\n} from './paths'\nimport constants from '../../constants'\n\nconst { CLI, NPX } = constants\n\nexport async function installLinks(\n realBinPath: string,\n binName: 'npm' | 'npx'\n): Promise<string> {\n const isNpx = binName === NPX\n // Find package manager being shadowed by this process.\n const binPath = isNpx ? getNpxBinPath() : getNpmBinPath()\n // Lazily access constants.WIN32.\n const { WIN32 } = constants\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n const shadowed = isNpx ? isNpxBinPathShadowed() : isNpmBinPathShadowed()\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n // Lazily access constants.rootDistPath.\n path.join(constants.rootDistPath, `${binName}-${CLI}.js`),\n path.join(realBinPath, binName)\n )\n }\n const { env } = process\n env['PATH'] = `${realBinPath}${path.delimiter}${env['PATH']}`\n }\n return binPath\n}\n","import process from 'node:process'\n\nimport { isDebug } from '@socketsecurity/registry/lib/debug'\nimport {\n isLoglevelFlag,\n isProgressFlag\n} from '@socketsecurity/registry/lib/npm'\nimport { spawn } from '@socketsecurity/registry/lib/spawn'\n\nimport { installLinks } from './link'\nimport constants from '../../constants'\n\nconst { SOCKET_CLI_SAFE_BIN, SOCKET_CLI_SAFE_PROGRESS, SOCKET_IPC_HANDSHAKE } =\n constants\n\nexport default async function shadowBin(\n binName: 'npm' | 'npx',\n args = process.argv.slice(2)\n) {\n process.exitCode = 1\n const useDebug = isDebug()\n const terminatorPos = args.indexOf('--')\n const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n const progressArg = rawBinArgs.findLast(isProgressFlag) !== '--no-progress'\n const binArgs = rawBinArgs.filter(a => !isProgressFlag(a))\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n const isSilent = !useDebug && !binArgs.some(isLoglevelFlag)\n // The default value of loglevel is \"notice\". We default to \"error\" which is\n // two levels quieter.\n const logLevelArgs = isSilent ? ['--loglevel', 'error'] : []\n const spawnPromise = spawn(\n // Lazily access constants.execPath.\n constants.execPath,\n [\n // Lazily access constants.nodeHardenFlags.\n ...constants.nodeHardenFlags,\n // Lazily access constants.nodeNoWarningsFlags.\n ...constants.nodeNoWarningsFlags,\n // Lazily access process.env['INLINED_SOCKET_CLI_SENTRY_BUILD'].\n ...(process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']\n ? [\n '--require',\n // Lazily access constants.distInstrumentWithSentryPath.\n constants.distInstrumentWithSentryPath\n ]\n : []),\n '--require',\n // Lazily access constants.distShadowNpmInjectPath.\n constants.distShadowNpmInjectPath,\n // Lazily access constants.shadowBinPath.\n await installLinks(constants.shadowBinPath, binName),\n // Add '--no-progress' to fix input being swallowed by the npm spinner.\n '--no-progress',\n // Add '--loglevel=error' if a loglevel flag is not provided and the\n // SOCKET_CLI_DEBUG environment variable is not truthy.\n ...logLevelArgs,\n ...binArgs,\n ...otherArgs\n ],\n {\n // 'inherit' + 'ipc'\n stdio: [0, 1, 2, 'ipc']\n }\n )\n // See https://nodejs.org/api/all.html#all_child_process_event-exit.\n spawnPromise.process.on('exit', (code, signalName) => {\n if (signalName) {\n process.kill(process.pid, signalName)\n } else if (code !== null) {\n // eslint-disable-next-line n/no-process-exit\n process.exit(code)\n }\n })\n spawnPromise.process.send({\n [SOCKET_IPC_HANDSHAKE]: {\n [SOCKET_CLI_SAFE_BIN]: binName,\n [SOCKET_CLI_SAFE_PROGRESS]: progressArg\n }\n })\n await spawnPromise\n}\n"],"names":["NPX","WIN32","env","SOCKET_IPC_HANDSHAKE","constants","process","spawnPromise"],"mappings":";;;;;;;;;;;AAaA;;AAAaA;AAAI;AAEV;AAIL;AACA;;AAEA;;AACQC;AAAM;AACd;;AAEE;AACF;;AAEA;;AAEE;AACE;AACE;;AAIJ;;AACQC;AAAI;AACZA;AACF;AACA;AACF;;AC9BA;;;AAAuDC;AAAqB;AAG7D;;AAKb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGE;;AAGE;;AAEA;;AAEA;;AASA;AACAC;AACA;AACA;AACA;;AAEA;AACA;;AAMA;;AAEF;AAEF;;AAEE;;AAEA;AACE;AACAC;AACF;AACF;AACAC;AACE;;AAEE;AACF;AACF;AACA;AACF;;","debugId":"c07c77d4-8583-4c6b-9a6a-0361d5c81ac7"}
@@ -6,6 +6,7 @@ const vendor = require('./vendor.js')
6
6
  const logger = require('@socketsecurity/registry/lib/logger')
7
7
  const constants = require('./constants.js')
8
8
  const arrays = require('@socketsecurity/registry/lib/arrays')
9
+ const packages = require('@socketsecurity/registry/lib/packages')
9
10
  const registry = require('@socketsecurity/registry')
10
11
  const objects = require('@socketsecurity/registry/lib/objects')
11
12
  const debug = require('@socketsecurity/registry/lib/debug')
@@ -16,48 +17,8 @@ const fs = require('node:fs')
16
17
  const os = require('node:os')
17
18
  const path = require('node:path')
18
19
  const fs$1 = require('@socketsecurity/registry/lib/fs')
19
- const packages = require('@socketsecurity/registry/lib/packages')
20
20
  const promises = require('node:timers/promises')
21
21
  const sorts = require('@socketsecurity/registry/lib/sorts')
22
- require('node:module')
23
- require('@socketsecurity/registry/lib/path')
24
- require('@socketsecurity/registry/lib/npm')
25
- require('@socketsecurity/registry/lib/words')
26
- require('./shadow-npm-inject.js')
27
- require('node:fs/promises')
28
- require('node:buffer')
29
- require('node:util')
30
- require('node:path')
31
- require('node:fs')
32
- require('node:tty')
33
- require('node:https')
34
- require('node:http')
35
- require('node:url')
36
- require('node:process')
37
- require('node:events')
38
- require('node:http')
39
- require('node:https')
40
- require('node:readline')
41
- require('@socketsecurity/registry/lib/constants/abort-signal')
42
- require('node:util')
43
- require('node:url')
44
- require('node:fs/promises')
45
- require('node:child_process')
46
- require('node:os')
47
- require('node:tty')
48
- require('node:crypto')
49
- require('node:constants')
50
- require('node:stream')
51
- require('node:assert')
52
- require('node:stream')
53
- require('node:string_decoder')
54
- require('node:path/win32')
55
- require('node:module')
56
- require('node:events')
57
- require('node:buffer')
58
- require('node:string_decoder')
59
- require('node:child_process')
60
- require('@socketsecurity/registry/lib/env')
61
22
 
62
23
  const { NPM: NPM$3, PNPM } = constants
63
24
  const PNPM_WORKSPACE = `${PNPM}-workspace`
@@ -662,7 +623,7 @@ async function setupSdk(
662
623
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_NAME']".
663
624
  name: 'socket',
664
625
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
665
- version: '0.14.134',
626
+ version: '0.14.136',
666
627
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_HOMEPAGE']".
667
628
  homepage: 'https://github.com/SocketDev/socket-cli'
668
629
  })
@@ -2365,10 +2326,11 @@ async function getAlertsMapFromPnpmLockfile(lockfile, options_) {
2365
2326
  }
2366
2327
  const depTypes = vendor.libExports$1.detectDepTypes(lockfile)
2367
2328
  const purls = Object.keys(depTypes).map(id => {
2368
- const lastAtSignIndex = id.lastIndexOf('@')
2369
- const name = id.slice(0, lastAtSignIndex)
2370
- const version = id.slice(lastAtSignIndex + 1)
2371
- return `pkg:npm/${name}@${vendor.semverExports.coerce(version)}`
2329
+ const purlObj = vendor.packageurlJsExports.PackageURL.fromString(
2330
+ `pkg:npm/${id}`
2331
+ )
2332
+ const name = packages.resolvePackageName(purlObj)
2333
+ return `pkg:npm/${name}@${vendor.semverExports.coerce(purlObj.version)}`
2372
2334
  })
2373
2335
  return await getAlertsMapFromPurls(purls, {
2374
2336
  overrides: lockfile.overrides,
@@ -2646,5 +2608,5 @@ exports.supportedConfigKeys = supportedConfigKeys
2646
2608
  exports.updateConfigValue = updateConfigValue
2647
2609
  exports.updateNode = updateNode
2648
2610
  exports.updatePackageJsonFromNode = updatePackageJsonFromNode
2649
- //# debugId=c11dabdd-174f-4ec7-a2e2-784eeeb79026
2611
+ //# debugId=9c835d76-48f0-4f82-a2c5-a1bbc9854cc9
2650
2612
  //# sourceMappingURL=shadow-npm-inject.js.map