Skip to content

Commit c22adf6

Browse files
committed
chore(wheelhouse): cascade template@df432707
Auto-applied by socket-wheelhouse sync-scaffolding into socket-lib. 8 file(s) touched: - .claude/hooks/fleet/concurrent-cargo-build-guard/README.md - .claude/hooks/fleet/concurrent-cargo-build-guard/index.mts - .claude/hooks/fleet/concurrent-cargo-build-guard/package.json - .claude/hooks/fleet/concurrent-cargo-build-guard/test/index.test.mts - .claude/hooks/fleet/concurrent-cargo-build-guard/tsconfig.json - .claude/hooks/fleet/logger-guard/index.mts - .claude/hooks/fleet/logger-guard/test/logger-guard.test.mts - .git-hooks/fleet/pre-push.mts
1 parent 2b8fb65 commit c22adf6

8 files changed

Lines changed: 29 additions & 333 deletions

File tree

.claude/hooks/fleet/concurrent-cargo-build-guard/README.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

.claude/hooks/fleet/concurrent-cargo-build-guard/index.mts

Lines changed: 0 additions & 151 deletions
This file was deleted.

.claude/hooks/fleet/concurrent-cargo-build-guard/package.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.claude/hooks/fleet/concurrent-cargo-build-guard/test/index.test.mts

Lines changed: 0 additions & 103 deletions
This file was deleted.

.claude/hooks/fleet/concurrent-cargo-build-guard/tsconfig.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.claude/hooks/fleet/logger-guard/index.mts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export function emitBlock(filePath: string, hits: Hit[]): string {
8282
out.push(` …and ${hits.length - 3} more.`)
8383
}
8484
out.push(
85-
' Opt-out for one line (rare): append `// socket-lint: allow console`.',
85+
' Opt-out for one line (rare): append `// socket-lint: allow console` for a ' +
86+
'`console.*` call, or `// socket-lint: allow process-stdio` for a raw ' +
87+
'`process.std{out,err}.write` (the id must match the call kind).',
8688
)
8789
out.push('')
8890
return out.join('\n')
@@ -115,10 +117,16 @@ export function scan(source: string): Hit[] {
115117
const lines = source.split('\n')
116118
const hits: Hit[] = []
117119
for (const leak of findLoggerLeaks(source)) {
118-
// Per-line allow marker: `// socket-lint: allow console`. The marker
119-
// must appear on the same source line as the call.
120+
// Per-line allow marker, keyed by leak kind so the edit-time guard agrees
121+
// with the pre-push `scanLoggerLeaks`: `console.*` waives with
122+
// `// socket-lint: allow console`, raw `process.std*.write` waives with the
123+
// more deliberate `// socket-lint: allow process-stdio`. The marker must be
124+
// on the same source line as the call.
125+
const rule = leak.fullCall.startsWith('process.')
126+
? 'process-stdio'
127+
: 'console'
120128
const sourceLine = lines[leak.line - 1] ?? ''
121-
if (lineIsSuppressed(sourceLine, 'console')) {
129+
if (lineIsSuppressed(sourceLine, rule)) {
122130
continue
123131
}
124132
hits.push({

.claude/hooks/fleet/logger-guard/test/logger-guard.test.mts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,28 @@ test('respects bare # socket-lint: allow marker', async () => {
136136
assert.equal(code, 0)
137137
})
138138

139-
test('respects // socket-lint: allow console marker (slash-slash prefix)', async () => {
139+
test('respects // socket-lint: allow process-stdio marker on a process.* write', async () => {
140140
const { code } = await runHook({
141141
tool_name: 'Edit',
142142
tool_input: {
143143
file_path: 'src/foo.ts',
144-
new_string: 'process.stderr.write(buf) // socket-lint: allow console',
144+
new_string: 'process.stderr.write(buf) // socket-lint: allow process-stdio',
145145
},
146146
})
147147
assert.equal(code, 0)
148148
})
149149

150+
test('a process.* write waived with the console id is still flagged (needs process-stdio)', async () => {
151+
const { code } = await runHook({
152+
tool_name: 'Edit',
153+
tool_input: {
154+
file_path: 'src/foo.ts',
155+
new_string: 'process.stderr.write(buf) // socket-lint: allow console',
156+
},
157+
})
158+
assert.equal(code, 2)
159+
})
160+
150161
test('respects /* socket-lint: allow console */ marker (block-comment prefix)', async () => {
151162
const { code } = await runHook({
152163
tool_name: 'Edit',

0 commit comments

Comments
 (0)