@socketsecurity/cli-with-sentry 0.14.154 → 0.14.155

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 (97) hide show
  1. package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
  2. package/dist/cli.js +1289 -2453
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +7 -6
  5. package/dist/constants.js.map +1 -1
  6. package/dist/instrument-with-sentry.js +10 -3
  7. package/dist/instrument-with-sentry.js.map +1 -1
  8. package/dist/shadow-bin.js +5 -7
  9. package/dist/shadow-bin.js.map +1 -1
  10. package/dist/shadow-npm-inject.js +130 -1646
  11. package/dist/shadow-npm-inject.js.map +1 -1
  12. package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
  13. package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +1 -1
  14. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +1 -1
  15. package/dist/types/commands/analytics/handle-analytics.d.mts.map +1 -1
  16. package/dist/types/commands/analytics/output-analytics.d.mts +15 -16
  17. package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
  18. package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +1 -1
  19. package/dist/types/commands/cdxgen/cmd-cdxgen.d.mts.map +1 -1
  20. package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +1 -1
  21. package/dist/types/commands/dependencies/fetch-dependencies.d.mts.map +1 -1
  22. package/dist/types/commands/diff-scan/fetch-diff-scan.d.mts.map +1 -1
  23. package/dist/types/commands/fix/git.d.mts +9 -1
  24. package/dist/types/commands/fix/git.d.mts.map +1 -1
  25. package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
  26. package/dist/types/commands/fix/open-pr.d.mts +30 -16
  27. package/dist/types/commands/fix/open-pr.d.mts.map +1 -1
  28. package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
  29. package/dist/types/commands/info/fetch-package-info.d.mts.map +1 -1
  30. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  31. package/dist/types/commands/npm/wrap-npm.d.mts.map +1 -1
  32. package/dist/types/commands/npx/wrap-npx.d.mts.map +1 -1
  33. package/dist/types/commands/optimize/deps-includes-by-agent.d.mts +1 -1
  34. package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +1 -1
  35. package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts +1 -1
  36. package/dist/types/commands/optimize/ls-by-agent.d.mts +1 -1
  37. package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +1 -1
  38. package/dist/types/commands/organization/fetch-license-policy.d.mts.map +1 -1
  39. package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
  40. package/dist/types/commands/organization/fetch-quota.d.mts.map +1 -1
  41. package/dist/types/commands/organization/fetch-security-policy.d.mts.map +1 -1
  42. package/dist/types/commands/package/fetch-purl-deep-score.d.mts.map +1 -1
  43. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
  44. package/dist/types/commands/repos/fetch-create-repo.d.mts.map +1 -1
  45. package/dist/types/commands/repos/fetch-delete-repo.d.mts.map +1 -1
  46. package/dist/types/commands/repos/fetch-list-repos.d.mts.map +1 -1
  47. package/dist/types/commands/repos/fetch-update-repo.d.mts.map +1 -1
  48. package/dist/types/commands/repos/fetch-view-repo.d.mts.map +1 -1
  49. package/dist/types/commands/repos/handle-create-repo.d.mts.map +1 -1
  50. package/dist/types/commands/repos/output-create-repo.d.mts +1 -1
  51. package/dist/types/commands/repos/output-create-repo.d.mts.map +1 -1
  52. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
  53. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +1 -1
  54. package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +1 -1
  55. package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
  56. package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
  57. package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +1 -1
  58. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +1 -1
  59. package/dist/types/commands/scan/stream-scan.d.mts +1 -1
  60. package/dist/types/commands/scan/stream-scan.d.mts.map +1 -1
  61. package/dist/types/commands/scan/suggest-org-slug.d.mts.map +1 -1
  62. package/dist/types/commands/threat-feed/output-threat-feed.d.mts.map +1 -1
  63. package/dist/types/constants.d.mts +1 -1
  64. package/dist/types/constants.d.mts.map +1 -1
  65. package/dist/types/shadow/npm/arborist/lib/dep-valid.d.mts +2 -2
  66. package/dist/types/shadow/npm/arborist/lib/dep-valid.d.mts.map +1 -1
  67. package/dist/types/{utils → shadow/npm}/arborist-helpers.d.mts +19 -3
  68. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -0
  69. package/dist/types/{utils/npm.d.mts → shadow/npm/install.d.mts} +2 -2
  70. package/dist/types/shadow/npm/install.d.mts.map +1 -0
  71. package/dist/types/shadow/npm/paths.d.mts +0 -6
  72. package/dist/types/shadow/npm/paths.d.mts.map +1 -1
  73. package/dist/types/utils/agent.d.mts +2 -2
  74. package/dist/types/utils/agent.d.mts.map +1 -1
  75. package/dist/types/utils/alerts-map.d.mts +0 -11
  76. package/dist/types/utils/alerts-map.d.mts.map +1 -1
  77. package/dist/types/utils/api.d.mts +15 -5
  78. package/dist/types/utils/api.d.mts.map +1 -1
  79. package/dist/types/utils/npm-paths.d.mts +7 -0
  80. package/dist/types/utils/npm-paths.d.mts.map +1 -0
  81. package/dist/types/utils/pnpm.d.mts +2 -1
  82. package/dist/types/utils/pnpm.d.mts.map +1 -1
  83. package/dist/types/utils/translations.d.mts.map +1 -1
  84. package/dist/utils.js +3169 -0
  85. package/dist/utils.js.map +1 -0
  86. package/dist/vendor.js +1284 -1231
  87. package/dist/vendor.js.map +1 -1
  88. package/external/@socketsecurity/registry/external/browserslist.js +382 -366
  89. package/external/@socketsecurity/registry/external/browserslist.js.map +1 -1
  90. package/external/@socketsecurity/registry/lib/constants/maintained-node-versions.js +7 -8
  91. package/external/@socketsecurity/registry/lib/fs.d.ts +6 -4
  92. package/external/@socketsecurity/registry/package.json +5 -5
  93. package/package.json +19 -19
  94. package/dist/shadow-npm-paths.js +0 -291
  95. package/dist/shadow-npm-paths.js.map +0 -1
  96. package/dist/types/utils/arborist-helpers.d.mts.map +0 -1
  97. package/dist/types/utils/npm.d.mts.map +0 -1
@@ -6,17 +6,15 @@
6
6
  // So we maintain a manual version list for now.
7
7
  // https://nodejs.org/en/about/previous-releases#looking-for-latest-release-of-a-version-branch
8
8
  //
9
- // Updated March 5th, 2025.
10
- const manualNext = '23.9.0'
11
- const manualCurr = '22.14.0'
12
- const manualPrev = '20.18.3'
13
- const manualLast = '18.20.7'
9
+ // Updated May 5th, 2025.
10
+ const manualNext = '23.11.0'
11
+ const manualCurr = '22.15.0'
12
+ const manualPrev = '20.19.1'
13
+ const manualLast = '20.19.1'
14
14
 
15
15
  const browsersList = /*@__PURE__*/ require('../../external/browserslist')
16
- const semver = /*@__PURE__*/ require('../../external/semver')
17
-
18
16
  const query = browsersList('maintained node versions')
19
- // Trim value, e.g. 'node 22.5.0' to '22.5.0'.
17
+ // Trim value, e.g. 'node 22.15.0' to '22.15.0'.
20
18
  .map(s => s.slice(5 /*'node '.length*/))
21
19
  // browsersList returns results in descending order.
22
20
  const queryNext = query.at(0) ?? manualNext
@@ -24,6 +22,7 @@ const queryCurr = query.at(1) ?? manualCurr
24
22
  const queryPrev = query.at(2) ?? manualPrev
25
23
  const queryLast = query.at(-1) ?? manualLast
26
24
 
25
+ const semver = /*@__PURE__*/ require('../../external/semver')
27
26
  const next = semver.maxSatisfying(
28
27
  [queryNext, manualNext],
29
28
  `^${semver.major(queryNext)}`
@@ -23,6 +23,7 @@ declare type BufferEncoding =
23
23
  | 'utf-16le'
24
24
  | 'ucs2'
25
25
  | 'ucs-2'
26
+ declare type JsonContent = NPMCliPackageJson.Content
26
27
  declare type ReadFileOptions =
27
28
  | Remap<
28
29
  ObjectEncodingOptions & {
@@ -63,28 +64,29 @@ declare const Fs: {
63
64
  readJson(
64
65
  filepath: PathLike,
65
66
  options?: ReadJsonOptions | undefined
66
- ): Promise<NPMCliPackageJson.Content>
67
+ ): Promise<JsonContent>
67
68
  readJsonSync(
68
69
  filepath: PathLike,
69
70
  options?: ReadJsonOptions | undefined
70
- ): NPMCliPackageJson.Content
71
+ ): JsonContent
71
72
  remove(filepath: PathLike, options?: RmOptions): Promise<void>
72
73
  removeSync(filepath: PathLike, options?: RmOptions): void
73
74
  uniqueSync(filepath: PathLike): string
74
75
  writeJson(
75
76
  filepath: PathLike,
76
- json: NPMCliPackageJson.Content,
77
+ json: JsonContent,
77
78
  options?: WriteJsonOptions | undefined
78
79
  ): Promise<void>
79
80
  writeJsonSync(
80
81
  filepath: PathLike,
81
- json: NPMCliPackageJson.Content,
82
+ json: JsonContent,
82
83
  options?: WriteJsonOptions | undefined
83
84
  ): void
84
85
  }
85
86
  declare namespace Fs {
86
87
  export {
87
88
  BufferEncoding,
89
+ JsonContent,
88
90
  ReadFileOptions,
89
91
  ReadJsonOptions,
90
92
  ReadDirOptions,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/registry",
3
- "version": "1.0.159",
3
+ "version": "1.0.160",
4
4
  "license": "MIT",
5
5
  "description": "Socket.dev registry helpers methods and metadata",
6
6
  "keywords": [
@@ -611,19 +611,19 @@
611
611
  "@socketregistry/yocto-spinner": "1.0.13",
612
612
  "@types/pacote": "11.1.8",
613
613
  "@yarnpkg/extensions": "2.0.5",
614
- "browserslist": "4.24.4",
614
+ "browserslist": "4.24.5",
615
615
  "cacache": "19.0.1",
616
616
  "cross-env": "7.0.3",
617
617
  "del-cli": "6.0.0",
618
618
  "dev-null-cli": "2.0.0",
619
- "eslint": "9.25.1",
619
+ "eslint": "9.26.0",
620
620
  "fast-sort": "3.4.1",
621
621
  "libnpmpack": "9.0.2",
622
622
  "make-fetch-happen": "14.0.3",
623
623
  "normalize-package-data": "6.0.1",
624
624
  "npm-package-arg": "12.0.2",
625
- "npm-run-all2": "7.0.2",
626
- "oxlint": "0.16.8",
625
+ "npm-run-all2": "8.0.1",
626
+ "oxlint": "0.16.9",
627
627
  "pacote": "21.0.0",
628
628
  "picomatch": "4.0.2",
629
629
  "rollup": "4.40.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/cli-with-sentry",
3
- "version": "0.14.154",
3
+ "version": "0.14.155",
4
4
  "description": "CLI tool for Socket.dev, includes Sentry error handling, otherwise identical to the regular `socket` package",
5
5
  "homepage": "https://github.com/SocketDev/socket-cli",
6
6
  "license": "MIT",
@@ -83,9 +83,9 @@
83
83
  "@babel/preset-typescript": "7.27.1",
84
84
  "@babel/runtime": "7.27.1",
85
85
  "@biomejs/biome": "1.9.4",
86
- "@cyclonedx/cdxgen": "11.2.6",
87
- "@eslint/compat": "1.2.8",
88
- "@eslint/js": "9.25.1",
86
+ "@cyclonedx/cdxgen": "11.2.7",
87
+ "@eslint/compat": "1.2.9",
88
+ "@eslint/js": "9.26.0",
89
89
  "@octokit/graphql": "8.2.2",
90
90
  "@octokit/openapi-types": "25.0.0",
91
91
  "@octokit/request-error": "6.1.8",
@@ -106,30 +106,30 @@
106
106
  "@socketregistry/is-interactive": "1.0.5",
107
107
  "@socketregistry/packageurl-js": "1.0.6",
108
108
  "@socketsecurity/config": "2.1.3",
109
- "@socketsecurity/registry": "1.0.159",
110
- "@socketsecurity/sdk": "1.4.30",
109
+ "@socketsecurity/registry": "1.0.160",
110
+ "@socketsecurity/sdk": "1.4.32",
111
111
  "@types/blessed": "0.1.25",
112
112
  "@types/cmd-shim": "5.0.2",
113
113
  "@types/micromatch": "4.0.9",
114
114
  "@types/mock-fs": "4.13.4",
115
- "@types/node": "22.15.3",
115
+ "@types/node": "22.15.14",
116
116
  "@types/npmcli__arborist": "6.3.0",
117
117
  "@types/proc-log": "3.0.4",
118
118
  "@types/semver": "7.7.0",
119
119
  "@types/which": "3.0.4",
120
120
  "@types/yargs-parser": "21.0.3",
121
- "@typescript-eslint/parser": "8.31.1",
122
- "@vitest/coverage-v8": "3.1.2",
121
+ "@typescript-eslint/parser": "8.32.0",
122
+ "@vitest/coverage-v8": "3.1.3",
123
123
  "blessed": "0.1.81",
124
124
  "blessed-contrib": "4.11.0",
125
- "browserslist": "4.24.4",
125
+ "browserslist": "4.24.5",
126
126
  "chalk-table": "1.0.2",
127
127
  "cmd-shim": "7.0.0",
128
128
  "cross-env": "7.0.3",
129
129
  "custompatch": "1.1.4",
130
130
  "del-cli": "6.0.0",
131
131
  "dev-null-cli": "2.0.0",
132
- "eslint": "9.25.1",
132
+ "eslint": "9.26.0",
133
133
  "eslint-import-resolver-typescript": "4.3.4",
134
134
  "eslint-plugin-import-x": "4.11.0",
135
135
  "eslint-plugin-n": "17.17.0",
@@ -139,19 +139,19 @@
139
139
  "hpagent": "1.2.0",
140
140
  "husky": "9.1.7",
141
141
  "ignore": "7.0.4",
142
- "knip": "5.52.0",
143
- "lint-staged": "15.5.1",
142
+ "knip": "5.54.1",
143
+ "lint-staged": "15.5.2",
144
144
  "magic-string": "0.30.17",
145
145
  "meow": "13.2.0",
146
146
  "micromatch": "4.0.8",
147
147
  "mock-fs": "5.5.0",
148
148
  "nock": "14.0.4",
149
149
  "npm-package-arg": "12.0.2",
150
- "npm-run-all2": "7.0.2",
150
+ "npm-run-all2": "8.0.1",
151
151
  "open": "10.1.2",
152
- "oxlint": "0.16.8",
152
+ "oxlint": "0.16.9",
153
153
  "pony-cause": "2.1.11",
154
- "rollup": "4.40.1",
154
+ "rollup": "4.40.2",
155
155
  "semver": "7.7.1",
156
156
  "synp": "1.9.14",
157
157
  "terminal-link": "2.1.1",
@@ -159,9 +159,9 @@
159
159
  "tinyglobby": "0.2.13",
160
160
  "type-coverage": "2.29.7",
161
161
  "typescript": "5.8.3",
162
- "typescript-eslint": "8.31.1",
162
+ "typescript-eslint": "8.32.0",
163
163
  "unplugin-purge-polyfills": "0.1.0",
164
- "vitest": "3.1.2",
164
+ "vitest": "3.1.3",
165
165
  "which": "5.0.0",
166
166
  "yaml": "2.7.1",
167
167
  "yargs-parser": "21.1.1",
@@ -194,7 +194,7 @@
194
194
  "tiny-colors": "$yoctocolors-cjs",
195
195
  "typedarray": "npm:@socketregistry/typedarray@^1",
196
196
  "undici": "6.21.1",
197
- "vite": "6.2.7",
197
+ "vite": "6.3.5",
198
198
  "xml2js": "0.5.0",
199
199
  "yaml": "2.7.1"
200
200
  },
@@ -1,291 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('node:fs')
4
- const Module = require('node:module')
5
- const path = require('node:path')
6
- const logger = require('../external/@socketsecurity/registry/lib/logger')
7
- const path$1 = require('../external/@socketsecurity/registry/lib/path')
8
- const constants = require('./constants.js')
9
- const vendor = require('./vendor.js')
10
- const debug = require('../external/@socketsecurity/registry/lib/debug')
11
- const npm = require('../external/@socketsecurity/registry/lib/npm')
12
- const words = require('../external/@socketsecurity/registry/lib/words')
13
- const shadowNpmInject = require('./shadow-npm-inject.js')
14
-
15
- const { NODE_MODULES: NODE_MODULES$1, NPM: NPM$1, shadowBinPath } = constants
16
- function findBinPathDetailsSync(binName) {
17
- const binPaths =
18
- vendor.libExports$3.sync(binName, {
19
- all: true,
20
- nothrow: true
21
- }) ?? []
22
- let shadowIndex = -1
23
- let theBinPath
24
- for (let i = 0, { length } = binPaths; i < length; i += 1) {
25
- const binPath = binPaths[i]
26
- // Skip our bin directory if it's in the front.
27
- if (path.dirname(binPath) === shadowBinPath) {
28
- shadowIndex = i
29
- } else {
30
- theBinPath = npm.resolveBinPath(binPath)
31
- break
32
- }
33
- }
34
- return {
35
- name: binName,
36
- path: theBinPath,
37
- shadowed: shadowIndex !== -1
38
- }
39
- }
40
- function findNpmPathSync(npmBinPath) {
41
- // Lazily access constants.WIN32.
42
- const { WIN32 } = constants
43
- let thePath = npmBinPath
44
- while (true) {
45
- const libNmNpmPath = path.join(thePath, 'lib', NODE_MODULES$1, NPM$1)
46
- // mise puts its npm bin in a path like:
47
- // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
48
- // HOWEVER, the location of the npm install is:
49
- // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/lib/node_modules/npm.
50
- if (
51
- // Use existsSync here because statsSync, even with { throwIfNoEntry: false },
52
- // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
53
- // See https://github.com/nodejs/node/issues/56993.
54
- fs.existsSync(libNmNpmPath) &&
55
- fs
56
- .statSync(libNmNpmPath, {
57
- throwIfNoEntry: false
58
- })
59
- ?.isDirectory()
60
- ) {
61
- thePath = path.join(libNmNpmPath, NPM$1)
62
- }
63
- const nmPath = path.join(thePath, NODE_MODULES$1)
64
- if (
65
- // npm bin paths may look like:
66
- // /usr/local/share/npm/bin/npm
67
- // /Users/SomeUsername/.nvm/versions/node/vX.X.X/bin/npm
68
- // C:\Users\SomeUsername\AppData\Roaming\npm\bin\npm.cmd
69
- // OR
70
- // C:\Program Files\nodejs\npm.cmd
71
- //
72
- // In practically all cases the npm path contains a node_modules folder:
73
- // /usr/local/share/npm/bin/npm/node_modules
74
- // C:\Program Files\nodejs\node_modules
75
- fs.existsSync(nmPath) &&
76
- fs
77
- .statSync(nmPath, {
78
- throwIfNoEntry: false
79
- })
80
- ?.isDirectory() &&
81
- // Optimistically look for the default location.
82
- (path.basename(thePath) === NPM$1 ||
83
- // Chocolatey installs npm bins in the same directory as node bins.
84
- (WIN32 && fs.existsSync(path.join(thePath, `${NPM$1}.cmd`))))
85
- ) {
86
- return thePath
87
- }
88
- const parent = path.dirname(thePath)
89
- if (parent === thePath) {
90
- return undefined
91
- }
92
- thePath = parent
93
- }
94
- }
95
- async function getPackageFilesForScan(cwd, inputPaths, supportedFiles, config) {
96
- debug.debugLog(
97
- `getPackageFilesForScan: resolving ${inputPaths.length} paths:\n`,
98
- inputPaths
99
- )
100
-
101
- // Lazily access constants.spinner.
102
- const { spinner } = constants
103
- const patterns = shadowNpmInject.pathsToGlobPatterns(inputPaths)
104
- spinner.start('Searching for local files to include in scan...')
105
- const entries = await shadowNpmInject.globWithGitIgnore(patterns, {
106
- cwd,
107
- socketConfig: config
108
- })
109
- if (debug.isDebug()) {
110
- spinner.stop()
111
- debug.debugLog(
112
- `Resolved ${inputPaths.length} paths to ${entries.length} local paths:\n`,
113
- entries
114
- )
115
- spinner.start('Searching for files now...')
116
- } else {
117
- spinner.start(
118
- `Resolved ${inputPaths.length} paths to ${entries.length} local paths, searching for files now...`
119
- )
120
- }
121
- const packageFiles = await shadowNpmInject.filterGlobResultToSupportedFiles(
122
- entries,
123
- supportedFiles
124
- )
125
- spinner.successAndStop(
126
- `Found ${packageFiles.length} local ${words.pluralize('file', packageFiles.length)}`
127
- )
128
- debug.debugLog('Absolute paths:\n', packageFiles)
129
- return packageFiles
130
- }
131
-
132
- const { NODE_MODULES, NPM, NPX, SOCKET_CLI_ISSUES_URL } = constants
133
- function exitWithBinPathError(binName) {
134
- logger.logger.fail(
135
- `Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`
136
- )
137
- // The exit code 127 indicates that the command or binary being executed
138
- // could not be found.
139
- // eslint-disable-next-line n/no-process-exit
140
- process.exit(127)
141
- }
142
- let _npmBinPathDetails
143
- function getNpmBinPathDetails() {
144
- if (_npmBinPathDetails === undefined) {
145
- _npmBinPathDetails = findBinPathDetailsSync(NPM)
146
- }
147
- return _npmBinPathDetails
148
- }
149
- let _npxBinPathDetails
150
- function getNpxBinPathDetails() {
151
- if (_npxBinPathDetails === undefined) {
152
- _npxBinPathDetails = findBinPathDetailsSync(NPX)
153
- }
154
- return _npxBinPathDetails
155
- }
156
- let _npmBinPath
157
- function getNpmBinPath() {
158
- if (_npmBinPath === undefined) {
159
- _npmBinPath = getNpmBinPathDetails().path
160
- if (!_npmBinPath) {
161
- exitWithBinPathError(NPM)
162
- }
163
- }
164
- return _npmBinPath
165
- }
166
- function isNpmBinPathShadowed() {
167
- return getNpmBinPathDetails().shadowed
168
- }
169
- let _npxBinPath
170
- function getNpxBinPath() {
171
- if (_npxBinPath === undefined) {
172
- _npxBinPath = getNpxBinPathDetails().path
173
- if (!_npxBinPath) {
174
- exitWithBinPathError(NPX)
175
- }
176
- }
177
- return _npxBinPath
178
- }
179
- function isNpxBinPathShadowed() {
180
- return getNpxBinPathDetails().shadowed
181
- }
182
- let _npmPath
183
- function getNpmPath() {
184
- if (_npmPath === undefined) {
185
- const npmBinPath = getNpmBinPath()
186
- _npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined
187
- if (!_npmPath) {
188
- let message = 'Unable to find npm CLI install directory.'
189
- if (npmBinPath) {
190
- message += `\nSearched parent directories of ${path.dirname(npmBinPath)}.`
191
- }
192
- message += `\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`
193
- logger.logger.fail(message)
194
- // The exit code 127 indicates that the command or binary being executed
195
- // could not be found.
196
- // eslint-disable-next-line n/no-process-exit
197
- process.exit(127)
198
- }
199
- }
200
- return _npmPath
201
- }
202
- let _npmRequire
203
- function getNpmRequire() {
204
- if (_npmRequire === undefined) {
205
- const npmPath = getNpmPath()
206
- const npmNmPath = path.join(npmPath, NODE_MODULES, NPM)
207
- _npmRequire = Module.createRequire(
208
- path.join(
209
- fs.existsSync(npmNmPath) ? npmNmPath : npmPath,
210
- '<dummy-basename>'
211
- )
212
- )
213
- }
214
- return _npmRequire
215
- }
216
- let _arboristPkgPath
217
- function getArboristPackagePath() {
218
- if (_arboristPkgPath === undefined) {
219
- const pkgName = '@npmcli/arborist'
220
- const mainPathWithForwardSlashes = path$1.normalizePath(
221
- getNpmRequire().resolve(pkgName)
222
- )
223
- const arboristPkgPathWithForwardSlashes = mainPathWithForwardSlashes.slice(
224
- 0,
225
- mainPathWithForwardSlashes.lastIndexOf(pkgName) + pkgName.length
226
- )
227
- // Lazily access constants.WIN32.
228
- _arboristPkgPath = constants.WIN32
229
- ? path.normalize(arboristPkgPathWithForwardSlashes)
230
- : arboristPkgPathWithForwardSlashes
231
- }
232
- return _arboristPkgPath
233
- }
234
- let _arboristClassPath
235
- function getArboristClassPath() {
236
- if (_arboristClassPath === undefined) {
237
- _arboristClassPath = path.join(
238
- getArboristPackagePath(),
239
- 'lib/arborist/index.js'
240
- )
241
- }
242
- return _arboristClassPath
243
- }
244
- let _arboristDepValidPath
245
- function getArboristDepValidPath() {
246
- if (_arboristDepValidPath === undefined) {
247
- _arboristDepValidPath = path.join(
248
- getArboristPackagePath(),
249
- 'lib/dep-valid.js'
250
- )
251
- }
252
- return _arboristDepValidPath
253
- }
254
- let _arboristEdgeClassPath
255
- function getArboristEdgeClassPath() {
256
- if (_arboristEdgeClassPath === undefined) {
257
- _arboristEdgeClassPath = path.join(getArboristPackagePath(), 'lib/edge.js')
258
- }
259
- return _arboristEdgeClassPath
260
- }
261
- let _arboristNodeClassPath
262
- function getArboristNodeClassPath() {
263
- if (_arboristNodeClassPath === undefined) {
264
- _arboristNodeClassPath = path.join(getArboristPackagePath(), 'lib/node.js')
265
- }
266
- return _arboristNodeClassPath
267
- }
268
- let _arboristOverrideSetClassPath
269
- function getArboristOverrideSetClassPath() {
270
- if (_arboristOverrideSetClassPath === undefined) {
271
- _arboristOverrideSetClassPath = path.join(
272
- getArboristPackagePath(),
273
- 'lib/override-set.js'
274
- )
275
- }
276
- return _arboristOverrideSetClassPath
277
- }
278
-
279
- exports.getArboristClassPath = getArboristClassPath
280
- exports.getArboristDepValidPath = getArboristDepValidPath
281
- exports.getArboristEdgeClassPath = getArboristEdgeClassPath
282
- exports.getArboristNodeClassPath = getArboristNodeClassPath
283
- exports.getArboristOverrideSetClassPath = getArboristOverrideSetClassPath
284
- exports.getNpmBinPath = getNpmBinPath
285
- exports.getNpmRequire = getNpmRequire
286
- exports.getNpxBinPath = getNpxBinPath
287
- exports.getPackageFilesForScan = getPackageFilesForScan
288
- exports.isNpmBinPathShadowed = isNpmBinPathShadowed
289
- exports.isNpxBinPathShadowed = isNpxBinPathShadowed
290
- //# debugId=b482d192-205f-4708-8cc8-9c74bbc66f2b
291
- //# sourceMappingURL=shadow-npm-paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow-npm-paths.js","sources":["../src/utils/path-resolve.mts","../src/shadow/npm/paths.mts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs'\nimport path from 'node:path'\n\nimport which from 'which'\n\nimport { debugLog, isDebug } from '@socketsecurity/registry/lib/debug'\nimport { resolveBinPath } from '@socketsecurity/registry/lib/npm'\nimport { pluralize } from '@socketsecurity/registry/lib/words'\n\nimport constants from '../constants.mts'\nimport {\n filterGlobResultToSupportedFiles,\n globWithGitIgnore,\n pathsToGlobPatterns\n} from './glob.mts'\n\nimport type { SocketYml } from '@socketsecurity/config'\nimport type { SocketSdkReturnType } from '@socketsecurity/sdk'\n\nconst { NODE_MODULES, NPM, shadowBinPath } = constants\n\nexport function findBinPathDetailsSync(binName: string): {\n name: string\n path: string | undefined\n shadowed: boolean\n} {\n const binPaths =\n which.sync(binName, {\n all: true,\n nothrow: true\n }) ?? []\n let shadowIndex = -1\n let theBinPath: string | undefined\n for (let i = 0, { length } = binPaths; i < length; i += 1) {\n const binPath = binPaths[i]!\n // Skip our bin directory if it's in the front.\n if (path.dirname(binPath) === shadowBinPath) {\n shadowIndex = i\n } else {\n theBinPath = resolveBinPath(binPath)\n break\n }\n }\n return { name: binName, path: theBinPath, shadowed: shadowIndex !== -1 }\n}\n\nexport function findNpmPathSync(npmBinPath: string): string | undefined {\n // Lazily access constants.WIN32.\n const { WIN32 } = constants\n let thePath = npmBinPath\n while (true) {\n const libNmNpmPath = path.join(thePath, 'lib', NODE_MODULES, NPM)\n // mise puts its npm bin in a path like:\n // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.\n // HOWEVER, the location of the npm install is:\n // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/lib/node_modules/npm.\n if (\n // Use existsSync here because statsSync, even with { throwIfNoEntry: false },\n // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.\n // See https://github.com/nodejs/node/issues/56993.\n existsSync(libNmNpmPath) &&\n statSync(libNmNpmPath, { throwIfNoEntry: false })?.isDirectory()\n ) {\n thePath = path.join(libNmNpmPath, NPM)\n }\n const nmPath = path.join(thePath, NODE_MODULES)\n if (\n // npm bin paths may look like:\n // /usr/local/share/npm/bin/npm\n // /Users/SomeUsername/.nvm/versions/node/vX.X.X/bin/npm\n // C:\\Users\\SomeUsername\\AppData\\Roaming\\npm\\bin\\npm.cmd\n // OR\n // C:\\Program Files\\nodejs\\npm.cmd\n //\n // In practically all cases the npm path contains a node_modules folder:\n // /usr/local/share/npm/bin/npm/node_modules\n // C:\\Program Files\\nodejs\\node_modules\n existsSync(nmPath) &&\n statSync(nmPath, { throwIfNoEntry: false })?.isDirectory() &&\n // Optimistically look for the default location.\n (path.basename(thePath) === NPM ||\n // Chocolatey installs npm bins in the same directory as node bins.\n (WIN32 && existsSync(path.join(thePath, `${NPM}.cmd`))))\n ) {\n return thePath\n }\n const parent = path.dirname(thePath)\n if (parent === thePath) {\n return undefined\n }\n thePath = parent\n }\n}\n\nexport async function getPackageFilesForScan(\n cwd: string,\n inputPaths: string[],\n supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'],\n config?: SocketYml | undefined\n): Promise<string[]> {\n debugLog(\n `getPackageFilesForScan: resolving ${inputPaths.length} paths:\\n`,\n inputPaths\n )\n\n // Lazily access constants.spinner.\n const { spinner } = constants\n\n const patterns = pathsToGlobPatterns(inputPaths)\n\n spinner.start('Searching for local files to include in scan...')\n\n const entries = await globWithGitIgnore(patterns, {\n cwd,\n socketConfig: config\n })\n\n if (isDebug()) {\n spinner.stop()\n debugLog(\n `Resolved ${inputPaths.length} paths to ${entries.length} local paths:\\n`,\n entries\n )\n spinner.start('Searching for files now...')\n } else {\n spinner.start(\n `Resolved ${inputPaths.length} paths to ${entries.length} local paths, searching for files now...`\n )\n }\n\n const packageFiles = await filterGlobResultToSupportedFiles(\n entries,\n supportedFiles\n )\n\n spinner.successAndStop(\n `Found ${packageFiles.length} local ${pluralize('file', packageFiles.length)}`\n )\n debugLog('Absolute paths:\\n', packageFiles)\n\n return packageFiles\n}\n","import { existsSync } from 'node:fs'\nimport Module from 'node:module'\nimport path from 'node:path'\n\nimport { logger } from '@socketsecurity/registry/lib/logger'\nimport { normalizePath } from '@socketsecurity/registry/lib/path'\n\nimport constants from '../../constants.mts'\nimport {\n findBinPathDetailsSync,\n findNpmPathSync\n} from '../../utils/path-resolve.mts'\n\nconst { NODE_MODULES, NPM, NPX, SOCKET_CLI_ISSUES_URL } = constants\n\nfunction exitWithBinPathError(binName: string): never {\n logger.fail(\n `Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`\n )\n // The exit code 127 indicates that the command or binary being executed\n // could not be found.\n // eslint-disable-next-line n/no-process-exit\n process.exit(127)\n}\n\nlet _npmBinPathDetails: ReturnType<typeof findBinPathDetailsSync> | undefined\nfunction getNpmBinPathDetails(): ReturnType<typeof findBinPathDetailsSync> {\n if (_npmBinPathDetails === undefined) {\n _npmBinPathDetails = findBinPathDetailsSync(NPM)\n }\n return _npmBinPathDetails\n}\n\nlet _npxBinPathDetails: ReturnType<typeof findBinPathDetailsSync> | undefined\nfunction getNpxBinPathDetails(): ReturnType<typeof findBinPathDetailsSync> {\n if (_npxBinPathDetails === undefined) {\n _npxBinPathDetails = findBinPathDetailsSync(NPX)\n }\n return _npxBinPathDetails\n}\n\nlet _npmBinPath: string | undefined\nexport function getNpmBinPath(): string {\n if (_npmBinPath === undefined) {\n _npmBinPath = getNpmBinPathDetails().path\n if (!_npmBinPath) {\n exitWithBinPathError(NPM)\n }\n }\n return _npmBinPath\n}\n\nexport function isNpmBinPathShadowed() {\n return getNpmBinPathDetails().shadowed\n}\n\nlet _npxBinPath: string | undefined\nexport function getNpxBinPath(): string {\n if (_npxBinPath === undefined) {\n _npxBinPath = getNpxBinPathDetails().path\n if (!_npxBinPath) {\n exitWithBinPathError(NPX)\n }\n }\n return _npxBinPath\n}\n\nexport function isNpxBinPathShadowed() {\n return getNpxBinPathDetails().shadowed\n}\n\nlet _npmPath: string | undefined\nexport function getNpmPath() {\n if (_npmPath === undefined) {\n const npmBinPath = getNpmBinPath()\n _npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined\n if (!_npmPath) {\n let message = 'Unable to find npm CLI install directory.'\n if (npmBinPath) {\n message += `\\nSearched parent directories of ${path.dirname(npmBinPath)}.`\n }\n message += `\\n\\nThis is may be a bug with socket-npm related to changes to the npm CLI.\\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`\n logger.fail(message)\n // The exit code 127 indicates that the command or binary being executed\n // could not be found.\n // eslint-disable-next-line n/no-process-exit\n process.exit(127)\n }\n }\n return _npmPath\n}\n\nlet _npmRequire: NodeJS.Require | undefined\nexport function getNpmRequire(): NodeJS.Require {\n if (_npmRequire === undefined) {\n const npmPath = getNpmPath()\n const npmNmPath = path.join(npmPath, NODE_MODULES, NPM)\n _npmRequire = Module.createRequire(\n path.join(existsSync(npmNmPath) ? npmNmPath : npmPath, '<dummy-basename>')\n )\n }\n return _npmRequire\n}\n\nlet _arboristPkgPath: string | undefined\nexport function getArboristPackagePath() {\n if (_arboristPkgPath === undefined) {\n const pkgName = '@npmcli/arborist'\n const mainPathWithForwardSlashes = normalizePath(\n getNpmRequire().resolve(pkgName)\n )\n const arboristPkgPathWithForwardSlashes = mainPathWithForwardSlashes.slice(\n 0,\n mainPathWithForwardSlashes.lastIndexOf(pkgName) + pkgName.length\n )\n // Lazily access constants.WIN32.\n _arboristPkgPath = constants.WIN32\n ? path.normalize(arboristPkgPathWithForwardSlashes)\n : arboristPkgPathWithForwardSlashes\n }\n return _arboristPkgPath\n}\n\nlet _arboristClassPath: string | undefined\nexport function getArboristClassPath() {\n if (_arboristClassPath === undefined) {\n _arboristClassPath = path.join(\n getArboristPackagePath(),\n 'lib/arborist/index.js'\n )\n }\n return _arboristClassPath\n}\n\nlet _arboristDepValidPath: string | undefined\nexport function getArboristDepValidPath() {\n if (_arboristDepValidPath === undefined) {\n _arboristDepValidPath = path.join(\n getArboristPackagePath(),\n 'lib/dep-valid.js'\n )\n }\n return _arboristDepValidPath\n}\n\nlet _arboristEdgeClassPath: string | undefined\nexport function getArboristEdgeClassPath() {\n if (_arboristEdgeClassPath === undefined) {\n _arboristEdgeClassPath = path.join(getArboristPackagePath(), 'lib/edge.js')\n }\n return _arboristEdgeClassPath\n}\n\nlet _arboristNodeClassPath: string | undefined\nexport function getArboristNodeClassPath() {\n if (_arboristNodeClassPath === undefined) {\n _arboristNodeClassPath = path.join(getArboristPackagePath(), 'lib/node.js')\n }\n return _arboristNodeClassPath\n}\n\nlet _arboristOverrideSetClassPath: string | undefined\nexport function getArboristOverrideSetClassPath() {\n if (_arboristOverrideSetClassPath === undefined) {\n _arboristOverrideSetClassPath = path.join(\n getArboristPackagePath(),\n 'lib/override-set.js'\n )\n }\n return _arboristOverrideSetClassPath\n}\n"],"names":["shadowBinPath","all","nothrow","length","shadowIndex","theBinPath","name","path","WIN32","existsSync","throwIfNoEntry","thePath","spinner","socketConfig","debugLog","SOCKET_CLI_ISSUES_URL","logger","process","_npmBinPathDetails","_npxBinPathDetails","_npmBinPath","_npxBinPath","_arboristPkgPath"],"mappings":";;;;;;;;;;;;;;AAmBA;;;AAA2BA;AAAc;AAElC;AAKL;AAEIC;AACAC;;;AAGJ;AACA;AAAkBC;;AAChB;AACA;;AAEEC;AACF;AACEC;AACA;AACF;AACF;;AACSC;AAAeC;;;AAC1B;AAEO;AACL;;AACQC;AAAM;;AAEd;AACE;AACA;AACA;AACA;AACA;AACA;AACE;AACA;AACA;AACAC;AACyBC;AAAsB;;AAGjD;;AAEA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD;AACmBC;AAAsB;AACzC;AACCH;AACC;AACCC;AAEH;AACF;AACA;;AAEE;AACF;AACAG;AACF;AACF;AAEO;;;AAWL;;AACQC;AAAQ;AAEhB;AAEAA;AAEA;;AAEEC;AACF;;;AAIEC;AAIAF;AACF;AACEA;AAGF;;AAOAA;AAGAE;AAEA;AACF;;AChIA;;;;AAAgCC;AAAsB;AAEtD;AACEC;AAGA;AACA;AACA;AACAC;AACF;AAEA;AACA;;AAEIC;AACF;AACA;AACF;AAEA;AACA;;AAEIC;AACF;AACA;AACF;AAEA;AACO;;AAEHC;;;AAGA;AACF;AACA;AACF;AAEO;AACL;AACF;AAEA;AACO;;AAEHC;;;AAGA;AACF;AACA;AACF;AAEO;AACL;AACF;AAEA;AACO;;AAEH;;;;AAIE;;AAEA;;AAEAL;AACA;AACA;AACA;AACAC;AACF;AACF;AACA;AACF;AAEA;AACO;;AAEH;;;AAKF;AACA;AACF;AAEA;AACO;;;AAGH;AAGA;AAIA;AACAK;AAGF;AACA;AACF;AAEA;AACO;;;AAML;AACA;AACF;AAEA;AACO;;;AAML;AACA;AACF;AAEA;AACO;;;AAGL;AACA;AACF;AAEA;AACO;;;AAGL;AACA;AACF;AAEA;AACO;;;AAML;AACA;AACF;;;;;;;;;;;;","debugId":"b482d192-205f-4708-8cc8-9c74bbc66f2b"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"arborist-helpers.d.mts","sourceRoot":"","sources":["../../../src/utils/arborist-helpers.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAQ7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAchF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,QAAQ,EACd,iBAAiB,EAAE,MAAM,EAAE,EAC3B,sBAAsB,CAAC,EAAE,MAAM,EAC/B,8BAA8B,CAAC,EAAE,MAAM,GAAG,SAAS,GAClD,MAAM,GAAG,IAAI,CAwBf;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAC3B,QAAQ,GAAG,SAAS,CAiBtB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAC3B,QAAQ,EAAE,CAmBZ;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC/B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC,CAAA;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,GACrC,aAAa,EAAE,CA+EjB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAElE;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,CAC7B,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,EACjD,IAAI,CACL,CAAA;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,GACjD,IAAI,CAsDN;AAED,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,mBAAmB,EACpC,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,GAClC,OAAO,CA+BT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm.d.mts","sourceRoot":"","sources":["../../../src/utils/npm.mts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAA;AAK1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AASnE,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AAElE,KAAK,qBAAqB,GAAG,WAAW,GAAG;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IAC/C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,kGAgF7D"}