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

@@ -189,11 +189,16 @@ func (r *SubprocessRunner) Run(ctx context.Context, req PolishRequest) (PolishRe
StderrLogPath: req.StderrLogPath,
})
if err != nil {
return r.failureResult(req, reqModules, runRes, credentialPresent, primaryConcurrencyViaEnv), fmt.Errorf(
"run audita process (binary=%q, stdout_log=%q, stderr_log=%q): %w",
wrappedMessage := fmt.Sprintf(
"run audita process (binary=%q, stdout_log=%q, stderr_log=%q)",
r.binary,
req.StdoutLogPath,
req.StderrLogPath,
)
wrappedMessage = addSubprocessStreamHint(wrappedMessage, err)
return r.failureResult(req, reqModules, runRes, credentialPresent, primaryConcurrencyViaEnv), fmt.Errorf(
"%s: %w",
wrappedMessage,
err,
)
}
@@ -328,6 +333,17 @@ func validateProcessedOutput(path string) error {
return nil
}
func addSubprocessStreamHint(message string, runErr error) string {
if runErr == nil {
return message
}
lower := strings.ToLower(runErr.Error())
if strings.Contains(lower, "bad file descriptor") || strings.Contains(lower, "exit code 120") {
return message + "; hint=audita child process may have started with invalid stderr/stdout descriptors"
}
return message
}
func validateJSONFile(path string) error {
data, err := os.ReadFile(path)
if err != nil {