@socketsecurity/cli 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/{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/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 -12357
- 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 -106
- 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:325534ec: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
|
}
|
|
@@ -4435,25 +4443,29 @@ async function install(pkgEnvDetails, options) {
|
|
|
4435
4443
|
})
|
|
4436
4444
|
return await getActualTree(cwd)
|
|
4437
4445
|
}
|
|
4446
|
+
async function readLockfile(pkgPath) {
|
|
4447
|
+
return await vendor.libExports$3.readWantedLockfile(pkgPath, {
|
|
4448
|
+
ignoreIncompatible: false
|
|
4449
|
+
})
|
|
4450
|
+
}
|
|
4438
4451
|
async function pnpmFix(
|
|
4439
4452
|
pkgEnvDetails,
|
|
4440
4453
|
{ autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
|
|
4441
4454
|
) {
|
|
4455
|
+
spinner?.start()
|
|
4442
4456
|
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4443
|
-
|
|
4444
|
-
ignoreIncompatible: false
|
|
4445
|
-
})
|
|
4457
|
+
let lockfile = await readLockfile(rootPath)
|
|
4446
4458
|
if (!lockfile) {
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4459
|
+
await install(pkgEnvDetails, {
|
|
4460
|
+
cwd,
|
|
4461
|
+
spinner
|
|
4462
|
+
})
|
|
4463
|
+
lockfile = await readLockfile(rootPath)
|
|
4464
|
+
if (!lockfile) {
|
|
4465
|
+
spinner?.stop()
|
|
4466
|
+
logger.logger.error('Required pnpm-lock.yaml not found.')
|
|
4467
|
+
return
|
|
4468
|
+
}
|
|
4457
4469
|
}
|
|
4458
4470
|
const alertsMap = purls.length
|
|
4459
4471
|
? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
|
|
@@ -4463,9 +4475,10 @@ async function pnpmFix(
|
|
|
4463
4475
|
)
|
|
4464
4476
|
const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
|
|
4465
4477
|
if (!infoByPkg) {
|
|
4478
|
+
spinner?.stop()
|
|
4479
|
+
logger.logger.info('No fixable vulnerabilities found.')
|
|
4466
4480
|
return
|
|
4467
4481
|
}
|
|
4468
|
-
spinner?.start()
|
|
4469
4482
|
|
|
4470
4483
|
// Lazily access constants.ENV[CI].
|
|
4471
4484
|
const isCi = constants.ENV[CI]
|
|
@@ -4473,13 +4486,6 @@ async function pnpmFix(
|
|
|
4473
4486
|
pkgEnvDetails.agent,
|
|
4474
4487
|
rootPath
|
|
4475
4488
|
)
|
|
4476
|
-
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4477
|
-
const { owner, repo } = isCi
|
|
4478
|
-
? getGitHubEnvRepoInfo()
|
|
4479
|
-
: {
|
|
4480
|
-
owner: '',
|
|
4481
|
-
repo: ''
|
|
4482
|
-
}
|
|
4483
4489
|
const pkgJsonPaths = [
|
|
4484
4490
|
...workspacePkgJsonPaths,
|
|
4485
4491
|
// Process the workspace root last since it will add an override to package.json.
|
|
@@ -4488,44 +4494,52 @@ async function pnpmFix(
|
|
|
4488
4494
|
for (const { 0: name, 1: infos } of infoByPkg) {
|
|
4489
4495
|
debug.debugLog(`Processing vulnerable package: ${name}`)
|
|
4490
4496
|
if (registry.getManifestData(NPM$c, name)) {
|
|
4491
|
-
spinner?.info(`
|
|
4497
|
+
spinner?.info(`Socket Optimize package for ${name} exists, skipping`)
|
|
4498
|
+
continue
|
|
4499
|
+
}
|
|
4500
|
+
if (!infos.length) {
|
|
4501
|
+
debug.debugLog(`No vulnerability info found for ${name}`)
|
|
4492
4502
|
continue
|
|
4493
4503
|
}
|
|
4504
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4505
|
+
const packument = await packages.fetchPackagePackument(name)
|
|
4506
|
+
if (!packument) {
|
|
4507
|
+
debug.debugLog(`No packument found for ${name}`)
|
|
4508
|
+
continue
|
|
4509
|
+
}
|
|
4510
|
+
const availableVersions = Object.keys(packument.versions)
|
|
4494
4511
|
const fixedSpecs = new Set()
|
|
4495
4512
|
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4499
|
-
let actualTree = await getActualTree(cwd)
|
|
4513
|
+
const pkgPath = path$1.dirname(pkgJsonPath)
|
|
4500
4514
|
const isWorkspaceRoot =
|
|
4501
4515
|
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4502
4516
|
const workspaceName = isWorkspaceRoot
|
|
4503
4517
|
? 'root'
|
|
4504
|
-
: path$1.relative(rootPath,
|
|
4518
|
+
: path$1.relative(rootPath, pkgPath)
|
|
4519
|
+
debug.debugLog(`Checking workspace: ${workspaceName}`)
|
|
4505
4520
|
|
|
4506
|
-
// Always re-read the editable package.json to avoid stale mutations across iterations
|
|
4507
4521
|
// eslint-disable-next-line no-await-in-loop
|
|
4508
|
-
|
|
4509
|
-
editable: true
|
|
4510
|
-
})
|
|
4511
|
-
|
|
4512
|
-
// Get current overrides for revert logic
|
|
4513
|
-
const oldPnpmSection = editablePkgJson.content[PNPM$8]
|
|
4514
|
-
const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
|
|
4522
|
+
let actualTree = await getActualTree(cwd)
|
|
4515
4523
|
const oldVersions = arrays.arrayUnique(
|
|
4516
4524
|
shadowNpmInject
|
|
4517
4525
|
.findPackageNodes(actualTree, name)
|
|
4518
4526
|
.map(n => n.target?.version ?? n.version)
|
|
4519
4527
|
.filter(Boolean)
|
|
4520
4528
|
)
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4524
|
-
await packages.fetchPackagePackument(name)
|
|
4525
|
-
: null
|
|
4526
|
-
if (!packument) {
|
|
4529
|
+
if (!oldVersions.length) {
|
|
4530
|
+
debug.debugLog(`Lockfile entries not found for ${name}`)
|
|
4527
4531
|
continue
|
|
4528
4532
|
}
|
|
4533
|
+
|
|
4534
|
+
// Always re-read the editable package.json to avoid stale mutations
|
|
4535
|
+
// across iterations.
|
|
4536
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4537
|
+
const editablePkgJson = await packages.readPackageJson(pkgJsonPath, {
|
|
4538
|
+
editable: true
|
|
4539
|
+
})
|
|
4540
|
+
// Get current overrides for revert logic
|
|
4541
|
+
const oldPnpmSection = editablePkgJson.content[PNPM$8]
|
|
4542
|
+
const oldOverrides = oldPnpmSection?.[OVERRIDES$2]
|
|
4529
4543
|
for (const oldVersion of oldVersions) {
|
|
4530
4544
|
const oldSpec = `${name}@${oldVersion}`
|
|
4531
4545
|
const oldPurl = `pkg:npm/${oldSpec}`
|
|
@@ -4535,14 +4549,13 @@ async function pnpmFix(
|
|
|
4535
4549
|
oldVersion
|
|
4536
4550
|
)
|
|
4537
4551
|
if (!node) {
|
|
4538
|
-
debug.debugLog(`
|
|
4552
|
+
debug.debugLog(`Arborist node not found, skipping ${oldSpec}`)
|
|
4539
4553
|
continue
|
|
4540
4554
|
}
|
|
4541
4555
|
for (const {
|
|
4542
4556
|
firstPatchedVersionIdentifier,
|
|
4543
4557
|
vulnerableVersionRange
|
|
4544
4558
|
} of infos) {
|
|
4545
|
-
const availableVersions = Object.keys(packument.versions)
|
|
4546
4559
|
const newVersion = shadowNpmInject.findBestPatchVersion(
|
|
4547
4560
|
node,
|
|
4548
4561
|
availableVersions,
|
|
@@ -4552,7 +4565,7 @@ async function pnpmFix(
|
|
|
4552
4565
|
? packument.versions[newVersion]
|
|
4553
4566
|
: undefined
|
|
4554
4567
|
if (!(newVersion && newVersionPackument)) {
|
|
4555
|
-
spinner?.fail(`No update
|
|
4568
|
+
spinner?.fail(`No update found for ${oldSpec}.`)
|
|
4556
4569
|
continue
|
|
4557
4570
|
}
|
|
4558
4571
|
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
@@ -4608,28 +4621,27 @@ async function pnpmFix(
|
|
|
4608
4621
|
if (updateData) {
|
|
4609
4622
|
editablePkgJson.update(updateData)
|
|
4610
4623
|
}
|
|
4611
|
-
|
|
4624
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4612
4625
|
editablePkgJson,
|
|
4613
4626
|
actualTree,
|
|
4614
4627
|
node,
|
|
4615
4628
|
newVersion,
|
|
4616
4629
|
rangeStyle
|
|
4617
4630
|
)
|
|
4618
|
-
debug.debugLog(`Updated package.json from node: ${modded}`)
|
|
4619
|
-
|
|
4620
4631
|
// eslint-disable-next-line no-await-in-loop
|
|
4621
4632
|
if (!(await editablePkgJson.save())) {
|
|
4622
4633
|
debug.debugLog(
|
|
4623
|
-
`
|
|
4634
|
+
`Nothing changed for ${workspaceName}, skipping install`
|
|
4624
4635
|
)
|
|
4625
4636
|
continue
|
|
4626
4637
|
}
|
|
4627
4638
|
spinner?.info(`Installing ${newSpec} in ${workspaceName}`)
|
|
4628
|
-
let errored = false
|
|
4629
4639
|
let error
|
|
4640
|
+
let errored = false
|
|
4630
4641
|
try {
|
|
4631
4642
|
// eslint-disable-next-line no-await-in-loop
|
|
4632
4643
|
actualTree = await install(pkgEnvDetails, {
|
|
4644
|
+
cwd,
|
|
4633
4645
|
spinner
|
|
4634
4646
|
})
|
|
4635
4647
|
if (test) {
|
|
@@ -4643,25 +4655,31 @@ async function pnpmFix(
|
|
|
4643
4655
|
fixedSpecs.add(newSpecKey)
|
|
4644
4656
|
spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`)
|
|
4645
4657
|
spinner?.start()
|
|
4658
|
+
} catch (e) {
|
|
4659
|
+
error = e
|
|
4660
|
+
errored = true
|
|
4661
|
+
}
|
|
4662
|
+
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4663
|
+
if (!errored && isCi) {
|
|
4646
4664
|
const branch = getSocketBranchName(
|
|
4647
4665
|
oldPurl,
|
|
4648
4666
|
newVersion,
|
|
4649
4667
|
workspaceName
|
|
4650
4668
|
)
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4669
|
+
try {
|
|
4670
|
+
const { owner, repo } = getGitHubEnvRepoInfo()
|
|
4671
|
+
if (
|
|
4672
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4673
|
+
(await doesPullRequestExistForBranch(owner, repo, branch)) ||
|
|
4674
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4675
|
+
!(await gitCreateAndPushBranchIfNeeded(
|
|
4676
|
+
branch,
|
|
4677
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4678
|
+
cwd
|
|
4679
|
+
))
|
|
4680
|
+
) {
|
|
4681
|
+
continue
|
|
4682
|
+
}
|
|
4665
4683
|
// eslint-disable-next-line no-await-in-loop
|
|
4666
4684
|
const prResponse = await openGitHubPullRequest(
|
|
4667
4685
|
owner,
|
|
@@ -4677,41 +4695,46 @@ async function pnpmFix(
|
|
|
4677
4695
|
)
|
|
4678
4696
|
if (prResponse) {
|
|
4679
4697
|
const { data } = prResponse
|
|
4680
|
-
spinner?.info(`PR #${data.number}
|
|
4698
|
+
spinner?.info(`Opened PR #${data.number}.`)
|
|
4681
4699
|
if (autoMerge) {
|
|
4682
4700
|
// eslint-disable-next-line no-await-in-loop
|
|
4683
4701
|
await enableAutoMerge(data)
|
|
4684
4702
|
}
|
|
4685
4703
|
}
|
|
4704
|
+
} catch (e) {
|
|
4705
|
+
error = e
|
|
4706
|
+
errored = true
|
|
4686
4707
|
}
|
|
4687
|
-
} catch (e) {
|
|
4688
|
-
error = e
|
|
4689
|
-
errored = true
|
|
4690
4708
|
}
|
|
4691
|
-
if (
|
|
4692
|
-
editablePkgJson.update(revertData)
|
|
4709
|
+
if (isCi) {
|
|
4693
4710
|
// eslint-disable-next-line no-await-in-loop
|
|
4694
|
-
await
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
])
|
|
4711
|
+
await gitHardReset(baseBranch, cwd)
|
|
4712
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4713
|
+
await gitCleanFdx(cwd)
|
|
4698
4714
|
// eslint-disable-next-line no-await-in-loop
|
|
4699
4715
|
actualTree = await install(pkgEnvDetails, {
|
|
4716
|
+
cwd,
|
|
4700
4717
|
spinner
|
|
4701
4718
|
})
|
|
4719
|
+
}
|
|
4720
|
+
if (errored) {
|
|
4721
|
+
if (!isCi) {
|
|
4722
|
+
editablePkgJson.update(revertData)
|
|
4723
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4724
|
+
await Promise.all([
|
|
4725
|
+
shadowNpmInject.removeNodeModules(cwd),
|
|
4726
|
+
editablePkgJson.save()
|
|
4727
|
+
])
|
|
4728
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4729
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4730
|
+
cwd,
|
|
4731
|
+
spinner
|
|
4732
|
+
})
|
|
4733
|
+
}
|
|
4702
4734
|
spinner?.failAndStop(
|
|
4703
4735
|
`Update failed for ${oldSpec} in ${workspaceName}`,
|
|
4704
4736
|
error
|
|
4705
4737
|
)
|
|
4706
|
-
} else if (isCi) {
|
|
4707
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4708
|
-
await gitHardReset(baseBranch, cwd)
|
|
4709
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4710
|
-
await gitCleanFdx(cwd)
|
|
4711
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4712
|
-
actualTree = await install(pkgEnvDetails, {
|
|
4713
|
-
spinner
|
|
4714
|
-
})
|
|
4715
4738
|
}
|
|
4716
4739
|
}
|
|
4717
4740
|
}
|
|
@@ -4720,29 +4743,6 @@ async function pnpmFix(
|
|
|
4720
4743
|
spinner?.stop()
|
|
4721
4744
|
}
|
|
4722
4745
|
|
|
4723
|
-
const CMD_NAME$1 = 'socket fix'
|
|
4724
|
-
function assignDefaultFixOptions(options) {
|
|
4725
|
-
if (options.autoPilot === undefined) {
|
|
4726
|
-
options.autoPilot = false
|
|
4727
|
-
}
|
|
4728
|
-
if (options.autoMerge === undefined) {
|
|
4729
|
-
options.autoMerge = !!options.autoPilot
|
|
4730
|
-
}
|
|
4731
|
-
if (options.cwd === undefined) {
|
|
4732
|
-
options.cwd = process.cwd()
|
|
4733
|
-
}
|
|
4734
|
-
if (options.rangeStyle === undefined) {
|
|
4735
|
-
options.rangeStyle = 'preserve'
|
|
4736
|
-
}
|
|
4737
|
-
if (options.test === undefined) {
|
|
4738
|
-
options.test = !!options.autoPilot || !!options.testScript
|
|
4739
|
-
}
|
|
4740
|
-
if (options.testScript === undefined) {
|
|
4741
|
-
options.testScript = 'test'
|
|
4742
|
-
}
|
|
4743
|
-
return options
|
|
4744
|
-
}
|
|
4745
|
-
|
|
4746
4746
|
const {
|
|
4747
4747
|
BINARY_LOCK_EXT,
|
|
4748
4748
|
BUN: BUN$5,
|
|
@@ -4846,7 +4846,7 @@ const readLockFileByAgent = (() => {
|
|
|
4846
4846
|
const lockBuffer = await binaryReader(lockPath)
|
|
4847
4847
|
if (lockBuffer) {
|
|
4848
4848
|
try {
|
|
4849
|
-
return
|
|
4849
|
+
return vendor.hyrious__bun_lockbExports.parse(lockBuffer)
|
|
4850
4850
|
} catch {}
|
|
4851
4851
|
}
|
|
4852
4852
|
// To print a Yarn lockfile to your console without writing it to disk
|
|
@@ -5661,7 +5661,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
5661
5661
|
logger.logger.log(DRY_RUN_BAIL_TEXT$w)
|
|
5662
5662
|
return
|
|
5663
5663
|
}
|
|
5664
|
-
if (!
|
|
5664
|
+
if (!vendor.isInteractiveExports()) {
|
|
5665
5665
|
throw new shadowNpmInject.InputError(
|
|
5666
5666
|
'Cannot prompt for credentials in a non-interactive shell'
|
|
5667
5667
|
)
|
|
@@ -10818,7 +10818,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
|
10818
10818
|
|
|
10819
10819
|
logger.logger.log('Diff scan result:')
|
|
10820
10820
|
logger.logger.log(
|
|
10821
|
-
|
|
10821
|
+
util.inspect(result, {
|
|
10822
10822
|
showHidden: false,
|
|
10823
10823
|
depth: depth > 0 ? depth : null,
|
|
10824
10824
|
colors: true,
|
|
@@ -11774,7 +11774,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11774
11774
|
const descriptions = data.results.map(d => d.description)
|
|
11775
11775
|
|
|
11776
11776
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
11777
|
-
const ScreenWidget =
|
|
11777
|
+
const ScreenWidget = require('blessed/lib/widgets/screen')
|
|
11778
11778
|
// Lazily access constants.blessedOptions.
|
|
11779
11779
|
const screen = new ScreenWidget({
|
|
11780
11780
|
...constants.blessedOptions
|
|
@@ -11784,9 +11784,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11784
11784
|
// node process just to exit it. That's very bad UX.
|
|
11785
11785
|
// eslint-disable-next-line n/no-process-exit
|
|
11786
11786
|
screen.key(['escape', 'q', 'C-c'], () => process.exit(0))
|
|
11787
|
-
const TableWidget =
|
|
11788
|
-
require('blessed-contrib/lib/widget/table')
|
|
11789
|
-
)
|
|
11787
|
+
const TableWidget = require('blessed-contrib/lib/widget/table')
|
|
11790
11788
|
const table = new TableWidget({
|
|
11791
11789
|
keys: 'true',
|
|
11792
11790
|
fg: 'white',
|
|
@@ -11809,7 +11807,7 @@ async function outputThreatFeed(data, { outputKind }) {
|
|
|
11809
11807
|
})
|
|
11810
11808
|
|
|
11811
11809
|
// Create details box at the bottom
|
|
11812
|
-
const BoxWidget =
|
|
11810
|
+
const BoxWidget = require('blessed/lib/widgets/box')
|
|
11813
11811
|
const detailsBox = new BoxWidget({
|
|
11814
11812
|
bottom: 0,
|
|
11815
11813
|
height: '30%',
|
|
@@ -12285,7 +12283,7 @@ void (async () => {
|
|
|
12285
12283
|
await vendor.updater({
|
|
12286
12284
|
name: SOCKET_CLI_BIN_NAME,
|
|
12287
12285
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
12288
|
-
version: '0.14.
|
|
12286
|
+
version: '0.14.131',
|
|
12289
12287
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
12290
12288
|
})
|
|
12291
12289
|
try {
|
|
@@ -12322,7 +12320,7 @@ void (async () => {
|
|
|
12322
12320
|
argv: process$1.argv.slice(2),
|
|
12323
12321
|
name: SOCKET_CLI_BIN_NAME,
|
|
12324
12322
|
importMeta: {
|
|
12325
|
-
url: `${require$$0
|
|
12323
|
+
url: `${require$$0.pathToFileURL(__filename)}`
|
|
12326
12324
|
}
|
|
12327
12325
|
}
|
|
12328
12326
|
)
|
|
@@ -12353,5 +12351,5 @@ void (async () => {
|
|
|
12353
12351
|
await shadowNpmInject.captureException(e)
|
|
12354
12352
|
}
|
|
12355
12353
|
})()
|
|
12356
|
-
//# debugId=
|
|
12354
|
+
//# debugId=a84f4ae7-7eb2-48c7-b03a-37504c364d76
|
|
12357
12355
|
//# sourceMappingURL=cli.js.map
|