socket 0.14.97 → 0.14.99
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/dist/module-sync/cli.js +168 -119
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.js +53 -53
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/vendor.js +117 -114
- package/dist/module-sync/vendor.js.map +1 -1
- package/dist/require/cli.js +168 -119
- package/dist/require/cli.js.map +1 -1
- package/dist/require/shadow-npm-inject.js +53 -53
- package/dist/require/shadow-npm-inject.js.map +1 -1
- package/package.json +73 -69
package/dist/module-sync/cli.js
CHANGED
|
@@ -35,6 +35,7 @@ const arrays = require('@socketsecurity/registry/lib/arrays')
|
|
|
35
35
|
const registry = require('@socketsecurity/registry')
|
|
36
36
|
const npm = require('@socketsecurity/registry/lib/npm')
|
|
37
37
|
const packages = require('@socketsecurity/registry/lib/packages')
|
|
38
|
+
const packageurlJs = require('@socketregistry/packageurl-js')
|
|
38
39
|
const spawn = require('@socketsecurity/registry/lib/spawn')
|
|
39
40
|
const index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs')
|
|
40
41
|
const sorts = require('@socketsecurity/registry/lib/sorts')
|
|
@@ -899,7 +900,7 @@ function emitBanner(name) {
|
|
|
899
900
|
logger.logger.error(getAsciiHeader(name))
|
|
900
901
|
}
|
|
901
902
|
function getAsciiHeader(command) {
|
|
902
|
-
const cliVersion = '0.14.
|
|
903
|
+
const cliVersion = '0.14.99:3a4bfe0:b743a1dc:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
903
904
|
const nodeVersion = process$1.version
|
|
904
905
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
905
906
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
@@ -1356,7 +1357,7 @@ async function runCycloneDX(yargvWithYes) {
|
|
|
1356
1357
|
await shadowBin(NPX$3, [
|
|
1357
1358
|
...yesArgs,
|
|
1358
1359
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SYNP_VERSION']".
|
|
1359
|
-
`synp@${'
|
|
1360
|
+
`synp@${'1.9.14'}`,
|
|
1360
1361
|
'--source-file',
|
|
1361
1362
|
`./${YARN_LOCK}`
|
|
1362
1363
|
])
|
|
@@ -1368,7 +1369,7 @@ async function runCycloneDX(yargvWithYes) {
|
|
|
1368
1369
|
await shadowBin(NPX$3, [
|
|
1369
1370
|
...yesArgs,
|
|
1370
1371
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
|
|
1371
|
-
`@cyclonedx/cdxgen@${'
|
|
1372
|
+
`@cyclonedx/cdxgen@${'11.2.3'}`,
|
|
1372
1373
|
...argvToArray(yargv)
|
|
1373
1374
|
])
|
|
1374
1375
|
if (cleanupPackageLock) {
|
|
@@ -3701,6 +3702,12 @@ const cmdDiffScan = {
|
|
|
3701
3702
|
}
|
|
3702
3703
|
|
|
3703
3704
|
const { GITHUB_REF_NAME } = constants
|
|
3705
|
+
function formatBranchName(str) {
|
|
3706
|
+
return str.replace(/[-_.]+/g, '-').replace(/[-a-zA-Z0-9]+/g, '') ?? ''
|
|
3707
|
+
}
|
|
3708
|
+
function getPkgNameFromPurlObj(purlObj) {
|
|
3709
|
+
return `${purlObj.namespace ? `${purlObj.namespace}/` : ''}${purlObj.name}`
|
|
3710
|
+
}
|
|
3704
3711
|
async function branchExists(branch, cwd = process.cwd()) {
|
|
3705
3712
|
try {
|
|
3706
3713
|
await spawn.spawn(
|
|
@@ -3762,8 +3769,28 @@ function getBaseBranch() {
|
|
|
3762
3769
|
'main'
|
|
3763
3770
|
)
|
|
3764
3771
|
}
|
|
3765
|
-
function getSocketBranchName(
|
|
3766
|
-
|
|
3772
|
+
function getSocketBranchName(purl, toVersion) {
|
|
3773
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3774
|
+
const namespace = formatBranchName(purlObj.namespace ?? '')
|
|
3775
|
+
const name = formatBranchName(purlObj.name)
|
|
3776
|
+
const version = formatBranchName(toVersion)
|
|
3777
|
+
const fullName = `${namespace ? `${namespace}-` : ''}${name}`
|
|
3778
|
+
return `socket-fix-${fullName}-${version}`
|
|
3779
|
+
}
|
|
3780
|
+
function getSocketPullRequestTitle(purl, toVersion) {
|
|
3781
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3782
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3783
|
+
return `Bump ${pkgName} from ${purlObj.version} to ${toVersion}`
|
|
3784
|
+
}
|
|
3785
|
+
function getSocketPullRequestBody(purl, toVersion) {
|
|
3786
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3787
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3788
|
+
return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${toVersion}.`
|
|
3789
|
+
}
|
|
3790
|
+
function getSocketCommitMessage(purl, toVersion) {
|
|
3791
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3792
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3793
|
+
return `socket: Bump ${pkgName} from ${purlObj.version} to ${toVersion}`
|
|
3767
3794
|
}
|
|
3768
3795
|
|
|
3769
3796
|
const { GITHUB_ACTIONS, GITHUB_REPOSITORY, SOCKET_SECURITY_GITHUB_PAT } =
|
|
@@ -3778,6 +3805,18 @@ function getOctokit() {
|
|
|
3778
3805
|
}
|
|
3779
3806
|
return _octokit
|
|
3780
3807
|
}
|
|
3808
|
+
let _octokitGraphql
|
|
3809
|
+
function getOctokitGraphql() {
|
|
3810
|
+
if (!_octokitGraphql) {
|
|
3811
|
+
_octokitGraphql = vendor.graphql2.defaults({
|
|
3812
|
+
headers: {
|
|
3813
|
+
// Lazily access constants.ENV[SOCKET_SECURITY_GITHUB_PAT].
|
|
3814
|
+
authorization: `token ${constants.ENV[SOCKET_SECURITY_GITHUB_PAT]}`
|
|
3815
|
+
}
|
|
3816
|
+
})
|
|
3817
|
+
}
|
|
3818
|
+
return _octokitGraphql
|
|
3819
|
+
}
|
|
3781
3820
|
async function doesPullRequestExistForBranch(owner, repo, branch) {
|
|
3782
3821
|
const octokit = getOctokit()
|
|
3783
3822
|
const { data: prs } = await octokit.pulls.list({
|
|
@@ -3788,11 +3827,10 @@ async function doesPullRequestExistForBranch(owner, repo, branch) {
|
|
|
3788
3827
|
})
|
|
3789
3828
|
return prs.length > 0
|
|
3790
3829
|
}
|
|
3791
|
-
async function enableAutoMerge(
|
|
3792
|
-
const
|
|
3793
|
-
const { node_id: prId, number: prNumber } = prResponseData
|
|
3830
|
+
async function enableAutoMerge({ node_id: prId, number: prNumber }) {
|
|
3831
|
+
const octokitGraphql = getOctokitGraphql()
|
|
3794
3832
|
try {
|
|
3795
|
-
await
|
|
3833
|
+
await octokitGraphql(
|
|
3796
3834
|
`
|
|
3797
3835
|
mutation EnableAutoMerge($pullRequestId: ID!) {
|
|
3798
3836
|
enablePullRequestAutoMerge(input: {
|
|
@@ -3813,16 +3851,23 @@ async function enableAutoMerge(prResponseData) {
|
|
|
3813
3851
|
}
|
|
3814
3852
|
)
|
|
3815
3853
|
logger.logger.info(`Auto-merge enabled for PR #${prNumber}`)
|
|
3854
|
+
return true
|
|
3816
3855
|
} catch (e) {
|
|
3817
|
-
|
|
3856
|
+
let message = `Failed to enable auto-merge for PR #${prNumber}`
|
|
3857
|
+
if (e instanceof vendor.GraphqlResponseError && e.errors) {
|
|
3858
|
+
const details = e.errors.map(({ message }) => ` - ${message}`).join('\n')
|
|
3859
|
+
message += `:\n${details}`
|
|
3860
|
+
}
|
|
3861
|
+
logger.logger.error(message)
|
|
3862
|
+
return false
|
|
3818
3863
|
}
|
|
3819
3864
|
}
|
|
3820
|
-
function
|
|
3865
|
+
function getGitHubEnvRepoInfo() {
|
|
3821
3866
|
// Lazily access constants.ENV[GITHUB_REPOSITORY].
|
|
3822
3867
|
const ownerSlashRepo = constants.ENV[GITHUB_REPOSITORY]
|
|
3823
3868
|
const slashIndex = ownerSlashRepo.indexOf('/')
|
|
3824
3869
|
if (slashIndex === -1) {
|
|
3825
|
-
throw new Error('GITHUB_REPOSITORY environment variable
|
|
3870
|
+
throw new Error('Missing GITHUB_REPOSITORY environment variable')
|
|
3826
3871
|
}
|
|
3827
3872
|
return {
|
|
3828
3873
|
owner: ownerSlashRepo.slice(0, slashIndex),
|
|
@@ -3834,8 +3879,8 @@ async function openGitHubPullRequest(
|
|
|
3834
3879
|
repo,
|
|
3835
3880
|
baseBranch,
|
|
3836
3881
|
branch,
|
|
3837
|
-
|
|
3838
|
-
|
|
3882
|
+
purl,
|
|
3883
|
+
toVersion,
|
|
3839
3884
|
cwd = process.cwd()
|
|
3840
3885
|
) {
|
|
3841
3886
|
// Lazily access constants.ENV[GITHUB_ACTIONS].
|
|
@@ -3850,19 +3895,34 @@ async function openGitHubPullRequest(
|
|
|
3850
3895
|
cwd
|
|
3851
3896
|
})
|
|
3852
3897
|
const octokit = getOctokit()
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3898
|
+
try {
|
|
3899
|
+
return await octokit.pulls.create({
|
|
3900
|
+
owner,
|
|
3901
|
+
repo,
|
|
3902
|
+
title: getSocketPullRequestTitle(purl, toVersion),
|
|
3903
|
+
head: branch,
|
|
3904
|
+
base: baseBranch,
|
|
3905
|
+
body: getSocketPullRequestBody(purl, toVersion)
|
|
3906
|
+
})
|
|
3907
|
+
} catch (e) {
|
|
3908
|
+
let message = `Failed to open pull request`
|
|
3909
|
+
if (e instanceof vendor.RequestError) {
|
|
3910
|
+
const restErrors = e.response?.data?.['errors']
|
|
3911
|
+
if (Array.isArray(restErrors)) {
|
|
3912
|
+
const details = restErrors
|
|
3913
|
+
.map(
|
|
3914
|
+
restErr =>
|
|
3915
|
+
`- ${restErr.message ?? `${restErr.resource}.${restErr.field} (${restErr.code})`}`
|
|
3916
|
+
)
|
|
3917
|
+
.join('\n')
|
|
3918
|
+
message += `:\n${details}`
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
logger.logger.error(message)
|
|
3922
|
+
return null
|
|
3923
|
+
}
|
|
3865
3924
|
}
|
|
3925
|
+
throw new Error('Missing GITHUB_ACTIONS environment variable')
|
|
3866
3926
|
}
|
|
3867
3927
|
|
|
3868
3928
|
const { CI: CI$1, NPM: NPM$f } = constants
|
|
@@ -3928,7 +3988,9 @@ async function npmFix(
|
|
|
3928
3988
|
for (const spec of specs) {
|
|
3929
3989
|
const lastAtSignIndex = spec.lastIndexOf('@')
|
|
3930
3990
|
const name = spec.slice(0, lastAtSignIndex)
|
|
3931
|
-
const
|
|
3991
|
+
const fromVersion = spec.slice(lastAtSignIndex + 1)
|
|
3992
|
+
const fromSpec = `${name}@${fromVersion}`
|
|
3993
|
+
const fromPurl = `pkg:npm/${fromSpec}`
|
|
3932
3994
|
for (const {
|
|
3933
3995
|
firstPatchedVersionIdentifier,
|
|
3934
3996
|
vulnerableVersionRange
|
|
@@ -3940,27 +4002,32 @@ async function npmFix(
|
|
|
3940
4002
|
const node = shadowNpmInject.findPackageNode(
|
|
3941
4003
|
arb.idealTree,
|
|
3942
4004
|
name,
|
|
3943
|
-
|
|
4005
|
+
fromVersion
|
|
3944
4006
|
)
|
|
3945
4007
|
if (!node) {
|
|
3946
4008
|
continue
|
|
3947
4009
|
}
|
|
3948
|
-
const oldSpec = `${name}@${oldVersion}`
|
|
3949
4010
|
if (
|
|
3950
4011
|
!shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
|
|
3951
4012
|
) {
|
|
3952
|
-
spinner?.failAndStop(`Could not patch ${
|
|
4013
|
+
spinner?.failAndStop(`Could not patch ${fromSpec}`)
|
|
3953
4014
|
return
|
|
3954
4015
|
}
|
|
3955
|
-
const
|
|
4016
|
+
const toVersion = node.package.version
|
|
4017
|
+
const toVersionRange = shadowNpmInject.applyRange(
|
|
4018
|
+
fromVersion,
|
|
4019
|
+
toVersion,
|
|
4020
|
+
rangeStyle
|
|
4021
|
+
)
|
|
4022
|
+
const toSpec = `${name}@${toVersionRange}`
|
|
3956
4023
|
let branch
|
|
3957
4024
|
let owner
|
|
3958
4025
|
let repo
|
|
3959
4026
|
let shouldOpenPr = false
|
|
3960
4027
|
// Lazily access constants.ENV[CI].
|
|
3961
4028
|
if (constants.ENV[CI$1]) {
|
|
3962
|
-
;({ owner, repo } =
|
|
3963
|
-
branch = getSocketBranchName(
|
|
4029
|
+
;({ owner, repo } = getGitHubEnvRepoInfo())
|
|
4030
|
+
branch = getSocketBranchName(fromPurl, toVersion)
|
|
3964
4031
|
// eslint-disable-next-line no-await-in-loop
|
|
3965
4032
|
shouldOpenPr = !(await doesPullRequestExistForBranch(
|
|
3966
4033
|
owner,
|
|
@@ -3968,7 +4035,6 @@ async function npmFix(
|
|
|
3968
4035
|
branch
|
|
3969
4036
|
))
|
|
3970
4037
|
}
|
|
3971
|
-
const fixSpec = `${name}@^${targetVersion}`
|
|
3972
4038
|
const revertData = {
|
|
3973
4039
|
...(editablePkgJson.content.dependencies
|
|
3974
4040
|
? {
|
|
@@ -3987,7 +4053,7 @@ async function npmFix(
|
|
|
3987
4053
|
}
|
|
3988
4054
|
: undefined)
|
|
3989
4055
|
}
|
|
3990
|
-
spinner?.info(`Installing ${
|
|
4056
|
+
spinner?.info(`Installing ${toSpec}`)
|
|
3991
4057
|
const baseBranch = getBaseBranch()
|
|
3992
4058
|
|
|
3993
4059
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -3999,7 +4065,7 @@ async function npmFix(
|
|
|
3999
4065
|
editablePkgJson,
|
|
4000
4066
|
arb.idealTree,
|
|
4001
4067
|
node,
|
|
4002
|
-
|
|
4068
|
+
toVersion,
|
|
4003
4069
|
rangeStyle
|
|
4004
4070
|
)
|
|
4005
4071
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4012,7 +4078,7 @@ async function npmFix(
|
|
|
4012
4078
|
})
|
|
4013
4079
|
installed = true
|
|
4014
4080
|
if (test) {
|
|
4015
|
-
spinner?.info(`Testing ${
|
|
4081
|
+
spinner?.info(`Testing ${toSpec}`)
|
|
4016
4082
|
// eslint-disable-next-line no-await-in-loop
|
|
4017
4083
|
await npm.runScript(testScript, [], {
|
|
4018
4084
|
spinner,
|
|
@@ -4022,7 +4088,7 @@ async function npmFix(
|
|
|
4022
4088
|
spinner?.successAndStop(`Fixed ${name}`)
|
|
4023
4089
|
spinner?.start()
|
|
4024
4090
|
} catch {
|
|
4025
|
-
spinner?.error(`Reverting ${
|
|
4091
|
+
spinner?.error(`Reverting ${toSpec}`)
|
|
4026
4092
|
if (saved) {
|
|
4027
4093
|
editablePkgJson.update(revertData)
|
|
4028
4094
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4034,35 +4100,29 @@ async function npmFix(
|
|
|
4034
4100
|
cwd
|
|
4035
4101
|
})
|
|
4036
4102
|
}
|
|
4037
|
-
spinner?.failAndStop(`Failed to fix ${
|
|
4103
|
+
spinner?.failAndStop(`Failed to fix ${fromSpec}`)
|
|
4038
4104
|
return
|
|
4039
4105
|
}
|
|
4040
4106
|
if (shouldOpenPr) {
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4107
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4108
|
+
await createAndPushBranchIfNeeded(
|
|
4109
|
+
branch,
|
|
4110
|
+
getSocketCommitMessage(fromPurl, toVersion),
|
|
4111
|
+
cwd
|
|
4112
|
+
)
|
|
4113
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4114
|
+
const prResponse = await openGitHubPullRequest(
|
|
4115
|
+
owner,
|
|
4116
|
+
repo,
|
|
4117
|
+
baseBranch,
|
|
4118
|
+
branch,
|
|
4119
|
+
fromPurl,
|
|
4120
|
+
toVersion,
|
|
4121
|
+
cwd
|
|
4122
|
+
)
|
|
4056
4123
|
if (prResponse && autoMerge) {
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
await enableAutoMerge(prResponse.data)
|
|
4060
|
-
} catch (e) {
|
|
4061
|
-
logger.logger.error(
|
|
4062
|
-
'Failed to enable auto-merge in pull request',
|
|
4063
|
-
e
|
|
4064
|
-
)
|
|
4065
|
-
}
|
|
4124
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4125
|
+
await enableAutoMerge(prResponse.data)
|
|
4066
4126
|
}
|
|
4067
4127
|
}
|
|
4068
4128
|
}
|
|
@@ -4337,7 +4397,9 @@ async function pnpmFix(
|
|
|
4337
4397
|
for (const spec of specs) {
|
|
4338
4398
|
const lastAtSignIndex = spec.lastIndexOf('@')
|
|
4339
4399
|
const name = spec.slice(0, lastAtSignIndex)
|
|
4340
|
-
const
|
|
4400
|
+
const fromVersion = spec.slice(lastAtSignIndex + 1)
|
|
4401
|
+
const fromSpec = `${name}@${fromVersion}`
|
|
4402
|
+
const fromPurl = `pkg:npm/${fromSpec}`
|
|
4341
4403
|
for (const {
|
|
4342
4404
|
firstPatchedVersionIdentifier,
|
|
4343
4405
|
vulnerableVersionRange
|
|
@@ -4345,33 +4407,45 @@ async function pnpmFix(
|
|
|
4345
4407
|
const node = shadowNpmInject.findPackageNode(
|
|
4346
4408
|
actualTree,
|
|
4347
4409
|
name,
|
|
4348
|
-
|
|
4410
|
+
fromVersion
|
|
4349
4411
|
)
|
|
4350
4412
|
if (!node) {
|
|
4351
4413
|
continue
|
|
4352
4414
|
}
|
|
4353
|
-
const oldSpec = `${name}@${oldVersion}`
|
|
4354
4415
|
const availableVersions = Object.keys(packument.versions)
|
|
4355
|
-
const
|
|
4416
|
+
const toVersion = shadowNpmInject.findBestPatchVersion(
|
|
4356
4417
|
node,
|
|
4357
4418
|
availableVersions,
|
|
4358
4419
|
vulnerableVersionRange
|
|
4359
4420
|
)
|
|
4360
|
-
const targetPackument =
|
|
4361
|
-
? packument.versions[
|
|
4421
|
+
const targetPackument = toVersion
|
|
4422
|
+
? packument.versions[toVersion]
|
|
4362
4423
|
: undefined
|
|
4363
|
-
if (!(
|
|
4364
|
-
spinner?.failAndStop(`Could not patch ${
|
|
4424
|
+
if (!(toVersion && targetPackument)) {
|
|
4425
|
+
spinner?.failAndStop(`Could not patch ${fromSpec}`)
|
|
4365
4426
|
return
|
|
4366
4427
|
}
|
|
4428
|
+
const oldPnpm = editablePkgJson.content[PNPM$9]
|
|
4429
|
+
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4430
|
+
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4431
|
+
const oldOverridesCount = oldOverrides
|
|
4432
|
+
? Object.keys(oldOverrides).length
|
|
4433
|
+
: 0
|
|
4434
|
+
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
4435
|
+
const toVersionRange = shadowNpmInject.applyRange(
|
|
4436
|
+
oldOverrides?.[overrideKey] ?? fromVersion,
|
|
4437
|
+
toVersion,
|
|
4438
|
+
rangeStyle
|
|
4439
|
+
)
|
|
4440
|
+
const toSpec = `${name}@${toVersionRange}`
|
|
4367
4441
|
let branch
|
|
4368
4442
|
let owner
|
|
4369
4443
|
let repo
|
|
4370
4444
|
let shouldOpenPr = false
|
|
4371
4445
|
// Lazily access constants.ENV[CI].
|
|
4372
4446
|
if (constants.ENV[CI]) {
|
|
4373
|
-
;({ owner, repo } =
|
|
4374
|
-
branch = getSocketBranchName(
|
|
4447
|
+
;({ owner, repo } = getGitHubEnvRepoInfo())
|
|
4448
|
+
branch = getSocketBranchName(fromPurl, toVersion)
|
|
4375
4449
|
// eslint-disable-next-line no-await-in-loop
|
|
4376
4450
|
shouldOpenPr = !(await doesPullRequestExistForBranch(
|
|
4377
4451
|
owner,
|
|
@@ -4379,24 +4453,11 @@ async function pnpmFix(
|
|
|
4379
4453
|
branch
|
|
4380
4454
|
))
|
|
4381
4455
|
}
|
|
4382
|
-
const oldPnpm = editablePkgJson.content[PNPM$9]
|
|
4383
|
-
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4384
|
-
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4385
|
-
const oldOverridesCount = oldOverrides
|
|
4386
|
-
? Object.keys(oldOverrides).length
|
|
4387
|
-
: 0
|
|
4388
|
-
const overrideKey = `${node.name}@${vulnerableVersionRange}`
|
|
4389
|
-
const overrideRange = shadowNpmInject.applyRange(
|
|
4390
|
-
oldOverrides?.[overrideKey] ?? targetVersion,
|
|
4391
|
-
targetVersion,
|
|
4392
|
-
rangeStyle
|
|
4393
|
-
)
|
|
4394
|
-
const fixSpec = `${name}@${overrideRange}`
|
|
4395
4456
|
const updateData = {
|
|
4396
4457
|
[PNPM$9]: {
|
|
4397
4458
|
...oldPnpm,
|
|
4398
4459
|
[OVERRIDES$2]: {
|
|
4399
|
-
[overrideKey]:
|
|
4460
|
+
[overrideKey]: toVersionRange,
|
|
4400
4461
|
...oldOverrides
|
|
4401
4462
|
}
|
|
4402
4463
|
}
|
|
@@ -4431,7 +4492,7 @@ async function pnpmFix(
|
|
|
4431
4492
|
}
|
|
4432
4493
|
: undefined)
|
|
4433
4494
|
}
|
|
4434
|
-
spinner?.info(`Installing ${
|
|
4495
|
+
spinner?.info(`Installing ${toSpec}`)
|
|
4435
4496
|
const baseBranch = getBaseBranch()
|
|
4436
4497
|
|
|
4437
4498
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4444,7 +4505,7 @@ async function pnpmFix(
|
|
|
4444
4505
|
editablePkgJson,
|
|
4445
4506
|
actualTree,
|
|
4446
4507
|
node,
|
|
4447
|
-
|
|
4508
|
+
toVersion,
|
|
4448
4509
|
rangeStyle
|
|
4449
4510
|
)
|
|
4450
4511
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4457,7 +4518,7 @@ async function pnpmFix(
|
|
|
4457
4518
|
})
|
|
4458
4519
|
installed = true
|
|
4459
4520
|
if (test) {
|
|
4460
|
-
spinner?.info(`Testing ${
|
|
4521
|
+
spinner?.info(`Testing ${toSpec}`)
|
|
4461
4522
|
// eslint-disable-next-line no-await-in-loop
|
|
4462
4523
|
await npm.runScript(testScript, [], {
|
|
4463
4524
|
spinner,
|
|
@@ -4467,7 +4528,7 @@ async function pnpmFix(
|
|
|
4467
4528
|
spinner?.successAndStop(`Fixed ${name}`)
|
|
4468
4529
|
spinner?.start()
|
|
4469
4530
|
} catch (e) {
|
|
4470
|
-
spinner?.error(`Reverting ${
|
|
4531
|
+
spinner?.error(`Reverting ${toSpec}`, e)
|
|
4471
4532
|
if (saved) {
|
|
4472
4533
|
editablePkgJson.update(revertData)
|
|
4473
4534
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4479,41 +4540,29 @@ async function pnpmFix(
|
|
|
4479
4540
|
spinner
|
|
4480
4541
|
})
|
|
4481
4542
|
}
|
|
4482
|
-
spinner?.failAndStop(`Failed to fix ${
|
|
4543
|
+
spinner?.failAndStop(`Failed to fix ${fromSpec}`)
|
|
4483
4544
|
return
|
|
4484
4545
|
}
|
|
4485
4546
|
if (shouldOpenPr) {
|
|
4486
4547
|
// eslint-disable-next-line no-await-in-loop
|
|
4487
4548
|
await createAndPushBranchIfNeeded(
|
|
4488
4549
|
branch,
|
|
4489
|
-
|
|
4550
|
+
getSocketCommitMessage(fromPurl, toVersion),
|
|
4551
|
+
cwd
|
|
4552
|
+
)
|
|
4553
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4554
|
+
const prResponse = await openGitHubPullRequest(
|
|
4555
|
+
owner,
|
|
4556
|
+
repo,
|
|
4557
|
+
baseBranch,
|
|
4558
|
+
branch,
|
|
4559
|
+
fromPurl,
|
|
4560
|
+
toVersion,
|
|
4490
4561
|
cwd
|
|
4491
4562
|
)
|
|
4492
|
-
let prResponse
|
|
4493
|
-
try {
|
|
4494
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4495
|
-
prResponse = await openGitHubPullRequest(
|
|
4496
|
-
owner,
|
|
4497
|
-
repo,
|
|
4498
|
-
baseBranch,
|
|
4499
|
-
branch,
|
|
4500
|
-
name,
|
|
4501
|
-
targetVersion,
|
|
4502
|
-
cwd
|
|
4503
|
-
)
|
|
4504
|
-
} catch (e) {
|
|
4505
|
-
logger.logger.error('Failed to open pull request', e)
|
|
4506
|
-
}
|
|
4507
4563
|
if (prResponse && autoMerge) {
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
await enableAutoMerge(prResponse.data)
|
|
4511
|
-
} catch (e) {
|
|
4512
|
-
logger.logger.error(
|
|
4513
|
-
'Failed to enable auto-merge in pull request',
|
|
4514
|
-
e
|
|
4515
|
-
)
|
|
4516
|
-
}
|
|
4564
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4565
|
+
await enableAutoMerge(prResponse.data)
|
|
4517
4566
|
}
|
|
4518
4567
|
}
|
|
4519
4568
|
}
|
|
@@ -11435,7 +11484,7 @@ void (async () => {
|
|
|
11435
11484
|
await vendor.updater({
|
|
11436
11485
|
name: SOCKET_CLI_BIN_NAME,
|
|
11437
11486
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11438
|
-
version: '0.14.
|
|
11487
|
+
version: '0.14.99',
|
|
11439
11488
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11440
11489
|
})
|
|
11441
11490
|
try {
|
|
@@ -11503,5 +11552,5 @@ void (async () => {
|
|
|
11503
11552
|
await shadowNpmInject.captureException(e)
|
|
11504
11553
|
}
|
|
11505
11554
|
})()
|
|
11506
|
-
//# debugId=
|
|
11555
|
+
//# debugId=2d326add-8fcf-4b0c-b3ae-80dfa2cf2bc
|
|
11507
11556
|
//# sourceMappingURL=cli.js.map
|