@socketsecurity/cli-with-sentry 0.14.78 → 0.14.80
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/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/cli.js +85 -65
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/fs.d.ts +61 -0
- package/dist/module-sync/shadow-npm-inject.js +52 -5
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shared.d.ts +11 -0
- package/dist/module-sync/types.d.ts +24 -79
- package/dist/require/cli.js +85 -65
- package/dist/require/cli.js.map +1 -1
- package/package.json +3 -1
|
@@ -1,81 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { Options as ArboristOptions } from '@npmcli/arborist'
|
|
5
|
-
import { Advisory as BaseAdvisory } from '@npmcli/arborist'
|
|
6
|
-
import { Arborist as BaseArborist } from '@npmcli/arborist'
|
|
7
|
-
import { AuditReport as BaseAuditReport } from '@npmcli/arborist'
|
|
8
|
-
import { Diff as BaseDiff } from '@npmcli/arborist'
|
|
9
|
-
type ArboristClass = ArboristInstance & {
|
|
10
|
-
new (...args: any): ArboristInstance
|
|
1
|
+
import { Spinner } from '@socketsecurity/registry/lib/spinner'
|
|
2
|
+
type StripUndefined<T> = {
|
|
3
|
+
[K in keyof T]-?: Exclude<T[K], undefined>
|
|
11
4
|
}
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
| '
|
|
15
|
-
| '
|
|
16
|
-
| '
|
|
17
|
-
| '
|
|
18
|
-
| '
|
|
19
|
-
| '
|
|
20
|
-
| '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
loadActual(options?: ArboristOptions): Promise<SafeNode>
|
|
29
|
-
loadVirtual(options?: ArboristOptions): Promise<SafeNode>
|
|
30
|
-
reify(options?: ArboristReifyOptions): Promise<SafeNode>
|
|
31
|
-
}
|
|
32
|
-
type ArboristReifyOptions = ReifyOptions & ArboristOptions
|
|
33
|
-
type AuditReportInstance = Omit<BaseAuditReport, 'report'> & {
|
|
34
|
-
report: {
|
|
35
|
-
[dependency: string]: AuditAdvisory[]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
type AuditAdvisory = Omit<BaseAdvisory, 'id'> & {
|
|
39
|
-
id: number
|
|
40
|
-
cwe: string[]
|
|
41
|
-
cvss: {
|
|
42
|
-
score: number
|
|
43
|
-
vectorString: string
|
|
44
|
-
}
|
|
45
|
-
vulnerable_versions: string
|
|
46
|
-
}
|
|
47
|
-
declare enum DiffAction {
|
|
48
|
-
add = 'ADD',
|
|
49
|
-
change = 'CHANGE',
|
|
50
|
-
remove = 'REMOVE'
|
|
51
|
-
}
|
|
52
|
-
type Diff = Omit<
|
|
53
|
-
BaseDiff,
|
|
54
|
-
| 'actual'
|
|
55
|
-
| 'children'
|
|
56
|
-
| 'filterSet'
|
|
57
|
-
| 'ideal'
|
|
58
|
-
| 'leaves'
|
|
59
|
-
| 'removed'
|
|
60
|
-
| 'shrinkwrapInflated'
|
|
61
|
-
| 'unchanged'
|
|
62
|
-
> & {
|
|
63
|
-
actual: SafeNode
|
|
64
|
-
children: Diff[]
|
|
65
|
-
filterSet: Set<SafeNode>
|
|
66
|
-
ideal: SafeNode
|
|
67
|
-
leaves: SafeNode[]
|
|
68
|
-
parent: Diff | null
|
|
69
|
-
removed: SafeNode[]
|
|
70
|
-
shrinkwrapInflated: Set<SafeNode>
|
|
71
|
-
unchanged: SafeNode[]
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
ArboristClass,
|
|
75
|
-
ArboristInstance,
|
|
76
|
-
ArboristReifyOptions,
|
|
77
|
-
AuditReportInstance,
|
|
78
|
-
AuditAdvisory,
|
|
79
|
-
DiffAction,
|
|
80
|
-
Diff
|
|
5
|
+
type RangeStyle =
|
|
6
|
+
| 'caret'
|
|
7
|
+
| 'gt'
|
|
8
|
+
| 'gte'
|
|
9
|
+
| 'lt'
|
|
10
|
+
| 'lte'
|
|
11
|
+
| 'pin'
|
|
12
|
+
| 'preserve'
|
|
13
|
+
| 'tilde'
|
|
14
|
+
type FixOptions = {
|
|
15
|
+
autoMerge?: boolean | undefined
|
|
16
|
+
cwd?: string | undefined
|
|
17
|
+
rangeStyle?: RangeStyle | undefined
|
|
18
|
+
spinner?: Spinner | undefined
|
|
19
|
+
test?: boolean | undefined
|
|
20
|
+
testScript?: string | undefined
|
|
81
21
|
}
|
|
22
|
+
type NormalizedFixOptions = StripUndefined<
|
|
23
|
+
Required<Omit<FixOptions, 'spinner'>>
|
|
24
|
+
> &
|
|
25
|
+
Pick<FixOptions, 'spinner'>
|
|
26
|
+
export { RangeStyle, FixOptions, NormalizedFixOptions }
|
package/dist/require/cli.js
CHANGED
|
@@ -36,6 +36,7 @@ const prompts = require('@socketsecurity/registry/lib/prompts')
|
|
|
36
36
|
const shadowNpmPaths = require('./shadow-npm-paths.js')
|
|
37
37
|
const chalkTable = _socketInterop(require('chalk-table'))
|
|
38
38
|
const require$$0$1 = require('node:util')
|
|
39
|
+
const terminalLink = _socketInterop(require('terminal-link'))
|
|
39
40
|
const arrays = require('@socketsecurity/registry/lib/arrays')
|
|
40
41
|
const registry = require('@socketsecurity/registry')
|
|
41
42
|
const npm = require('@socketsecurity/registry/lib/npm')
|
|
@@ -52,7 +53,6 @@ const index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs')
|
|
|
52
53
|
const sorts = require('@socketsecurity/registry/lib/sorts')
|
|
53
54
|
const registryConstants = require('@socketsecurity/registry/lib/constants')
|
|
54
55
|
const isInteractive = require('@socketregistry/is-interactive/index.cjs')
|
|
55
|
-
const terminalLink = _socketInterop(require('terminal-link'))
|
|
56
56
|
const npa = _socketInterop(require('npm-package-arg'))
|
|
57
57
|
const tinyglobby = _socketInterop(require('tinyglobby'))
|
|
58
58
|
const promises = require('@socketsecurity/registry/lib/promises')
|
|
@@ -912,7 +912,7 @@ function emitBanner(name) {
|
|
|
912
912
|
logger.logger.error(getAsciiHeader(name))
|
|
913
913
|
}
|
|
914
914
|
function getAsciiHeader(command) {
|
|
915
|
-
const cliVersion = '0.14.
|
|
915
|
+
const cliVersion = '0.14.80:4ef7be7:e324b7e4:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
916
916
|
const nodeVersion = process$1.version
|
|
917
917
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
918
918
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
@@ -3775,6 +3775,35 @@ function getOctokit() {
|
|
|
3775
3775
|
}
|
|
3776
3776
|
return _octokit
|
|
3777
3777
|
}
|
|
3778
|
+
async function enableAutoMerge(prResponseData) {
|
|
3779
|
+
const octokit = getOctokit()
|
|
3780
|
+
const { node_id: prId, number: prNumber } = prResponseData
|
|
3781
|
+
try {
|
|
3782
|
+
await octokit.graphql(
|
|
3783
|
+
`
|
|
3784
|
+
mutation EnableAutoMerge($pullRequestId: ID!) {
|
|
3785
|
+
enablePullRequestAutoMerge(input: {
|
|
3786
|
+
pullRequestId: $pullRequestId,
|
|
3787
|
+
mergeMethod: SQUASH
|
|
3788
|
+
}) {
|
|
3789
|
+
pullRequest {
|
|
3790
|
+
number
|
|
3791
|
+
autoMergeRequest {
|
|
3792
|
+
enabledAt
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
`,
|
|
3798
|
+
{
|
|
3799
|
+
pullRequestId: prId
|
|
3800
|
+
}
|
|
3801
|
+
)
|
|
3802
|
+
logger.logger.info(`Auto-merge enabled for PR #${prNumber}`)
|
|
3803
|
+
} catch (e) {
|
|
3804
|
+
logger.logger.error(`Failed to enable auto-merge for PR #${prNumber}:`, e)
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3778
3807
|
async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
3779
3808
|
// Lazily access constants.ENV[GITHUB_ACTIONS].
|
|
3780
3809
|
if (constants.ENV[GITHUB_ACTIONS]) {
|
|
@@ -3816,7 +3845,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
|
3816
3845
|
})
|
|
3817
3846
|
}
|
|
3818
3847
|
const octokit = getOctokit()
|
|
3819
|
-
await octokit.pulls.create({
|
|
3848
|
+
return await octokit.pulls.create({
|
|
3820
3849
|
owner,
|
|
3821
3850
|
repo,
|
|
3822
3851
|
title: commitMsg,
|
|
@@ -3843,16 +3872,10 @@ async function install$1(idealTree, options) {
|
|
|
3843
3872
|
arb2.idealTree = idealTree
|
|
3844
3873
|
await arb2.reify()
|
|
3845
3874
|
}
|
|
3846
|
-
async function npmFix(
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
test = false,
|
|
3851
|
-
testScript = 'test'
|
|
3852
|
-
} = {
|
|
3853
|
-
__proto__: null,
|
|
3854
|
-
...options
|
|
3855
|
-
}
|
|
3875
|
+
async function npmFix(
|
|
3876
|
+
_pkgEnvDetails,
|
|
3877
|
+
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
3878
|
+
) {
|
|
3856
3879
|
spinner?.start()
|
|
3857
3880
|
const arb = new shadowNpmInject.SafeArborist({
|
|
3858
3881
|
path: cwd,
|
|
@@ -3948,7 +3971,8 @@ async function npmFix(_pkgEnvDetails, options) {
|
|
|
3948
3971
|
shadowNpmInject.updatePackageJsonFromNode(
|
|
3949
3972
|
editablePkgJson,
|
|
3950
3973
|
arb.idealTree,
|
|
3951
|
-
node
|
|
3974
|
+
node,
|
|
3975
|
+
rangeStyle
|
|
3952
3976
|
)
|
|
3953
3977
|
// eslint-disable-next-line no-await-in-loop
|
|
3954
3978
|
await editablePkgJson.save()
|
|
@@ -3972,7 +3996,15 @@ async function npmFix(_pkgEnvDetails, options) {
|
|
|
3972
3996
|
// Lazily access constants.ENV[CI].
|
|
3973
3997
|
if (constants.ENV[CI$1]) {
|
|
3974
3998
|
// eslint-disable-next-line no-await-in-loop
|
|
3975
|
-
await openGitHubPullRequest(
|
|
3999
|
+
const prResponse = await openGitHubPullRequest(
|
|
4000
|
+
name,
|
|
4001
|
+
targetVersion,
|
|
4002
|
+
cwd
|
|
4003
|
+
)
|
|
4004
|
+
if (autoMerge) {
|
|
4005
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4006
|
+
await enableAutoMerge(prResponse.data)
|
|
4007
|
+
}
|
|
3976
4008
|
}
|
|
3977
4009
|
} catch {
|
|
3978
4010
|
spinner?.error(`Reverting ${fixSpec}`)
|
|
@@ -4207,16 +4239,10 @@ async function install(pkgEnvDetails, options) {
|
|
|
4207
4239
|
stdio: 'ignore'
|
|
4208
4240
|
})
|
|
4209
4241
|
}
|
|
4210
|
-
async function pnpmFix(
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
test = false,
|
|
4215
|
-
testScript = 'test'
|
|
4216
|
-
} = {
|
|
4217
|
-
__proto__: null,
|
|
4218
|
-
...options
|
|
4219
|
-
}
|
|
4242
|
+
async function pnpmFix(
|
|
4243
|
+
pkgEnvDetails,
|
|
4244
|
+
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
4245
|
+
) {
|
|
4220
4246
|
const lockfile = await lockfile_fs.readWantedLockfile(cwd, {
|
|
4221
4247
|
ignoreIncompatible: false
|
|
4222
4248
|
})
|
|
@@ -4273,7 +4299,7 @@ async function pnpmFix(pkgEnvDetails, options) {
|
|
|
4273
4299
|
vulnerableVersionRange
|
|
4274
4300
|
} of infos) {
|
|
4275
4301
|
const node = shadowNpmInject.findPackageNode(
|
|
4276
|
-
arb.
|
|
4302
|
+
arb.actualTree,
|
|
4277
4303
|
name,
|
|
4278
4304
|
oldVersion
|
|
4279
4305
|
)
|
|
@@ -4346,7 +4372,8 @@ async function pnpmFix(pkgEnvDetails, options) {
|
|
|
4346
4372
|
shadowNpmInject.updatePackageJsonFromNode(
|
|
4347
4373
|
editablePkgJson,
|
|
4348
4374
|
arb.actualTree,
|
|
4349
|
-
node
|
|
4375
|
+
node,
|
|
4376
|
+
rangeStyle
|
|
4350
4377
|
)
|
|
4351
4378
|
// eslint-disable-next-line no-await-in-loop
|
|
4352
4379
|
await editablePkgJson.save()
|
|
@@ -4371,7 +4398,15 @@ async function pnpmFix(pkgEnvDetails, options) {
|
|
|
4371
4398
|
// Lazily access constants.ENV[CI].
|
|
4372
4399
|
if (constants.ENV[CI]) {
|
|
4373
4400
|
// eslint-disable-next-line no-await-in-loop
|
|
4374
|
-
await openGitHubPullRequest(
|
|
4401
|
+
const prResponse = await openGitHubPullRequest(
|
|
4402
|
+
name,
|
|
4403
|
+
targetVersion,
|
|
4404
|
+
cwd
|
|
4405
|
+
)
|
|
4406
|
+
if (autoMerge) {
|
|
4407
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4408
|
+
await enableAutoMerge(prResponse.data)
|
|
4409
|
+
}
|
|
4375
4410
|
}
|
|
4376
4411
|
} catch {
|
|
4377
4412
|
spinner?.error(`Reverting ${fixSpec}`)
|
|
@@ -4798,48 +4833,27 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
|
4798
4833
|
|
|
4799
4834
|
const { NPM: NPM$a, PNPM: PNPM$7 } = constants
|
|
4800
4835
|
const CMD_NAME$2 = 'socket fix'
|
|
4801
|
-
async function runFix({
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
}) {
|
|
4808
|
-
const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
|
|
4836
|
+
async function runFix(options_) {
|
|
4837
|
+
const options = shadowNpmInject.assignDefaultFixOptions({
|
|
4838
|
+
__proto__: null,
|
|
4839
|
+
...options_
|
|
4840
|
+
})
|
|
4841
|
+
const pkgEnvDetails = await detectAndValidatePackageEnvironment(options.cwd, {
|
|
4809
4842
|
cmdName: CMD_NAME$2,
|
|
4810
4843
|
logger: logger.logger
|
|
4811
4844
|
})
|
|
4812
4845
|
if (!pkgEnvDetails) {
|
|
4813
|
-
spinner?.stop()
|
|
4814
4846
|
return
|
|
4815
4847
|
}
|
|
4816
4848
|
logger.logger.info(`Fixing packages for ${pkgEnvDetails.agent}`)
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
test,
|
|
4823
|
-
testScript
|
|
4824
|
-
})
|
|
4825
|
-
break
|
|
4826
|
-
}
|
|
4827
|
-
case PNPM$7: {
|
|
4828
|
-
await pnpmFix(pkgEnvDetails, {
|
|
4829
|
-
rangeStyle,
|
|
4830
|
-
spinner,
|
|
4831
|
-
test,
|
|
4832
|
-
testScript
|
|
4833
|
-
})
|
|
4834
|
-
break
|
|
4835
|
-
}
|
|
4849
|
+
const { agent } = pkgEnvDetails
|
|
4850
|
+
if (agent === NPM$a) {
|
|
4851
|
+
await npmFix(pkgEnvDetails, options)
|
|
4852
|
+
} else if (agent === PNPM$7) {
|
|
4853
|
+
await pnpmFix(pkgEnvDetails, options)
|
|
4836
4854
|
}
|
|
4837
|
-
spinner?.stop()
|
|
4838
|
-
// spinner.successAndStop('Socket.dev fix successful')
|
|
4839
4855
|
}
|
|
4840
4856
|
|
|
4841
|
-
const RangeStyles = ['caret', 'gt', 'lt', 'pin', 'preserve', 'tilde']
|
|
4842
|
-
|
|
4843
4857
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
|
|
4844
4858
|
const config$z = {
|
|
4845
4859
|
commandName: 'fix',
|
|
@@ -4847,6 +4861,11 @@ const config$z = {
|
|
|
4847
4861
|
hidden: true,
|
|
4848
4862
|
flags: {
|
|
4849
4863
|
...commonFlags,
|
|
4864
|
+
autoMerge: {
|
|
4865
|
+
type: 'boolean',
|
|
4866
|
+
default: true,
|
|
4867
|
+
description: `Enable auto-merge for pull requests that Socket opens.\n See ${terminalLink('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
|
|
4868
|
+
},
|
|
4850
4869
|
rangeStyle: {
|
|
4851
4870
|
type: 'string',
|
|
4852
4871
|
default: 'preserve',
|
|
@@ -4864,7 +4883,7 @@ const config$z = {
|
|
|
4864
4883
|
test: {
|
|
4865
4884
|
type: 'boolean',
|
|
4866
4885
|
default: true,
|
|
4867
|
-
description: '
|
|
4886
|
+
description: 'Verify the fix by running unit tests'
|
|
4868
4887
|
},
|
|
4869
4888
|
testScript: {
|
|
4870
4889
|
type: 'string',
|
|
@@ -4893,8 +4912,8 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4893
4912
|
parentName
|
|
4894
4913
|
})
|
|
4895
4914
|
const wasBadInput = handleBadInput({
|
|
4896
|
-
test: RangeStyles.includes(cli.flags['rangeStyle']),
|
|
4897
|
-
message: `Expecting range style of ${arrays.joinOr(RangeStyles)}`,
|
|
4915
|
+
test: shadowNpmInject.RangeStyles.includes(cli.flags['rangeStyle']),
|
|
4916
|
+
message: `Expecting range style of ${arrays.joinOr(shadowNpmInject.RangeStyles)}`,
|
|
4898
4917
|
pass: 'ok',
|
|
4899
4918
|
fail: 'missing'
|
|
4900
4919
|
})
|
|
@@ -4909,6 +4928,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4909
4928
|
// Lazily access constants.spinner.
|
|
4910
4929
|
const { spinner } = constants
|
|
4911
4930
|
await runFix({
|
|
4931
|
+
autoMerge: Boolean(cli.flags['autoMerge']),
|
|
4912
4932
|
spinner,
|
|
4913
4933
|
rangeStyle: cli.flags['rangeStyle'] ?? undefined,
|
|
4914
4934
|
test: Boolean(cli.flags['test']),
|
|
@@ -11284,7 +11304,7 @@ void (async () => {
|
|
|
11284
11304
|
await vendor.updater({
|
|
11285
11305
|
name: SOCKET_CLI_BIN_NAME,
|
|
11286
11306
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11287
|
-
version: '0.14.
|
|
11307
|
+
version: '0.14.80',
|
|
11288
11308
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11289
11309
|
})
|
|
11290
11310
|
try {
|
|
@@ -11352,5 +11372,5 @@ void (async () => {
|
|
|
11352
11372
|
await shadowNpmInject.captureException(e)
|
|
11353
11373
|
}
|
|
11354
11374
|
})()
|
|
11355
|
-
//# debugId=
|
|
11375
|
+
//# debugId=bacb26e3-a893-4b98-b932-47c19a1d8f5d
|
|
11356
11376
|
//# sourceMappingURL=cli.js.map
|