MCPcopy Create free account
hub / github.com/codeaashu/claude-code / stripWrappersFromArgv

Function stripWrappersFromArgv

src/tools/BashTool/bashPermissions.ts:678–701  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

676 * there, add it here too.
677 */
678export function stripWrappersFromArgv(argv: string[]): string[] {
679 // SECURITY: Consume optional `--` after wrapper options, matching what the
680 // wrapper does. Otherwise `['nohup','--','rm','--','-/../foo']` yields `--`
681 // as baseCmd and skips path validation. See SAFE_WRAPPER_PATTERNS comment.
682 let a = argv
683 for (;;) {
684 if (a[0] === 'time' || a[0] === 'nohup') {
685 a = a.slice(a[1] === '--' ? 2 : 1)
686 } else if (a[0] === 'timeout') {
687 const i = skipTimeoutFlags(a)
688 if (i < 0 || !a[i] || !/^\d+(?:\.\d+)?[smhd]?$/.test(a[i]!)) return a
689 a = a.slice(i + 1)
690 } else if (
691 a[0] === 'nice' &&
692 a[1] === '-n' &&
693 a[2] &&
694 /^-?\d+$/.test(a[2])
695 ) {
696 a = a.slice(a[3] === '--' ? 4 : 3)
697 } else {
698 return a
699 }
700 }
701}
702
703/**
704 * Env vars that make a *different binary* run (injection or resolution hijack).

Callers

nothing calls this directly

Calls 1

skipTimeoutFlagsFunction · 0.70

Tested by

no test coverage detected