Harden Windows hook warning escaping · Entire
Harden Windows hook warning escaping
db20ff4→main·
peyton-alt·2w ago·2 files·+28 added/-1 removed
Sessions
36599a4bbda6View transcript
[?
Fix Codex Windows Hook FallbackCodex·1 step](/content/gh/entireio/cli/session/019f0998-b0f5-7202-9db6-34d41fd9be38#timeline-36599a4bbda6/index.html)
Changes
2
cmd/entire/cli/agent
Mhook_command.go+8/-1
Mhook_command_test.go+20
96 unmodified lines
97
98
99
100
100
101
102
103
53 unmodified lines
157
158
159
160
161
162
163
164
165
166
167
168
169
96 unmodified lines
func WrapWindowsProductionPlainTextWarningHookCommand(command string, format WarningFormat) string {
return fmt.Sprintf(
`cmd.exe /d /s /c "where.exe entire >nul 2>nul || (echo %s & exit /b 0) & %s"`,
escapeWindowsCMD(MissingEntireWarning(format)),
escapeWindowsCMD(windowsPlainTextWarning(format)),
command,
)
}
53 unmodified lines
`<`, `^<`,
`>`, `^>`,
`"`, `^"`,
`(`, `^(`,
`)`, `^)`,
`%`, `^%`,
)
return replacer.Replace(s)
func windowsPlainTextWarning(format WarningFormat) string {
return strings.Join(strings.Fields(MissingEntireWarning(format)), " ")
}
Mcmd/entire/cli/agent/hook_command.go+8/-1
89 unmodified lines
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
89 unmodified lines
}
func TestWrapWindowsProductionPlainTextWarningHookCommandUsesSingleLineWarning(t *testing.T) {
t.Parallel()
command := WrapWindowsProductionPlainTextWarningHookCommand("entire hooks codex session-start", WarningFormatMultiLine)
if strings.Contains(command, "\n") {
t.Fatalf("windows wrapper should keep warning command single-line, got %q", command)
}
}
func TestEscapeWindowsCMD_EscapesCmdBlockMetacharacters(t *testing.T) {
t.Parallel()
got := escapeWindowsCMD(`^&|<>\