Add additional subprocess diagnostics for the audita interface

This commit is contained in:
2026-05-04 13:05:04 -05:00
parent 4a593f9dcb
commit 15037c6d80
4 changed files with 102 additions and 3 deletions

View File

@@ -276,9 +276,27 @@ func buildDiagnostics(req RunRequest, result RunResult, stderrTail string) strin
req.StderrLogPath,
)
if strings.TrimSpace(stderrTail) == "" {
if hint := fdDiagnosticsHint(result.ExitCode, ""); hint != "" {
return details + fmt.Sprintf(" hint=%q", hint)
}
return details
}
return details + fmt.Sprintf(" stderr_tail=%q", stderrTail)
details = details + fmt.Sprintf(" stderr_tail=%q", stderrTail)
if hint := fdDiagnosticsHint(result.ExitCode, stderrTail); hint != "" {
details = details + fmt.Sprintf(" hint=%q", hint)
}
return details
}
func fdDiagnosticsHint(exitCode int, stderrTail string) string {
lowerTail := strings.ToLower(stderrTail)
if strings.Contains(lowerTail, "bad file descriptor") || strings.Contains(lowerTail, "errno 9") {
return "stderr stream appears invalid in child process (fd 2); check wrapper/subprocess environment differences versus direct shell execution"
}
if exitCode == 120 {
return "exit code 120 may indicate interpreter shutdown stream-flush failures (commonly invalid stdout/stderr descriptors in Python processes)"
}
return ""
}
func readRedactedTail(path string, envOverrides map[string]string, maxBytes int64) string {