Skip to content

Commit cb98ffb

Browse files
committed
Add nodeDebugFlags constant
1 parent 66ec978 commit cb98ffb

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

bin/cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
constants.execPath,
1818
[
1919
...constants.nodeNoWarningsFlags,
20+
...constants.nodeDebugFlags,
2021
...constants.nodeHardenFlags,
2122
...constants.nodeMemoryFlags,
2223
...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD

src/constants.mts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export type Constants = Remap<
165165
readonly instrumentWithSentryPath: string
166166
readonly minimumVersionByAgent: Map<Agent, string>
167167
readonly nmBinPath: string
168+
readonly nodeDebugFlags: string[]
168169
readonly nodeHardenFlags: string[]
169170
readonly nodeMemoryFlags: string[]
170171
readonly npmCachePath: string
@@ -492,23 +493,33 @@ const lazyMinimumVersionByAgent = () =>
492493

493494
const lazyNmBinPath = () => path.join(constants.rootPath, 'node_modules/.bin')
494495

496+
const lazyNodeDebugFlags = () =>
497+
constants.ENV.SOCKET_CLI_DEBUG ? ['--trace-uncaught', '--trace-warnings'] : []
498+
495499
// Redefine registryConstants.nodeHardenFlags to account for the
496500
// INLINED_SOCKET_CLI_SENTRY_BUILD environment variable.
497501
const lazyNodeHardenFlags = () =>
498502
Object.freeze(
503+
// Harden Node security.
504+
// https://nodejs.org/en/learn/getting-started/security-best-practices
499505
constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD || constants.WIN32
500-
? []
501-
: // Harden Node security.
502-
// https://nodejs.org/en/learn/getting-started/security-best-practices
503-
[
504-
'--disable-proto',
505-
'throw',
506+
? [
507+
// https://nodejs.org/api/cli.html#--disallow-code-generation-from-strings
508+
// '--disallow-code-generation-from-strings'
509+
]
510+
: [
511+
// '--disallow-code-generation-from-strings',
512+
// https://nodejs.org/api/cli.html#--disable-protomode
513+
// '--disable-proto',
514+
// 'throw',
515+
// https://nodejs.org/api/cli.html#--frozen-intrinsics
506516
// We have contributed the following patches to our dependencies to make
507517
// Node's --frozen-intrinsics workable.
508518
// √ https://github.com/SBoudrias/Inquirer.js/pull/1683
509519
// √ https://github.com/pnpm/components/pull/23
510-
'--frozen-intrinsics',
511-
'--no-deprecation',
520+
// '--frozen-intrinsics',
521+
// https://nodejs.org/api/cli.html#--no-deprecation
522+
// '--no-deprecation',
512523
],
513524
)
514525

@@ -677,6 +688,7 @@ const constants: Constants = createConstantsObject(
677688
minimumVersionByAgent: undefined,
678689
nmBinPath: undefined,
679690
nodeHardenFlags: undefined,
691+
nodeDebugFlags: undefined,
680692
nodeMemoryFlags: undefined,
681693
npmCachePath: undefined,
682694
npmGlobalPrefix: undefined,
@@ -709,6 +721,7 @@ const constants: Constants = createConstantsObject(
709721
instrumentWithSentryPath: lazyInstrumentWithSentryPath,
710722
minimumVersionByAgent: lazyMinimumVersionByAgent,
711723
nmBinPath: lazyNmBinPath,
724+
nodeDebugFlags: lazyNodeDebugFlags,
712725
nodeHardenFlags: lazyNodeHardenFlags,
713726
nodeMemoryFlags: lazyNodeMemoryFlags,
714727
npmCachePath: lazyNpmCachePath,

src/shadow/npm/bin.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export default async function shadowBin(
8484
constants.execPath,
8585
[
8686
...constants.nodeNoWarningsFlags,
87+
...constants.nodeDebugFlags,
8788
...constants.nodeHardenFlags,
8889
...constants.nodeMemoryFlags,
8990
...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD
@@ -92,7 +93,6 @@ export default async function shadowBin(
9293
'--require',
9394
constants.shadowNpmInjectPath,
9495
await installLinks(constants.shadowBinPath, binName),
95-
...(useDebug ? ['--trace-uncaught', '--trace-warnings'] : []),
9696
...(useNodeOptions
9797
? [
9898
`--node-options='${nodeOptionsArg ? nodeOptionsArg.slice(15) : ''}${cmdFlagsToString(permArgs)}'`,

src/shadow/npm/install.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function shadowNpmInstall(
6464
constants.execPath,
6565
[
6666
...constants.nodeNoWarningsFlags,
67+
...constants.nodeDebugFlags,
6768
...constants.nodeHardenFlags,
6869
...constants.nodeMemoryFlags,
6970
...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD

0 commit comments

Comments
 (0)