-
Notifications
You must be signed in to change notification settings - Fork 13
Capture StdErr in command execution error #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,14 @@ | |
| package commandhandler | ||
|
|
||
| import ( | ||
| "github.com/Azure/azure-extension-platform/pkg/constants" | ||
| "github.com/Azure/azure-extension-platform/pkg/logging" | ||
| "github.com/pkg/errors" | ||
| "io" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
|
|
||
| "github.com/Azure/azure-extension-platform/pkg/constants" | ||
| "github.com/Azure/azure-extension-platform/pkg/logging" | ||
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| type ICommandHandler interface { | ||
|
|
@@ -70,10 +71,13 @@ func execCmdInDirWithAction(cmd, workingDir, logDir string, waitForCompletion bo | |
| stdOutFile.Close() | ||
| } | ||
|
|
||
| stdErrFile, err3 := os.OpenFile(errFileName, os.O_RDONLY, constants.FilePermissions_UserOnly_ReadWrite) | ||
| stdErrContents, err3 := os.ReadFile(errFileName) | ||
| if err3 == nil { | ||
| el.InfoFromStream("stderr:", stdErrFile) | ||
| stdErrFile.Close() | ||
| el.Info("stderr: %s", stdErrContents) | ||
|
|
||
| if execErr != nil { | ||
| return exitCode, errors.Wrap(execErr, string(stdErrContents)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably shouldn't fail the command if we can't read the standard error, right?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I didn't change the behavior with regards to that. |
||
| } | ||
| } | ||
|
|
||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, my fear here is that we've dodged a security issue with a bug that causes these events to not reach Kusto. There's a high likelihood that these events will contain security credentials.
Please check with Norberto and Simon on whether there's any plan to scrub these generically for creds. Otherwise, I fear we may have to replicate the logic we have for the BI data to scrub them here.