@socketsecurity/cli-with-sentry 0.14.129 → 0.14.131
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 +37 -44
- package/bin/npx-cli.js +1 -3
- package/dist/{module-sync/cli.js → cli.js} +336 -338
- package/dist/cli.js.map +1 -0
- package/dist/constants.js +8 -25
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +3 -14
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/{module-sync/shadow-bin.js → shadow-bin.js} +52 -1
- package/dist/shadow-bin.js.map +1 -0
- package/dist/{module-sync/shadow-npm-inject.js → shadow-npm-inject.js} +67 -48
- package/dist/shadow-npm-inject.js.map +1 -0
- package/dist/shadow-npm-paths.js.map +1 -0
- package/dist/{module-sync/vendor.js → vendor.js} +10320 -4778
- package/dist/vendor.js.map +1 -0
- package/package.json +16 -26
- package/dist/constants.d.ts +0 -285
- package/dist/instrument-with-sentry.d.ts +0 -1
- package/dist/module-sync/arborist-helpers.d.ts +0 -69
- package/dist/module-sync/artifact.d.ts +0 -63
- package/dist/module-sync/cli.d.ts +0 -2
- package/dist/module-sync/cli.js.map +0 -1
- package/dist/module-sync/cmd.d.ts +0 -4
- package/dist/module-sync/config.d.ts +0 -44
- package/dist/module-sync/constants.js +0 -3
- package/dist/module-sync/edge.d.ts +0 -78
- package/dist/module-sync/errors.d.ts +0 -29
- package/dist/module-sync/fs.d.ts +0 -63
- package/dist/module-sync/index.d.ts +0 -34
- package/dist/module-sync/node.d.ts +0 -121
- package/dist/module-sync/override-set.d.ts +0 -43
- package/dist/module-sync/package-environment.d.ts +0 -83
- package/dist/module-sync/path-resolve.d.ts +0 -15
- package/dist/module-sync/sdk.d.ts +0 -9
- package/dist/module-sync/semver.d.ts +0 -17
- package/dist/module-sync/shadow-bin.d.ts +0 -5
- package/dist/module-sync/shadow-bin.js.map +0 -1
- package/dist/module-sync/shadow-npm-inject.d.ts +0 -1
- package/dist/module-sync/shadow-npm-inject.js.map +0 -1
- package/dist/module-sync/shadow-npm-paths.d.ts +0 -27
- package/dist/module-sync/shadow-npm-paths.js.map +0 -1
- package/dist/module-sync/socket-package-alert.d.ts +0 -104
- package/dist/module-sync/vendor.d.ts +0 -0
- package/dist/module-sync/vendor.js.map +0 -1
- package/dist/require/cli.d.ts +0 -2
- package/dist/require/cli.js +0 -12361
- package/dist/require/cli.js.map +0 -1
- package/dist/require/constants.js +0 -3
- package/dist/require/shadow-bin.d.ts +0 -5
- package/dist/require/shadow-bin.js +0 -110
- package/dist/require/shadow-bin.js.map +0 -1
- package/dist/require/shadow-npm-inject.d.ts +0 -1
- package/dist/require/shadow-npm-inject.js +0 -2616
- package/dist/require/shadow-npm-inject.js.map +0 -1
- package/dist/require/shadow-npm-paths.d.ts +0 -27
- package/dist/require/shadow-npm-paths.js +0 -292
- package/dist/require/shadow-npm-paths.js.map +0 -1
- package/dist/require/vendor.js +0 -3
- /package/dist/{module-sync/shadow-npm-paths.js → shadow-npm-paths.js} +0 -0
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
function _socketInterop(e) {
|
|
4
|
-
let c = 0
|
|
5
|
-
for (const k in e ?? {}) {
|
|
6
|
-
c = c === 0 && k === 'default' ? 1 : 0
|
|
7
|
-
if (!c && k !== '__esModule') {
|
|
8
|
-
break
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return c ? e.default : e
|
|
12
|
-
}
|
|
13
|
-
|
|
14
3
|
const process$1 = require('node:process')
|
|
15
|
-
const require$$0
|
|
4
|
+
const require$$0 = require('node:url')
|
|
16
5
|
const vendor = require('./vendor.js')
|
|
17
6
|
const debug = require('@socketsecurity/registry/lib/debug')
|
|
18
7
|
const logger = require('@socketsecurity/registry/lib/logger')
|
|
@@ -30,18 +19,50 @@ const fs$1 = require('node:fs')
|
|
|
30
19
|
const shadowBin = require('./shadow-bin.js')
|
|
31
20
|
const prompts = require('@socketsecurity/registry/lib/prompts')
|
|
32
21
|
const shadowNpmPaths = require('./shadow-npm-paths.js')
|
|
33
|
-
const
|
|
22
|
+
const util = require('node:util')
|
|
34
23
|
const arrays = require('@socketsecurity/registry/lib/arrays')
|
|
35
24
|
const registry = require('@socketsecurity/registry')
|
|
36
25
|
const npm = require('@socketsecurity/registry/lib/npm')
|
|
37
26
|
const packages = require('@socketsecurity/registry/lib/packages')
|
|
38
|
-
const packageurlJs = require('@socketregistry/packageurl-js')
|
|
39
27
|
const spawn = require('@socketsecurity/registry/lib/spawn')
|
|
40
|
-
const index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs')
|
|
41
28
|
const sorts = require('@socketsecurity/registry/lib/sorts')
|
|
42
29
|
const registryConstants = require('@socketsecurity/registry/lib/constants')
|
|
43
|
-
const isInteractive = require('@socketregistry/is-interactive/index.cjs')
|
|
44
30
|
const promises = require('@socketsecurity/registry/lib/promises')
|
|
31
|
+
require('node:os')
|
|
32
|
+
require('node:buffer')
|
|
33
|
+
require('node:util')
|
|
34
|
+
require('node:path')
|
|
35
|
+
require('node:fs')
|
|
36
|
+
require('node:tty')
|
|
37
|
+
require('node:https')
|
|
38
|
+
require('node:http')
|
|
39
|
+
require('node:url')
|
|
40
|
+
require('node:process')
|
|
41
|
+
require('node:events')
|
|
42
|
+
require('node:http')
|
|
43
|
+
require('node:https')
|
|
44
|
+
require('node:readline')
|
|
45
|
+
require('@socketsecurity/registry/lib/constants/abort-signal')
|
|
46
|
+
require('node:fs/promises')
|
|
47
|
+
require('node:child_process')
|
|
48
|
+
require('node:os')
|
|
49
|
+
require('node:tty')
|
|
50
|
+
require('node:crypto')
|
|
51
|
+
require('node:constants')
|
|
52
|
+
require('node:stream')
|
|
53
|
+
require('node:assert')
|
|
54
|
+
require('node:stream')
|
|
55
|
+
require('node:string_decoder')
|
|
56
|
+
require('node:path/win32')
|
|
57
|
+
require('node:module')
|
|
58
|
+
require('node:events')
|
|
59
|
+
require('node:buffer')
|
|
60
|
+
require('node:string_decoder')
|
|
61
|
+
require('node:child_process')
|
|
62
|
+
require('@socketsecurity/registry/lib/fs')
|
|
63
|
+
require('node:timers/promises')
|
|
64
|
+
require('node:module')
|
|
65
|
+
require('@socketsecurity/registry/lib/env')
|
|
45
66
|
|
|
46
67
|
function failMsgWithBadge(badge, msg) {
|
|
47
68
|
return `${vendor.yoctocolorsCjsExports.bgRed(vendor.yoctocolorsCjsExports.bold(vendor.yoctocolorsCjsExports.white(` ${badge}: `)))} ${vendor.yoctocolorsCjsExports.bold(msg)}`
|
|
@@ -401,12 +422,12 @@ ${mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
|
|
|
401
422
|
`
|
|
402
423
|
}
|
|
403
424
|
function displayAnalyticsScreen(data) {
|
|
404
|
-
const ScreenWidget =
|
|
425
|
+
const ScreenWidget = require('blessed/lib/widgets/screen')
|
|
405
426
|
// Lazily access constants.blessedOptions.
|
|
406
427
|
const screen = new ScreenWidget({
|
|
407
428
|
...constants.blessedOptions
|
|
408
429
|
})
|
|
409
|
-
const contrib =
|
|
430
|
+
const contrib = require('blessed-contrib')
|
|
410
431
|
const grid = new contrib.grid({
|
|
411
432
|
rows: 5,
|
|
412
433
|
cols: 4,
|
|
@@ -564,7 +585,7 @@ function formatDate(date) {
|
|
|
564
585
|
return `${Months[new Date(date).getMonth()]} ${new Date(date).getDate()}`
|
|
565
586
|
}
|
|
566
587
|
function renderLineCharts(grid, screen, title, coords, data) {
|
|
567
|
-
const contrib =
|
|
588
|
+
const contrib = require('blessed-contrib')
|
|
568
589
|
const line = grid.set(...coords, contrib.line, {
|
|
569
590
|
style: {
|
|
570
591
|
line: 'cyan',
|
|
@@ -917,7 +938,7 @@ function emitBanner(name) {
|
|
|
917
938
|
logger.logger.error(getAsciiHeader(name))
|
|
918
939
|
}
|
|
919
940
|
function getAsciiHeader(command) {
|
|
920
|
-
const cliVersion = '0.14.
|
|
941
|
+
const cliVersion = '0.14.131:fb1cc4f:889bca7f:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
921
942
|
const nodeVersion = process$1.version
|
|
922
943
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
923
944
|
const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
|
|
@@ -3535,7 +3556,7 @@ async function outputDiffScan$1(result, { depth, file, outputKind }) {
|
|
|
3535
3556
|
|
|
3536
3557
|
logger.logger.log('Diff scan result:')
|
|
3537
3558
|
logger.logger.log(
|
|
3538
|
-
|
|
3559
|
+
util.inspect(result, {
|
|
3539
3560
|
showHidden: false,
|
|
3540
3561
|
depth: depth > 0 ? depth : null,
|
|
3541
3562
|
colors: true,
|
|
@@ -3746,7 +3767,7 @@ function getBaseGitBranch() {
|
|
|
3746
3767
|
)
|
|
3747
3768
|
}
|
|
3748
3769
|
function getSocketBranchName(purl, newVersion, workspaceName) {
|
|
3749
|
-
const purlObj =
|
|
3770
|
+
const purlObj = vendor.packageurlJsExports.PackageURL.fromString(purl)
|
|
3750
3771
|
const maybeWorkspaceName = workspaceName
|
|
3751
3772
|
? `${formatBranchName(workspaceName)}-`
|
|
3752
3773
|
: ''
|
|
@@ -3757,19 +3778,19 @@ function getSocketBranchName(purl, newVersion, workspaceName) {
|
|
|
3757
3778
|
return `socket-fix-${fullName}-${formatBranchName(newVersion)}`
|
|
3758
3779
|
}
|
|
3759
3780
|
function getSocketPullRequestTitle(purl, newVersion, workspaceName) {
|
|
3760
|
-
const purlObj =
|
|
3781
|
+
const purlObj = vendor.packageurlJsExports.PackageURL.fromString(purl)
|
|
3761
3782
|
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3762
3783
|
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3763
3784
|
return `Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
|
|
3764
3785
|
}
|
|
3765
3786
|
function getSocketPullRequestBody(purl, newVersion, workspaceName) {
|
|
3766
|
-
const purlObj =
|
|
3787
|
+
const purlObj = vendor.packageurlJsExports.PackageURL.fromString(purl)
|
|
3767
3788
|
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3768
3789
|
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3769
3790
|
return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${newVersion}${workspaceDetails}.`
|
|
3770
3791
|
}
|
|
3771
3792
|
function getSocketCommitMessage(purl, newVersion, workspaceName) {
|
|
3772
|
-
const purlObj =
|
|
3793
|
+
const purlObj = vendor.packageurlJsExports.PackageURL.fromString(purl)
|
|
3773
3794
|
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3774
3795
|
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3775
3796
|
return `socket: Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
|
|
@@ -3788,29 +3809,6 @@ async function gitBranchExists(branch, cwd = process.cwd()) {
|
|
|
3788
3809
|
} catch {}
|
|
3789
3810
|
return false
|
|
3790
3811
|
}
|
|
3791
|
-
async function gitCheckoutBaseBranchIfAvailable(
|
|
3792
|
-
baseBranch,
|
|
3793
|
-
cwd = process.cwd()
|
|
3794
|
-
) {
|
|
3795
|
-
try {
|
|
3796
|
-
await gitHardReset()
|
|
3797
|
-
await spawn.spawn('git', ['fetch', '--depth=1', 'origin', baseBranch], {
|
|
3798
|
-
cwd
|
|
3799
|
-
})
|
|
3800
|
-
await spawn.spawn('git', ['checkout', baseBranch], {
|
|
3801
|
-
cwd
|
|
3802
|
-
})
|
|
3803
|
-
await spawn.spawn('git', ['reset', '--hard', `origin/${baseBranch}`], {
|
|
3804
|
-
cwd
|
|
3805
|
-
})
|
|
3806
|
-
logger.logger.info(`Checked out and reset to ${baseBranch}`)
|
|
3807
|
-
} catch (e) {
|
|
3808
|
-
logger.logger.warn(
|
|
3809
|
-
`Could not switch to ${baseBranch}. Proceeding with HEAD.`
|
|
3810
|
-
)
|
|
3811
|
-
debug.debugLog(e)
|
|
3812
|
-
}
|
|
3813
|
-
}
|
|
3814
3812
|
async function gitCleanFdx(cwd = process.cwd()) {
|
|
3815
3813
|
await spawn.spawn('git', ['clean', '-fdx'], {
|
|
3816
3814
|
cwd
|
|
@@ -4005,45 +4003,69 @@ async function openGitHubPullRequest(
|
|
|
4005
4003
|
throw new Error('Missing GITHUB_ACTIONS environment variable')
|
|
4006
4004
|
}
|
|
4007
4005
|
|
|
4006
|
+
const CMD_NAME$1 = 'socket fix'
|
|
4007
|
+
const alertMapOptions = Object.freeze({
|
|
4008
|
+
consolidate: true,
|
|
4009
|
+
include: {
|
|
4010
|
+
existing: true,
|
|
4011
|
+
unfixable: false,
|
|
4012
|
+
upgradable: false
|
|
4013
|
+
},
|
|
4014
|
+
nothrow: true
|
|
4015
|
+
})
|
|
4016
|
+
function assignDefaultFixOptions(options) {
|
|
4017
|
+
if (options.autoPilot === undefined) {
|
|
4018
|
+
options.autoPilot = false
|
|
4019
|
+
}
|
|
4020
|
+
if (options.autoMerge === undefined) {
|
|
4021
|
+
options.autoMerge = !!options.autoPilot
|
|
4022
|
+
}
|
|
4023
|
+
if (options.cwd === undefined) {
|
|
4024
|
+
options.cwd = process.cwd()
|
|
4025
|
+
}
|
|
4026
|
+
if (options.rangeStyle === undefined) {
|
|
4027
|
+
options.rangeStyle = 'preserve'
|
|
4028
|
+
}
|
|
4029
|
+
if (options.test === undefined) {
|
|
4030
|
+
options.test = !!options.autoPilot || !!options.testScript
|
|
4031
|
+
}
|
|
4032
|
+
if (options.testScript === undefined) {
|
|
4033
|
+
options.testScript = 'test'
|
|
4034
|
+
}
|
|
4035
|
+
return options
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4008
4038
|
const { CI: CI$1, NPM: NPM$f } = constants
|
|
4009
4039
|
async function install$1(idealTree, options) {
|
|
4010
4040
|
const { cwd = process.cwd() } = {
|
|
4011
4041
|
__proto__: null,
|
|
4012
4042
|
...options
|
|
4013
4043
|
}
|
|
4014
|
-
const
|
|
4044
|
+
const arb = new shadowNpmInject.Arborist({
|
|
4015
4045
|
path: cwd
|
|
4016
4046
|
})
|
|
4017
|
-
|
|
4018
|
-
await
|
|
4047
|
+
arb.idealTree = idealTree
|
|
4048
|
+
await arb.reify()
|
|
4019
4049
|
}
|
|
4020
4050
|
async function npmFix(
|
|
4021
4051
|
pkgEnvDetails,
|
|
4022
4052
|
{ autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
|
|
4023
4053
|
) {
|
|
4024
|
-
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4025
4054
|
spinner?.start()
|
|
4055
|
+
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4026
4056
|
const arb = new shadowNpmInject.SafeArborist({
|
|
4027
4057
|
path: rootPath,
|
|
4028
4058
|
...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
4029
4059
|
})
|
|
4030
4060
|
// Calling arb.reify() creates the arb.diff object and nulls-out arb.idealTree.
|
|
4031
4061
|
await arb.reify()
|
|
4032
|
-
const alertMapOptions = {
|
|
4033
|
-
consolidate: true,
|
|
4034
|
-
include: {
|
|
4035
|
-
existing: true,
|
|
4036
|
-
unfixable: false,
|
|
4037
|
-
upgradable: false
|
|
4038
|
-
},
|
|
4039
|
-
nothrow: true
|
|
4040
|
-
}
|
|
4041
4062
|
const alertsMap = purls.length
|
|
4042
4063
|
? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
|
|
4043
4064
|
: await shadowNpmInject.getAlertsMapFromArborist(arb, alertMapOptions)
|
|
4044
4065
|
const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
|
|
4045
4066
|
if (!infoByPkg) {
|
|
4046
4067
|
spinner?.stop()
|
|
4068
|
+
logger.logger.info('No fixable vulnerabilities found.')
|
|
4047
4069
|
return
|
|
4048
4070
|
}
|
|
4049
4071
|
|
|
@@ -4059,123 +4081,104 @@ async function npmFix(
|
|
|
4059
4081
|
pkgEnvDetails.editablePkgJson.filename
|
|
4060
4082
|
]
|
|
4061
4083
|
for (const { 0: name, 1: infos } of infoByPkg) {
|
|
4062
|
-
|
|
4063
|
-
if (
|
|
4064
|
-
spinner?.info(`
|
|
4084
|
+
debug.debugLog(`Processing vulnerable package: ${name}`)
|
|
4085
|
+
if (registry.getManifestData(NPM$f, name)) {
|
|
4086
|
+
spinner?.info(`Socket Optimize package for ${name} exists, skipping`)
|
|
4087
|
+
continue
|
|
4088
|
+
}
|
|
4089
|
+
if (!infos.length) {
|
|
4090
|
+
debug.debugLog(`No vulnerability info found for ${name}`)
|
|
4065
4091
|
continue
|
|
4066
4092
|
}
|
|
4067
|
-
arb.idealTree = null
|
|
4068
4093
|
// eslint-disable-next-line no-await-in-loop
|
|
4069
|
-
await
|
|
4070
|
-
const oldVersions = arrays.arrayUnique(
|
|
4071
|
-
shadowNpmInject
|
|
4072
|
-
.findPackageNodes(arb.idealTree, name)
|
|
4073
|
-
.map(n => n.target?.version ?? n.version)
|
|
4074
|
-
.filter(Boolean)
|
|
4075
|
-
)
|
|
4076
|
-
const packument =
|
|
4077
|
-
oldVersions.length && infos.length
|
|
4078
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4079
|
-
await packages.fetchPackagePackument(name)
|
|
4080
|
-
: null
|
|
4094
|
+
const packument = await packages.fetchPackagePackument(name)
|
|
4081
4095
|
if (!packument) {
|
|
4096
|
+
debug.debugLog(`No packument found for ${name}`)
|
|
4082
4097
|
continue
|
|
4083
4098
|
}
|
|
4084
|
-
const
|
|
4099
|
+
const availableVersions = Object.keys(packument.versions)
|
|
4085
4100
|
const fixedSpecs = new Set()
|
|
4086
|
-
const installedSpecs = new Set()
|
|
4087
|
-
const testedSpecs = new Set()
|
|
4088
|
-
const unavailableSpecs = new Set()
|
|
4089
|
-
const revertedSpecs = new Set()
|
|
4090
4101
|
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4102
|
+
const pkgPath = path$1.dirname(pkgJsonPath)
|
|
4103
|
+
const isWorkspaceRoot =
|
|
4104
|
+
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4105
|
+
const workspaceName = isWorkspaceRoot
|
|
4106
|
+
? 'root'
|
|
4107
|
+
: path$1.relative(rootPath, pkgPath)
|
|
4108
|
+
debug.debugLog(`Checking workspace: ${workspaceName}`)
|
|
4109
|
+
arb.idealTree = null
|
|
4110
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4111
|
+
await arb.buildIdealTree()
|
|
4112
|
+
const oldVersions = arrays.arrayUnique(
|
|
4113
|
+
shadowNpmInject
|
|
4114
|
+
.findPackageNodes(arb.idealTree, name)
|
|
4115
|
+
.map(n => n.target?.version ?? n.version)
|
|
4116
|
+
.filter(Boolean)
|
|
4117
|
+
)
|
|
4118
|
+
if (!oldVersions.length) {
|
|
4119
|
+
debug.debugLog(`Lockfile entries not found for ${name}`)
|
|
4120
|
+
continue
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
// Always re-read the editable package.json to avoid stale mutations
|
|
4124
|
+
// across iterations.
|
|
4125
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4126
|
+
const editablePkgJson = await packages.readPackageJson(pkgJsonPath, {
|
|
4127
|
+
editable: true
|
|
4128
|
+
})
|
|
4091
4129
|
for (const oldVersion of oldVersions) {
|
|
4092
4130
|
const oldSpec = `${name}@${oldVersion}`
|
|
4093
4131
|
const oldPurl = `pkg:npm/${oldSpec}`
|
|
4132
|
+
const node = shadowNpmInject.findPackageNode(
|
|
4133
|
+
arb.idealTree,
|
|
4134
|
+
name,
|
|
4135
|
+
oldVersion
|
|
4136
|
+
)
|
|
4137
|
+
if (!node) {
|
|
4138
|
+
debug.debugLog(`Arborist node not found, skipping ${oldSpec}`)
|
|
4139
|
+
continue
|
|
4140
|
+
}
|
|
4094
4141
|
for (const {
|
|
4095
4142
|
firstPatchedVersionIdentifier,
|
|
4096
4143
|
vulnerableVersionRange
|
|
4097
4144
|
} of infos) {
|
|
4098
|
-
const
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
const node = shadowNpmInject.findPackageNode(
|
|
4103
|
-
arb.idealTree,
|
|
4104
|
-
name,
|
|
4105
|
-
oldVersion
|
|
4145
|
+
const newVersion = shadowNpmInject.findBestPatchVersion(
|
|
4146
|
+
node,
|
|
4147
|
+
availableVersions,
|
|
4148
|
+
vulnerableVersionRange
|
|
4106
4149
|
)
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
)
|
|
4112
|
-
continue
|
|
4113
|
-
}
|
|
4114
|
-
if (
|
|
4115
|
-
!shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
|
|
4116
|
-
) {
|
|
4117
|
-
if (!unavailableSpecs.has(oldSpec)) {
|
|
4118
|
-
unavailableSpecs.add(oldSpec)
|
|
4119
|
-
spinner?.fail(`No update available for ${oldSpec}`)
|
|
4120
|
-
}
|
|
4150
|
+
const newVersionPackument = newVersion
|
|
4151
|
+
? packument.versions[newVersion]
|
|
4152
|
+
: undefined
|
|
4153
|
+
if (!(newVersion && newVersionPackument)) {
|
|
4154
|
+
spinner?.fail(`No update found for ${oldSpec}.`)
|
|
4121
4155
|
continue
|
|
4122
4156
|
}
|
|
4123
|
-
const isWorkspaceRoot =
|
|
4124
|
-
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4125
|
-
const workspaceName = isWorkspaceRoot
|
|
4126
|
-
? ''
|
|
4127
|
-
: path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
|
|
4128
|
-
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
4129
|
-
const editablePkgJson = isWorkspaceRoot
|
|
4130
|
-
? pkgEnvDetails.editablePkgJson
|
|
4131
|
-
: // eslint-disable-next-line no-await-in-loop
|
|
4132
|
-
await packages.readPackageJson(pkgJsonPath, {
|
|
4133
|
-
editable: true
|
|
4134
|
-
})
|
|
4135
|
-
const newVersion = node.package.version
|
|
4136
4157
|
const newVersionRange = shadowNpmInject.applyRange(
|
|
4137
4158
|
oldVersion,
|
|
4138
4159
|
newVersion,
|
|
4139
4160
|
rangeStyle
|
|
4140
4161
|
)
|
|
4141
4162
|
const newSpec = `${name}@${newVersionRange}`
|
|
4142
|
-
const newSpecKey = `${workspaceName
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
: undefined),
|
|
4149
|
-
...(editablePkgJson.content.optionalDependencies
|
|
4150
|
-
? {
|
|
4151
|
-
optionalDependencies:
|
|
4152
|
-
editablePkgJson.content.optionalDependencies
|
|
4153
|
-
}
|
|
4154
|
-
: undefined),
|
|
4155
|
-
...(editablePkgJson.content.peerDependencies
|
|
4156
|
-
? {
|
|
4157
|
-
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4158
|
-
}
|
|
4159
|
-
: undefined)
|
|
4163
|
+
const newSpecKey = `${workspaceName}:${newSpec}`
|
|
4164
|
+
if (fixedSpecs.has(newSpecKey)) {
|
|
4165
|
+
debug.debugLog(
|
|
4166
|
+
`Already fixed ${newSpec} in ${workspaceName}, skipping`
|
|
4167
|
+
)
|
|
4168
|
+
continue
|
|
4160
4169
|
}
|
|
4161
|
-
const
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
const shouldOpenPr = isCi
|
|
4172
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4173
|
-
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4174
|
-
: false
|
|
4175
|
-
if (isCi) {
|
|
4176
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4177
|
-
await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
|
|
4170
|
+
const revertData = {
|
|
4171
|
+
...(editablePkgJson.content.dependencies && {
|
|
4172
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4173
|
+
}),
|
|
4174
|
+
...(editablePkgJson.content.optionalDependencies && {
|
|
4175
|
+
optionalDependencies: editablePkgJson.content.optionalDependencies
|
|
4176
|
+
}),
|
|
4177
|
+
...(editablePkgJson.content.peerDependencies && {
|
|
4178
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4179
|
+
})
|
|
4178
4180
|
}
|
|
4181
|
+
shadowNpmInject.updateNode(node, newVersion, newVersionPackument)
|
|
4179
4182
|
shadowNpmInject.updatePackageJsonFromNode(
|
|
4180
4183
|
editablePkgJson,
|
|
4181
4184
|
arb.idealTree,
|
|
@@ -4183,105 +4186,110 @@ async function npmFix(
|
|
|
4183
4186
|
newVersion,
|
|
4184
4187
|
rangeStyle
|
|
4185
4188
|
)
|
|
4186
|
-
let error
|
|
4187
|
-
let errored = false
|
|
4188
|
-
let saved = false
|
|
4189
|
-
|
|
4190
4189
|
// eslint-disable-next-line no-await-in-loop
|
|
4191
|
-
if (await editablePkgJson.save()) {
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
|
|
4190
|
+
if (!(await editablePkgJson.save())) {
|
|
4191
|
+
debug.debugLog(
|
|
4192
|
+
`Nothing changed for ${workspaceName}, skipping install`
|
|
4193
|
+
)
|
|
4194
|
+
continue
|
|
4197
4195
|
}
|
|
4196
|
+
spinner?.info(`Installing ${newSpec} in ${workspaceName}`)
|
|
4197
|
+
let error
|
|
4198
|
+
let errored = false
|
|
4198
4199
|
try {
|
|
4199
4200
|
// eslint-disable-next-line no-await-in-loop
|
|
4200
4201
|
await install$1(arb.idealTree, {
|
|
4201
4202
|
cwd
|
|
4202
4203
|
})
|
|
4203
4204
|
if (test) {
|
|
4204
|
-
|
|
4205
|
-
testedSpecs.add(newSpecKey)
|
|
4206
|
-
spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
|
|
4207
|
-
}
|
|
4205
|
+
spinner?.info(`Testing ${newSpec} in ${workspaceName}`)
|
|
4208
4206
|
// eslint-disable-next-line no-await-in-loop
|
|
4209
4207
|
await npm.runScript(testScript, [], {
|
|
4210
4208
|
spinner,
|
|
4211
4209
|
stdio: 'ignore'
|
|
4212
4210
|
})
|
|
4213
4211
|
}
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
spinner?.start()
|
|
4218
|
-
}
|
|
4212
|
+
fixedSpecs.add(newSpecKey)
|
|
4213
|
+
spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`)
|
|
4214
|
+
spinner?.start()
|
|
4219
4215
|
} catch (e) {
|
|
4220
|
-
error = e
|
|
4221
4216
|
errored = true
|
|
4217
|
+
error = e
|
|
4222
4218
|
}
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4227
|
-
(await gitCreateAndPushBranchIfNeeded(
|
|
4228
|
-
branch,
|
|
4229
|
-
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4230
|
-
cwd
|
|
4231
|
-
))
|
|
4232
|
-
) {
|
|
4233
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4234
|
-
const prResponse = await openGitHubPullRequest(
|
|
4235
|
-
owner,
|
|
4236
|
-
repo,
|
|
4237
|
-
baseBranch,
|
|
4238
|
-
branch,
|
|
4219
|
+
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4220
|
+
if (!errored && isCi) {
|
|
4221
|
+
const branch = getSocketBranchName(
|
|
4239
4222
|
oldPurl,
|
|
4240
4223
|
newVersion,
|
|
4241
|
-
|
|
4242
|
-
cwd,
|
|
4243
|
-
workspaceName
|
|
4244
|
-
}
|
|
4224
|
+
workspaceName
|
|
4245
4225
|
)
|
|
4246
|
-
|
|
4247
|
-
const {
|
|
4248
|
-
|
|
4249
|
-
|
|
4226
|
+
try {
|
|
4227
|
+
const { owner, repo } = getGitHubEnvRepoInfo()
|
|
4228
|
+
if (
|
|
4229
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4230
|
+
(await doesPullRequestExistForBranch(owner, repo, branch)) ||
|
|
4250
4231
|
// eslint-disable-next-line no-await-in-loop
|
|
4251
|
-
await
|
|
4232
|
+
!(await gitCreateAndPushBranchIfNeeded(
|
|
4233
|
+
branch,
|
|
4234
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4235
|
+
cwd
|
|
4236
|
+
))
|
|
4237
|
+
) {
|
|
4238
|
+
continue
|
|
4252
4239
|
}
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4240
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4241
|
+
const prResponse = await openGitHubPullRequest(
|
|
4242
|
+
owner,
|
|
4243
|
+
repo,
|
|
4244
|
+
baseBranch,
|
|
4245
|
+
branch,
|
|
4246
|
+
oldPurl,
|
|
4247
|
+
newVersion,
|
|
4248
|
+
{
|
|
4249
|
+
cwd,
|
|
4250
|
+
workspaceName
|
|
4251
|
+
}
|
|
4252
|
+
)
|
|
4253
|
+
if (prResponse) {
|
|
4254
|
+
const { data } = prResponse
|
|
4255
|
+
spinner?.info(`Opened PR #${data.number}.`)
|
|
4256
|
+
if (autoMerge) {
|
|
4257
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4258
|
+
await enableAutoMerge(data)
|
|
4259
|
+
}
|
|
4260
4260
|
}
|
|
4261
|
+
} catch (e) {
|
|
4262
|
+
error = e
|
|
4263
|
+
errored = true
|
|
4261
4264
|
}
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
}
|
|
4265
|
+
}
|
|
4266
|
+
if (isCi) {
|
|
4265
4267
|
// eslint-disable-next-line no-await-in-loop
|
|
4266
|
-
await
|
|
4267
|
-
shadowNpmInject.removeNodeModules(cwd),
|
|
4268
|
-
...(isCi
|
|
4269
|
-
? [gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)]
|
|
4270
|
-
: []),
|
|
4271
|
-
...(saved && !isCi ? [editablePkgJson.save()] : [])
|
|
4272
|
-
])
|
|
4268
|
+
await gitHardReset(baseBranch, cwd)
|
|
4273
4269
|
// eslint-disable-next-line no-await-in-loop
|
|
4274
|
-
await
|
|
4270
|
+
await gitCleanFdx(cwd)
|
|
4271
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4272
|
+
await install$1(arb.idealTree, {
|
|
4275
4273
|
cwd
|
|
4276
4274
|
})
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4275
|
+
}
|
|
4276
|
+
if (errored) {
|
|
4277
|
+
if (!isCi) {
|
|
4278
|
+
editablePkgJson.update(revertData)
|
|
4279
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4280
|
+
await Promise.all([
|
|
4281
|
+
shadowNpmInject.removeNodeModules(cwd),
|
|
4282
|
+
editablePkgJson.save()
|
|
4283
|
+
])
|
|
4284
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4285
|
+
await install$1(arb.idealTree, {
|
|
4286
|
+
cwd
|
|
4287
|
+
})
|
|
4284
4288
|
}
|
|
4289
|
+
spinner?.failAndStop(
|
|
4290
|
+
`Update failed for ${oldSpec} in ${workspaceName}`,
|
|
4291
|
+
error
|
|
4292
|
+
)
|
|
4285
4293
|
}
|
|
4286
4294
|
}
|
|
4287
4295
|
}
|
|
@@ -4439,25 +4447,29 @@ async function install(pkgEnvDetails, options) {
|
|
|
4439
4447
|
})
|
|
4440
4448
|
return await getActualTree(cwd)
|
|
4441
4449
|
}
|
|
4450
|
+
async function readLockfile(pkgPath) {
|
|
4451
|
+
return await vendor.libExports$3.readWantedLockfile(pkgPath, {
|
|
4452
|
+
ignoreIncompatible: false
|
|
4453
|
+
})
|
|
4454
|
+
}
|
|
4442
4455
|
async function pnpmFix(
|
|
4443
4456
|
pkgEnvDetails,
|
|
4444
4457
|
{ autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
|
|
4445
4458
|
) {
|
|
4459
|
+
spinner?.start()
|
|
4446
4460
|
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4447
|
-
|
|
4448
|
-
ignoreIncompatible: false
|
|
4449
|
-
})
|
|
4461
|
+
let lockfile = await readLockfile(rootPath)
|
|
4450
4462
|
if (!lockfile) {
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4463
|
+
await install(pkgEnvDetails, {
|
|
4464
|
+
cwd,
|
|
4465
|
+
spinner
|
|
4466
|
+
})
|
|
4467
|
+
lockfile = await readLockfile(rootPath)
|
|
4468
|
+
if (!lockfile) {
|
|
4469
|
+
spinner?.stop()
|
|
4470
|
+
logger.logger.error('Required pnpm-lock.yaml not found.')
|
|
4471
|
+
return
|
|
4472
|
+
}
|
|
4461
4473
|
}
|
|
4462
4474
|
const alertsMap = purls.length
|
|
4463
4475
|
? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
|
|
@@ -4467,9 +4479,10 @@ async function pnpmFix(
|
|
|
4467
4479
|
)
|
|
4468
4480
|
const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
|
|
4469
4481
|
if (!infoByPkg) {
|
|
4482
|
+
spinner?.stop()
|
|
4483
|
+
logger.logger.info('No fixable vulnerabilities found.')
|
|
4470
4484
|
return
|
|
4471
4485
|
}
|
|
4472
|
-
spinner?.start()
|
|
4473
4486
|
|
|
4474
4487
|
// Lazily access constants.ENV[CI].
|
|
4475
4488
|
const isCi = constants.ENV[CI]
|
|
@@ -4477,13 +4490,6 @@ async function pnpmFix(
|
|
|
4477
4490
|
pkgEnvDetails.agent,
|
|
4478
4491
|
rootPath
|
|
4479
4492
|
)
|
|
4480
|
-
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4481
|
-
const { owner, repo } = isCi
|
|
4482
|
-
? getGitHubEnvRepoInfo()
|
|
4483
|
-
: {
|
|
4484
|
-
owner: '',
|
|
4485
|
-
repo: ''
|
|
4486
|
-
}
|
|
4487
4493
|
const pkgJsonPaths = [
|
|
4488
4494
|
...workspacePkgJsonPaths,
|
|
4489
4495
|
// Process the workspace root last since it will add an override to package.json.
|
|
@@ -4492,44 +4498,52 @@ async function pnpmFix(
|
|
|
4492
4498
|
for (const { 0: name, 1: infos } of infoByPkg) {
|
|
4493
4499
|
debug.debugLog(`Processing vulnerable package: ${name}`)
|
|
4494
4500
|
if (registry.getManifestData(NPM$c, name)) {
|
|
4495
|
-
spinner?.info(`
|
|
4501
|
+
spinner?.info(`Socket Optimize package for ${name} exists, skipping`)
|
|
4502
|
+
continue
|
|
4503
|
+
}
|
|
4504
|
+
if (!infos.length) {
|
|
4505
|
+
debug.debugLog(`No vulnerability info found for ${name}`)
|
|
4496
4506
|
continue
|
|
4497
4507
|
}
|
|
4508
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4509
|
+
const packument = await packages.fetchPackagePackument(name)
|
|
4510
|
+
if (!packument) {
|
|
4511
|
+
debug.debugLog(`No packument found for ${name}`)
|
|
4512
|
+
continue
|
|
4513
|
+
}
|
|
4514
|
+
const availableVersions = Object.keys(packument.versions)
|
|
4498
4515
|
const fixedSpecs = new Set()
|
|
4499
4516
|
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4503
|
-
let actualTree = await getActualTree(cwd)
|
|
4517
|
+
const pkgPath = path$1.dirname(pkgJsonPath)
|
|
4504
4518
|
const isWorkspaceRoot =
|
|
4505
4519
|
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4506
4520
|
const workspaceName = isWorkspaceRoot
|
|
4507
4521
|
? 'root'
|
|
4508
|
-
: path$1.relative(rootPath,
|
|
4522
|
+
: path$1.relative(rootPath, pkgPath)
|
|
4523
|
+
debug.debugLog(`Checking workspace: ${workspaceName}`)
|
|
4509
4524
|
|
|
4510
|
-
// Always re-read the editable package.json to avoid stale mutations across iterations
|
|
4511
4525
|
// eslint-disable-next-line no-await-in-loop
|
|
4512
|
-
|
|
4513
|
-
editable: true
|
|
4514
|
-
})
|
|
4515
|
-
|
|
4516
|
-
// Get current overrides for revert logic
|
|
4517
|
-
const oldPnpmSection = editablePkgJson.content[PNPM$8]
|
|
4518
|
-
const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
|
|
4526
|
+
let actualTree = await getActualTree(cwd)
|
|
4519
4527
|
const oldVersions = arrays.arrayUnique(
|
|
4520
4528
|
shadowNpmInject
|
|
4521
4529
|
.findPackageNodes(actualTree, name)
|
|
4522
4530
|
.map(n => n.target?.version ?? n.version)
|
|
4523
4531
|
.filter(Boolean)
|
|
4524
4532
|
)
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4528
|
-
await packages.fetchPackagePackument(name)
|
|
4529
|
-
: null
|
|
4530
|
-
if (!packument) {
|
|
4533
|
+
if (!oldVersions.length) {
|
|
4534
|
+
debug.debugLog(`Lockfile entries not found for ${name}`)
|
|
4531
4535
|
continue
|
|
4532
4536
|
}
|
|
4537
|
+
|
|
4538
|
+
// Always re-read the editable package.json to avoid stale mutations
|
|
4539
|
+
// across iterations.
|
|
4540
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4541
|
+
const editablePkgJson = await packages.readPackageJson(pkgJsonPath, {
|
|
4542
|
+
editable: true
|
|
4543
|
+
})
|
|
4544
|
+
// Get current overrides for revert logic
|
|
4545
|
+
const oldPnpmSection = editablePkgJson.content[PNPM$8]
|
|
4546
|
+
const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
|
|
4533
4547
|
for (const oldVersion of oldVersions) {
|
|
4534
4548
|
const oldSpec = `${name}@${oldVersion}`
|
|
4535
4549
|
const oldPurl = `pkg:npm/${oldSpec}`
|
|
@@ -4539,14 +4553,13 @@ async function pnpmFix(
|
|
|
4539
4553
|
oldVersion
|
|
4540
4554
|
)
|
|
4541
4555
|
if (!node) {
|
|
4542
|
-
debug.debugLog(`
|
|
4556
|
+
debug.debugLog(`Arborist node not found, skipping ${oldSpec}`)
|
|
4543
4557
|
continue
|
|
4544
4558
|
}
|
|
4545
4559
|
for (const {
|
|
4546
4560
|
firstPatchedVersionIdentifier,
|
|
4547
4561
|
vulnerableVersionRange
|
|
4548
4562
|
} of infos) {
|
|
4549
|
-
const availableVersions = Object.keys(packument.versions)
|
|
4550
4563
|
const newVersion = shadowNpmInject.findBestPatchVersion(
|
|
4551
4564
|
node,
|
|
4552
4565
|
availableVersions,
|
|
@@ -4556,7 +4569,7 @@ async function pnpmFix(
|
|
|
4556
4569
|
? packument.versions[newVersion]
|
|
4557
4570
|
: undefined
|
|
4558
4571
|
if (!(newVersion && newVersionPackument)) {
|
|
4559
|
-
spinner?.fail(`No update
|
|
4572
|
+
spinner?.fail(`No update found for ${oldSpec}.`)
|
|
4560
4573
|
continue
|
|
4561
4574
|
}
|
|
4562
4575
|
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
@@ -4612,28 +4625,27 @@ async function pnpmFix(
|
|
|
4612
4625
|
if (updateData) {
|
|
4613
4626
|
editablePkgJson.update(updateData)
|
|
4614
4627
|
}
|
|
4615
|
-
|
|
4628
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4616
4629
|
editablePkgJson,
|
|
4617
4630
|
actualTree,
|
|
4618
4631
|
node,
|
|
4619
4632
|
newVersion,
|
|
4620
4633
|
rangeStyle
|
|
4621
4634
|
)
|
|
4622
|
-
debug.debugLog(`Updated package.json from node: ${modded}`)
|
|
4623
|
-
|
|
4624
4635
|
// eslint-disable-next-line no-await-in-loop
|
|
4625
4636
|
if (!(await editablePkgJson.save())) {
|
|
4626
4637
|
debug.debugLog(
|
|
4627
|
-
`
|
|
4638
|
+
`Nothing changed for ${workspaceName}, skipping install`
|
|
4628
4639
|
)
|
|
4629
4640
|
continue
|
|
4630
4641
|
}
|
|
4631
4642
|
spinner?.info(`Installing ${newSpec} in ${workspaceName}`)
|
|
4632
|
-
let errored = false
|
|
4633
4643
|
let error
|
|
4644
|
+
let errored = false
|
|
4634
4645
|
try {
|
|
4635
4646
|
// eslint-disable-next-line no-await-in-loop
|
|
4636
4647
|
actualTree = await install(pkgEnvDetails, {
|
|
4648
|
+
cwd,
|
|
4637
4649
|
spinner
|
|
4638
4650
|
})
|
|
4639
4651
|
if (test) {
|
|
@@ -4647,25 +4659,31 @@ async function pnpmFix(
|
|
|
4647
4659
|
fixedSpecs.add(newSpecKey)
|
|
4648
4660
|
spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`)
|
|
4649
4661
|
spinner?.start()
|
|
4662
|
+
} catch (e) {
|
|
4663
|
+
error = e
|
|
4664
|
+
errored = true
|
|
4665
|
+
}
|
|
4666
|
+
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4667
|
+
if (!errored && isCi) {
|
|
4650
4668
|
const branch = getSocketBranchName(
|
|
4651
4669
|
oldPurl,
|
|
4652
4670
|
newVersion,
|
|
4653
4671
|
workspaceName
|
|
4654
4672
|
)
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4673
|
+
try {
|
|
4674
|
+
const { owner, repo } = getGitHubEnvRepoInfo()
|
|
4675
|
+
if (
|
|
4676
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4677
|
+
(await doesPullRequestExistForBranch(owner, repo, branch)) ||
|
|
4678
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4679
|
+
!(await gitCreateAndPushBranchIfNeeded(
|
|
4680
|
+
branch,
|
|
4681
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4682
|
+
cwd
|
|
4683
|
+
))
|
|
4684
|
+
) {
|
|
4685
|
+
continue
|
|
4686
|
+
}
|
|
4669
4687
|
// eslint-disable-next-line no-await-in-loop
|
|
4670
4688
|
const prResponse = await openGitHubPullRequest(
|
|
4671
4689
|
owner,
|
|
@@ -4681,41 +4699,46 @@ async function pnpmFix(
|
|
|
4681
4699
|
)
|
|
4682
4700
|
if (prResponse) {
|
|
4683
4701
|
const { data } = prResponse
|
|
4684
|
-
spinner?.info(`PR #${data.number}
|
|
4702
|
+
spinner?.info(`Opened PR #${data.number}.`)
|
|
4685
4703
|
if (autoMerge) {
|
|
4686
4704
|
// eslint-disable-next-line no-await-in-loop
|
|
4687
4705
|
await enableAutoMerge(data)
|
|
4688
4706
|
}
|
|
4689
4707
|
}
|
|
4708
|
+
} catch (e) {
|
|
4709
|
+
error = e
|
|
4710
|
+
errored = true
|
|
4690
4711
|
}
|
|
4691
|
-
} catch (e) {
|
|
4692
|
-
error = e
|
|
4693
|
-
errored = true
|
|
4694
4712
|
}
|
|
4695
|
-
if (
|
|
4696
|
-
editablePkgJson.update(revertData)
|
|
4713
|
+
if (isCi) {
|
|
4697
4714
|
// eslint-disable-next-line no-await-in-loop
|
|
4698
|
-
await
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
])
|
|
4715
|
+
await gitHardReset(baseBranch, cwd)
|
|
4716
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4717
|
+
await gitCleanFdx(cwd)
|
|
4702
4718
|
// eslint-disable-next-line no-await-in-loop
|
|
4703
4719
|
actualTree = await install(pkgEnvDetails, {
|
|
4720
|
+
cwd,
|
|
4704
4721
|
spinner
|
|
4705
4722
|
})
|
|
4723
|
+
}
|
|
4724
|
+
if (errored) {
|
|
4725
|
+
if (!isCi) {
|
|
4726
|
+
editablePkgJson.update(revertData)
|
|
4727
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4728
|
+
await Promise.all([
|
|
4729
|
+
shadowNpmInject.removeNodeModules(cwd),
|
|
4730
|
+
editablePkgJson.save()
|
|
4731
|
+
])
|
|
4732
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4733
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4734
|
+
cwd,
|
|
4735
|
+
spinner
|
|
4736
|
+
})
|
|
4737
|
+
}
|
|
4706
4738
|
spinner?.failAndStop(
|
|
4707
4739
|
`Update failed for ${oldSpec} in ${workspaceName}`,
|
|
4708
4740
|
error
|
|
4709
4741
|
)
|
|
4710
|
-
} else if (isCi) {
|
|
4711
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4712
|
-
await gitHardReset(baseBranch, cwd)
|
|
4713
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4714
|
-
await gitCleanFdx(cwd)
|
|
4715
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4716
|
-
actualTree = await install(pkgEnvDetails, {
|
|
4717
|
-
spinner
|
|
4718
|
-
})
|
|
4719
4742
|
}
|
|
4720
4743
|
}
|
|
4721
4744
|
}
|
|
@@ -4724,29 +4747,6 @@ async function pnpmFix(
|
|
|
4724
4747
|
spinner?.stop()
|
|
4725
4748
|
}
|
|
4726
4749
|
|
|
4727
|
-
const CMD_NAME$1 = 'socket fix'
|
|
4728
|
-
function assignDefaultFixOptions(options) {
|
|
4729
|
-
if (options.autoPilot === undefined) {
|
|
4730
|
-
options.autoPilot = false
|
|
4731
|
-
}
|
|
4732
|
-
if (options.autoMerge === undefined) {
|
|
4733
|
-
options.autoMerge = !!options.autoPilot
|
|
4734
|
-
}
|
|
4735
|
-
if (options.cwd === undefined) {
|
|
4736
|
-
options.cwd = process.cwd()
|
|
4737
|
-
}
|
|
4738
|
-
if (options.rangeStyle === undefined) {
|
|
4739
|
-
options.rangeStyle = 'preserve'
|
|
4740
|
-
}
|
|
4741
|
-
if (options.test === undefined) {
|
|
4742
|
-
options.test = !!options.autoPilot || !!options.testScript
|
|
4743
|
-
}
|
|
4744
|
-
if (options.testScript === undefined) {
|
|
4745
|
-
options.testScript = 'test'
|
|
4746
|
-
}
|
|
4747
|
-
return options
|
|
4748
|
-
}
|
|
4749
|
-
|
|
4750
4750
|
const {
|
|
4751
4751
|
BINARY_LOCK_EXT,
|
|
4752
4752
|
BUN: BUN$5,
|
|
@@ -4850,7 +4850,7 @@ const readLockFileByAgent = (() => {
|
|
|
4850
4850
|
const lockBuffer = await binaryReader(lockPath)
|
|
4851
4851
|
if (lockBuffer) {
|
|
4852
4852
|
try {
|
|
4853
|
-
return
|
|
4853
|
+
return vendor.hyrious__bun_lockbExports.parse(lockBuffer)
|
|
4854
4854
|
} catch {}
|
|
4855
4855
|
}
|
|
4856
4856
|
// To print a Yarn lockfile to your console without writing it to disk
|
|
@@ -5665,7 +5665,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
5665
5665
|
logger.logger.log(DRY_RUN_BAIL_TEXT$w)
|
|
5666
5666
|
return
|
|
5667
5667
|
}
|
|
5668
|
-
if (!
|
|
5668
|
+
if (!vendor.isInteractiveExports()) {
|
|
5669
5669
|
throw new shadowNpmInject.InputError(
|
|
5670
5670
|
'Cannot prompt for credentials in a non-interactive shell'
|
|
5671
5671
|
)
|
|
@@ -10822,7 +10822,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
|
10822
10822
|
|
|
10823
10823
|
logger.logger.log('Diff scan result:')
|
|
10824
10824
|
logger.logger.log(
|
|
10825
|
-
|
|
10825
|
+
util.inspect(result, {
|
|
10826
10826
|
showHidden: false,
|
|
10827
10827
|
depth: depth > 0 ? depth : null,
|
|
10828
10828
|
colors: true,
|
|
@@ -11778,7 +11778,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11778
11778
|
const descriptions = data.results.map(d => d.description)
|
|
11779
11779
|
|
|
11780
11780
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
11781
|
-
const ScreenWidget =
|
|
11781
|
+
const ScreenWidget = require('blessed/lib/widgets/screen')
|
|
11782
11782
|
// Lazily access constants.blessedOptions.
|
|
11783
11783
|
const screen = new ScreenWidget({
|
|
11784
11784
|
...constants.blessedOptions
|
|
@@ -11788,9 +11788,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11788
11788
|
// node process just to exit it. That's very bad UX.
|
|
11789
11789
|
// eslint-disable-next-line n/no-process-exit
|
|
11790
11790
|
screen.key(['escape', 'q', 'C-c'], () => process.exit(0))
|
|
11791
|
-
const TableWidget =
|
|
11792
|
-
require('blessed-contrib/lib/widget/table')
|
|
11793
|
-
)
|
|
11791
|
+
const TableWidget = require('blessed-contrib/lib/widget/table')
|
|
11794
11792
|
const table = new TableWidget({
|
|
11795
11793
|
keys: 'true',
|
|
11796
11794
|
fg: 'white',
|
|
@@ -11813,7 +11811,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11813
11811
|
})
|
|
11814
11812
|
|
|
11815
11813
|
// Create details box at the bottom
|
|
11816
|
-
const BoxWidget =
|
|
11814
|
+
const BoxWidget = require('blessed/lib/widgets/box')
|
|
11817
11815
|
const detailsBox = new BoxWidget({
|
|
11818
11816
|
bottom: 0,
|
|
11819
11817
|
height: '30%',
|
|
@@ -12289,7 +12287,7 @@ void (async () => {
|
|
|
12289
12287
|
await vendor.updater({
|
|
12290
12288
|
name: SOCKET_CLI_BIN_NAME,
|
|
12291
12289
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
12292
|
-
version: '0.14.
|
|
12290
|
+
version: '0.14.131',
|
|
12293
12291
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
12294
12292
|
})
|
|
12295
12293
|
try {
|
|
@@ -12326,7 +12324,7 @@ void (async () => {
|
|
|
12326
12324
|
argv: process$1.argv.slice(2),
|
|
12327
12325
|
name: SOCKET_CLI_BIN_NAME,
|
|
12328
12326
|
importMeta: {
|
|
12329
|
-
url: `${require$$0
|
|
12327
|
+
url: `${require$$0.pathToFileURL(__filename)}`
|
|
12330
12328
|
}
|
|
12331
12329
|
}
|
|
12332
12330
|
)
|
|
@@ -12357,5 +12355,5 @@ void (async () => {
|
|
|
12357
12355
|
await shadowNpmInject.captureException(e)
|
|
12358
12356
|
}
|
|
12359
12357
|
})()
|
|
12360
|
-
//# debugId=
|
|
12358
|
+
//# debugId=233c031b-8e82-4383-8df6-0b5da4408db2
|
|
12361
12359
|
//# sourceMappingURL=cli.js.map
|