-
Notifications
You must be signed in to change notification settings - Fork 1
fix(FLEETMDM-003): 6 review findings across 3 files #128
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 |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| package paniclog | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "golang.org/x/sys/unix" | ||
|
|
@@ -16,20 +16,20 @@ func redirectStderr(f *os.File) (UndoFunction, error) { | |
| stderrFd := int(os.Stderr.Fd()) | ||
| oldfd, err := unix.Dup(stderrFd) | ||
| if err != nil { | ||
| return nil, errors.New("Failed to redirect stderr to file: " + err.Error()) | ||
| return nil, fmt.Errorf("redirect stderr to file: %w", err) | ||
| } | ||
|
|
||
|
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. 𦩠π Second Dup2 failure error also discards err chain In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| err = unix.Dup2(int(f.Fd()), stderrFd) | ||
| if err != nil { | ||
| return nil, errors.New("Failed to redirect stderr to file: " + err.Error()) | ||
| return nil, fmt.Errorf("redirect stderr to file: %w", err) | ||
| } | ||
|
|
||
|
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. 𦩠π Duplicate string-concatenation error swallows original error twice in undo path In the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| undo := func() error { | ||
| undoErr := unix.Dup2(oldfd, stderrFd) | ||
| unix.Close(oldfd) | ||
|
|
||
| if undoErr != nil { | ||
| return errors.New("Failed to reverse stderr redirection: " + err.Error()) | ||
| return fmt.Errorf("reverse stderr redirection: %w", undoErr) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,15 +232,15 @@ func parseAppSSOPlatformCommandOutput(output []byte, expectedExtensionIdentifier | |
| } | ||
| realm, ok := realm_.(string) | ||
| if !ok { | ||
| return nil, fmt.Errorf("unexpected type for \"realm\" key in \"kerberosStatus\": %T", err) | ||
| return nil, fmt.Errorf("unexpected type for \"realm\" key in \"kerberosStatus\": %T", realm_) | ||
| } | ||
| upn_, ok := userConfig.KerberosStatus[0]["upn"] | ||
| if !ok { | ||
| return nil, errors.New("missing \"upn\" key in \"kerberosStatus\"") | ||
| } | ||
| upn, ok := upn_.(string) | ||
| if !ok { | ||
| return nil, fmt.Errorf("unexpected type for \"upn\" key in \"kerberosStatus\": %T", err) | ||
| return nil, fmt.Errorf("unexpected type for \"upn\" key in \"kerberosStatus\": %T", upn_) | ||
| } | ||
| if upn == "" { | ||
| return nil, errors.New("empty \"upn\" key in \"kerberosStatus\"") | ||
|
Comment on lines
232
to
246
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. 𦩠π Bare error return without wrapping in extractJSONSections/parseAppSSOPlatformCommandOutput helper chain In parseAppSSOPlatformCommandOutput, the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
Comment on lines
232
to
246
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. 𦩠π Same wrong-variable %T bug repeated for upn type assertion In parseAppSSOPlatformCommandOutput, the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,8 +250,7 @@ func getSeceditData() (SeceditData, error) { | |
| // Load the .inf file content | ||
| cfg, err := ini.Load(fileContent) | ||
| if err != nil { | ||
| fmt.Printf("Error: %v\n", err) | ||
| return data, err | ||
| return data, fmt.Errorf("failed to load secedit inf file: %w", err) | ||
| } | ||
|
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. 𦩠π secedit.exe error printed with fmt.Printf and swallowed, not wrapped In π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer |
||
|
|
||
| // Parse System Access section | ||
|
|
||
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.
𦩠π errors.New used instead of wrapped fmt.Errorf in orbit stderr redirection
In
redirectStderr, replaced the firsterrors.New("Failed to redirect stderr to file: " + err.Error())(afterunix.Dup) withfmt.Errorf("redirect stderr to file: %w", err), preserving the error chain; also switched the import fromerrorstofmtsinceerrorsis no longer used.π€ Prompt for AI agents
fix confidence: π’ 90 high β react π/π to teach the reviewer