@@ -10,11 +10,9 @@ import { NPX } from '../../../../../constants/agents.mts'
1010import ENV from '../../../../../constants/env.mts'
1111import { NODE_MODULES } from '../../../../../constants/packages.mts'
1212import {
13- getInternals ,
1413 SOCKET_CLI_ACCEPT_RISKS ,
1514 SOCKET_CLI_SHADOW_ACCEPT_RISKS ,
1615 SOCKET_CLI_SHADOW_API_TOKEN ,
17- SOCKET_CLI_SHADOW_BIN ,
1816 SOCKET_CLI_SHADOW_PROGRESS ,
1917 SOCKET_CLI_SHADOW_SILENT ,
2018 SOCKET_CLI_VIEW_ALL_RISKS ,
@@ -32,9 +30,6 @@ import type {
3230 NodeClass ,
3331} from '../../types.mts'
3432
35- const internals = getInternals ( )
36- const getIpc = internals . getIpc
37-
3833export const SAFE_NO_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES = {
3934 __proto__ : null ,
4035 audit : false ,
@@ -101,97 +96,7 @@ export class SafeArborist extends Arborist {
10196 this : SafeArborist ,
10297 ...args : Parameters < InstanceType < ArboristClass > [ 'reify' ] >
10398 ) : Promise < NodeClass > {
104- const options = {
105- __proto__ : null ,
106- ...( args . length ? args [ 0 ] : undefined ) ,
107- } as ArboristReifyOptions
108-
109- const ipc = getIpc ? await getIpc ( ) : undefined
110-
111- const binName = ipc ?. [ SOCKET_CLI_SHADOW_BIN ]
112- if ( ! binName ) {
113- return await this [ kRiskyReify ] ( ...args )
114- }
115-
116- await super . reify (
117- {
118- ...options ,
119- ...SAFE_NO_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES ,
120- progress : false ,
121- } ,
122- // @ts -expect-error: TypeScript gets grumpy about rest parameters.
123- ...args . slice ( 1 ) ,
124- )
125-
126- const shadowAcceptRisks = ! ! ipc ?. [ SOCKET_CLI_SHADOW_ACCEPT_RISKS ]
127- const shadowProgress = ! ! ipc ?. [ SOCKET_CLI_SHADOW_PROGRESS ]
128- const shadowSilent = ! ! ipc ?. [ SOCKET_CLI_SHADOW_SILENT ]
129-
130- const acceptRisks = shadowAcceptRisks || ENV . SOCKET_CLI_ACCEPT_RISKS
131- const reportOnlyBlocking =
132- acceptRisks || options [ 'dryRun' ] || options [ 'yes' ]
133- const silent = ! ! options [ 'silent' ]
134- const spinnerInstance =
135- silent || ! shadowProgress ? undefined : ( getSpinner ( ) ?? undefined )
136-
137- const isShadowNpx = binName === NPX
138- const hasExisting = await findUp ( NODE_MODULES , {
139- cwd : process . cwd ( ) ,
140- onlyDirectories : true ,
141- } )
142- const shouldCheckExisting = reportOnlyBlocking ? true : isShadowNpx
143-
144- const needInfoOn = getDetailsFromDiff ( this . diff , {
145- filter : {
146- existing : shouldCheckExisting ,
147- } ,
148- } )
149-
150- const alertsMap = await getAlertsMapFromArborist ( this , needInfoOn , {
151- apiToken : ipc ?. [ SOCKET_CLI_SHADOW_API_TOKEN ] ,
152- spinner : spinnerInstance ,
153- filter : reportOnlyBlocking
154- ? {
155- actions : [ 'error' ] ,
156- blocked : true ,
157- existing : shouldCheckExisting ,
158- }
159- : {
160- actions : [ 'error' , 'monitor' , 'warn' ] ,
161- existing : shouldCheckExisting ,
162- } ,
163- } )
164-
165- if ( alertsMap . size ) {
166- process . exitCode = 1
167- const viewAllRisks = ENV . SOCKET_CLI_VIEW_ALL_RISKS
168- logAlertsMap ( alertsMap , {
169- hideAt : viewAllRisks ? 'none' : 'middle' ,
170- output : process . stderr ,
171- } )
172- throw new Error (
173- `
174- Socket ${ binName } exiting due to risks.${
175- viewAllRisks
176- ? ''
177- : `\nView all risks - Rerun with environment variable ${ SOCKET_CLI_VIEW_ALL_RISKS } =1.`
178- } ${
179- acceptRisks
180- ? ''
181- : `\nAccept risks - Rerun with environment variable ${ SOCKET_CLI_ACCEPT_RISKS } =1.`
182- }
183- ` . trim ( ) ,
184- )
185- }
186- if ( ! silent && ! shadowSilent ) {
187- logger . success (
188- `Socket ${ binName } ${ acceptRisks ? 'accepted' : 'found no' } ${ hasExisting ? ' new' : '' } risks` ,
189- )
190- if ( isShadowNpx ) {
191- logger . log ( `Running ${ options . add ?. [ 0 ] } ` )
192- }
193- }
194-
99+ // Note: Registry no longer provides IPC, always use risky reify.
195100 return await this [ kRiskyReify ] ( ...args )
196101 }
197102}
0 commit comments