Skip to content

Commit c0b52a4

Browse files
committed
chore(deps): bump @socketsecurity/lib to 5.21.0
Catalog bump from 5.20.1 to 5.21.0 plus the caller-side migrations needed for the new API surface: - pnpm-workspace.yaml catalog: 5.20.1 → 5.21.0 - packageManager + engines.pnpm: 11.0.0-rc.0 → 11.0.0-rc.2 to match the rest of the fleet Migrations for 5.21.0 changes: 1. `printFooter` moved out of `@socketsecurity/lib/stdio/header` — it was a latent wrong-path import that lib's loose subpath exports hid on 5.18.2. Now imported from `@socketsecurity/lib/stdio/footer` in scripts/check.mts and scripts/type.mts. 2. `StdioOptions` strictening via `SpawnExtra = Record<string, unknown>` — `spawnExtra?.['stdio']` is `unknown`, not assignable to `StdioOptions`. Cast to `StdioOptions | undefined` at the 9 call sites in utils/dlx/spawn.mts and utils/coana/spawn.mts. Also switched `||` → `??` so an empty-string stdio (not a real value, but TypeScript-possible) doesn't silently fall through. 3. `IpcHandshake` / `IpcMessage` types removed from `@socketsecurity/lib/ipc`. The cli validator re-derives these shapes structurally anyway — define them locally in utils/validation/ipc.mts alongside the validators. 4. `sendBootstrapHandshake`'s parameter requires a non-optional `send` method, but `ChildProcess.send` is optional. Add a runtime typeof-guard with a clear TypeError before the call (we always spawn with an IPC channel; the guard just narrows for the type system). Lint + typecheck clean. Pre-existing check-new-deps hook test failures on main are unrelated to this bump.
1 parent a0418f7 commit c0b52a4

File tree

9 files changed

+75
-36
lines changed

9 files changed

+75
-36
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "socket-cli-monorepo",
33
"version": "0.0.0",
4-
"packageManager": "pnpm@11.0.0-rc.0",
4+
"packageManager": "pnpm@11.0.0-rc.2",
55
"private": true,
66
"engines": {
77
"node": ">=25.9.0",
8-
"pnpm": ">=11.0.0-rc.0"
8+
"pnpm": ">=11.0.0-rc.2"
99
},
1010
"scripts": {
1111
"// Build": "",

packages/cli/src/utils/coana/spawn.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { spawnNode } from '../spawn/spawn-node.mjs'
1212

1313
import type { IpcObject } from '../ipc.mts'
1414
import type { CResult } from '../../types.mjs'
15+
import type { StdioOptions } from 'node:child_process'
1516
import type { SpawnExtra, SpawnOptions } from '@socketsecurity/lib/spawn'
1617

1718
export type CoanaSpawnOptions = SpawnOptions & {
@@ -70,7 +71,8 @@ export async function spawnCoana(
7071
...mixinsEnv,
7172
...spawnEnv,
7273
},
73-
stdio: spawnExtra?.['stdio'] || 'inherit',
74+
stdio:
75+
(spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
7476
},
7577
)
7678

packages/cli/src/utils/dlx/spawn.mts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { getDefaultApiToken, getDefaultProxyUrl } from '../socket/sdk.mjs'
6969
import type { IpcObject } from '../ipc.mts'
7070
import type { CResult } from '../../types.mjs'
7171
import type { ExternalTool } from './vfs-extract.mjs'
72+
import type { StdioOptions } from 'node:child_process'
7273
import type {
7374
SpawnExtra,
7475
SpawnOptions,
@@ -390,7 +391,7 @@ export async function spawnCoanaDlx(
390391
const spawnPromise = spawn(spawnCommand, spawnArgs, {
391392
...dlxOptions,
392393
env: finalEnv,
393-
stdio: spawnExtra?.['stdio'] || 'inherit',
394+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
394395
})
395396

396397
const output = await spawnPromise
@@ -469,7 +470,7 @@ export async function spawnCdxgenDlx(
469470
...process.env,
470471
...spawnEnv,
471472
},
472-
stdio: spawnExtra?.['stdio'] || 'inherit',
473+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
473474
})
474475

475476
return {
@@ -519,7 +520,7 @@ export async function spawnSfwDlx(
519520
...process.env,
520521
...spawnEnv,
521522
},
522-
stdio: spawnExtra?.['stdio'] || 'inherit',
523+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
523524
})
524525

525526
return {
@@ -572,7 +573,7 @@ export async function spawnSocketPatchDlx(
572573
...process.env,
573574
...spawnEnv,
574575
},
575-
stdio: spawnExtra?.['stdio'] || 'inherit',
576+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
576577
})
577578

578579
return {
@@ -590,7 +591,7 @@ export async function spawnSocketPatchDlx(
590591
...process.env,
591592
...spawnEnv,
592593
},
593-
stdio: spawnExtra?.['stdio'] || 'inherit',
594+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
594595
})
595596

596597
return {
@@ -672,7 +673,7 @@ async function spawnToolVfs(
672673
...process.env,
673674
...spawnEnv,
674675
},
675-
stdio: spawnExtra?.['stdio'] || 'inherit',
676+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
676677
})
677678

678679
return {
@@ -1657,7 +1658,7 @@ async function spawnTrivyDlx(
16571658
...process.env,
16581659
...spawnEnv,
16591660
},
1660-
stdio: spawnExtra?.['stdio'] || 'inherit',
1661+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
16611662
})
16621663

16631664
return {
@@ -1719,7 +1720,7 @@ async function spawnTrufflehogDlx(
17191720
...process.env,
17201721
...spawnEnv,
17211722
},
1722-
stdio: spawnExtra?.['stdio'] || 'inherit',
1723+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
17231724
})
17241725

17251726
return {
@@ -1781,7 +1782,7 @@ async function spawnOpengrepDlx(
17811782
...process.env,
17821783
...spawnEnv,
17831784
},
1784-
stdio: spawnExtra?.['stdio'] || 'inherit',
1785+
stdio: (spawnExtra?.['stdio'] as StdioOptions | undefined) ?? 'inherit',
17851786
})
17861787

17871788
return {

packages/cli/src/utils/spawn/spawn-node.mts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,18 @@ export function spawnNode(
117117
extra,
118118
)
119119

120+
// `ChildProcess.send` is optional — only present when the child was
121+
// spawned with an IPC stdio channel. We always pass `ipc` in stdio
122+
// above via `ensureIpcInStdio`, so `send` is guaranteed here, but
123+
// TypeScript can't prove that. The guard narrows safely.
124+
if (typeof spawnResult.process.send !== 'function') {
125+
throw new TypeError(
126+
'spawn-node: expected IPC channel on child process (send is undefined)',
127+
)
128+
}
120129
sendBootstrapHandshake(
121-
spawnResult.process,
130+
// Safe: narrowed by the typeof check above.
131+
spawnResult.process as { send: (message: unknown) => void },
122132
// Always send IPC handshake with bootstrap indicators + custom data.
123133
{
124134
subprocess: true,

packages/cli/src/utils/validation/ipc.mts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,34 @@
77

88
import { randomBytes } from 'node:crypto'
99

10-
import type { IpcHandshake, IpcMessage, IpcStub } from '@socketsecurity/lib/ipc'
10+
import type { IpcStub } from '@socketsecurity/lib/ipc'
11+
12+
/**
13+
* Structural shape of an IPC message as validated by `isValidIpcMessage`.
14+
* Previously re-exported from `@socketsecurity/lib/ipc`; that export was
15+
* removed in lib 5.20.x. The shape is defined here locally because the
16+
* validator is its own source of truth.
17+
*/
18+
export interface IpcMessage<T = unknown> {
19+
id: string
20+
timestamp: number
21+
type: string
22+
data: T
23+
}
24+
25+
/**
26+
* Structural shape of an IPC handshake message. Carries the protocol
27+
* version plus handshake-specific payload (pid, appName, optional
28+
* apiToken). Defined locally alongside `IpcMessage`.
29+
*/
30+
export interface IpcHandshake extends IpcMessage<{
31+
version: string
32+
pid: number
33+
appName: string
34+
apiToken?: string | undefined
35+
}> {
36+
type: 'handshake'
37+
}
1138

1239
/**
1340
* Check if a value is a valid IPC message.

pnpm-lock.yaml

Lines changed: 16 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ catalog:
4242
'@socketregistry/packageurl-js': 1.4.2
4343
'@socketregistry/yocto-spinner': 1.0.25
4444
'@socketsecurity/config': 3.0.1
45-
'@socketsecurity/lib': 5.20.1
45+
'@socketsecurity/lib': 5.21.0
4646
'@socketsecurity/registry': 2.0.2
4747
'@socketsecurity/sdk': 4.0.1
4848
'@types/adm-zip': 0.5.7

scripts/check.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { WIN32 } from '@socketsecurity/lib/constants/platform'
1414
import { getChangedFiles, getStagedFiles } from '@socketsecurity/lib/git'
1515
import { getDefaultLogger } from '@socketsecurity/lib/logger'
1616
import { spawn } from '@socketsecurity/lib/spawn'
17-
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
17+
import { printFooter } from '@socketsecurity/lib/stdio/footer'
18+
import { printHeader } from '@socketsecurity/lib/stdio/header'
1819

1920
import {
2021
getAffectedPackages,

scripts/type.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { parseArgs } from '@socketsecurity/lib/argv/parse'
1212
import { WIN32 } from '@socketsecurity/lib/constants/platform'
1313
import { getDefaultLogger } from '@socketsecurity/lib/logger'
1414
import { spawn } from '@socketsecurity/lib/spawn'
15-
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
15+
import { printFooter } from '@socketsecurity/lib/stdio/footer'
16+
import { printHeader } from '@socketsecurity/lib/stdio/header'
1617

1718
import { getPackagesWithScript } from './utils/monorepo-helper.mts'
1819

0 commit comments

Comments
 (0)