-
Notifications
You must be signed in to change notification settings - Fork 1
fix(FLEETMDM-002-2): CU-86akj32d7 62 review findings across 40 files #175
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
c9adb52
68bfc71
42bda98
b332fe7
cd1c5ab
7850c7b
fb6a190
f284e25
7369c94
c3a1ed9
1a082db
6ff03fe
9316a11
19f22d4
39ba955
e23f24f
4e8ffc5
501eeec
94758e0
bf6a6f3
ee2ffe2
e17f5a2
8a13525
482ef4f
830b57b
345a674
8478337
2c13eda
d33c79c
0da9e46
5a3c3ee
fdd84f3
5a46463
b301830
6ce729b
9fb2260
d703178
7e58ef0
d626e27
fb47bb4
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 |
|---|---|---|
|
|
@@ -110,6 +110,7 @@ func NewProxy( | |
|
|
||
| handler, err := newProxyHandler(targetURL, rootCA, insecure, signer) | ||
|
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. 𦩠π NewProxy leaks the listener if handler creation fails after listener is bound In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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. 𦩠π NewProxy leaks the listener if handler creation fails after listener is bound In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| listener.Close() | ||
| return nil, fmt.Errorf("make proxy handler: %w", err) | ||
| } | ||
|
|
||
|
|
@@ -226,7 +227,7 @@ type signingRoundTripper struct { | |
| func (s *signingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { | ||
|
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. 𦩠π signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability Changed the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability Changed the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability Changed the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| // Sign the request before sending | ||
| if err := s.signer.Sign(req); err != nil { | ||
| return nil, fmt.Errorf("signing request: %#v", err) | ||
| return nil, fmt.Errorf("signing request: %w", err) | ||
| } | ||
|
|
||
| // Remove X-Forwarded-For because we are forwarding from 127.0.0.1, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import ( | |
| "bytes" | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| "log/slog" | ||
|
|
@@ -126,7 +125,7 @@ func (lowLevelAPI *GoogleCalendarLoadAPI) CreateEvent(event *calendar.Event) (*c | |
| } | ||
|
|
||
| func (lowLevelAPI *GoogleCalendarLoadAPI) UpdateEvent(event *calendar.Event) (*calendar.Event, error) { | ||
|
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. 𦩠π UpdateEvent stub returns unwrapped errors.New without call-site context In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer
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. 𦩠π UpdateEvent stub returns unwrapped errors.New without call-site context In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer
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. 𦩠π UpdateEvent stub returns unwrapped errors.New without call-site context In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| return nil, errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented") | ||
| return nil, fmt.Errorf("update event: %w", errNotImplemented) | ||
| } | ||
|
|
||
| func (lowLevelAPI *GoogleCalendarLoadAPI) GetEvent(id, _ string) (*calendar.Event, error) { | ||
|
|
@@ -249,3 +248,5 @@ func (lowLevelAPI *GoogleCalendarLoadAPI) Watch(eventUUID string, channelID stri | |
| func (lowLevelAPI *GoogleCalendarLoadAPI) Stop(channelID string, resourceID string) error { | ||
| return nil | ||
| } | ||
|
|
||
| var errNotImplemented = errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,8 @@ func blockWaitForStopEvent(_ string) error { | |
| func trayIconExists() bool { | ||
| conn, err := dbus.SessionBus() | ||
|
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. 𦩠π dbus.SessionBus() error is logged but not returned, code proceeds with nil conn In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π dbus.SessionBus() error is logged but not returned, code proceeds with nil conn In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π dbus.SessionBus() error is logged but not returned, code proceeds with nil conn In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| log.Error().Err(err) | ||
| log.Error().Err(err).Msg("trayIconExists: connect to session bus") | ||
| return false | ||
| } | ||
|
|
||
| // Get the name we would expect systray to reserve for our tray icon. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import ( | |
| func JsonFile(file string, opts ...FlattenOpts) ([]Row, error) { | ||
|
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 propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers Changed π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers Changed π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers Changed π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| rawdata, err := os.ReadFile(file) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("reading json file %s: %w", file, err) | ||
| } | ||
| return Json(rawdata, opts...) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import ( | |
| func JsonlFile(file string, opts ...FlattenOpts) ([]Row, error) { | ||
|
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 propagation without wrapping in jsonl.go file opener In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in jsonl.go file opener In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in jsonl.go file opener In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| f, err := os.Open(file) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("opening jsonl file %s: %w", file, err) | ||
| } | ||
| defer f.Close() | ||
| return Jsonl(f, opts...) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import ( | |
| func PlistFile(file string, opts ...FlattenOpts) ([]Row, error) { | ||
|
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 propagation without wrapping in plist.go file reader In PlistFile (orbit/pkg/dataflatten/plist.go), the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in plist.go file reader In PlistFile (orbit/pkg/dataflatten/plist.go), the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 propagation without wrapping in plist.go file reader In PlistFile (orbit/pkg/dataflatten/plist.go), the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| rawdata, err := os.ReadFile(file) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("reading plist file %s: %w", file, err) | ||
| } | ||
| return Plist(rawdata, opts...) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| package paniclog | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "syscall" | ||
| ) | ||
|
|
@@ -57,28 +57,28 @@ func setStdHandle(stdhandle int32, handle syscall.Handle) error { | |
| func redirectStderr(f *os.File) (UndoFunction, error) { | ||
| stderrFd, err := getStdHandle(syscall.STD_ERROR_HANDLE) | ||
|
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 %w wrapping in redirectStderr In redirectStderr, the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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 %w wrapping in redirectStderr In redirectStderr, the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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 %w wrapping in redirectStderr In redirectStderr, the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| return nil, errors.New("Failed to redirect stderr to file: " + err.Error()) | ||
| return nil, fmt.Errorf("failed to redirect stderr to file: %w", err) | ||
| } | ||
|
|
||
| // duplicate the handle to match unix behavior | ||
| fHandle, err := dupFD(f.Fd()) | ||
|
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 dupFD's caller path (Windows paniclog) In redirectStderr, the dupFD error path π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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 dupFD's caller path (Windows paniclog) In redirectStderr, the dupFD error path π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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 dupFD's caller path (Windows paniclog) In redirectStderr, the dupFD error path π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| return nil, errors.New("Failed to duplicate file: " + err.Error()) | ||
| return nil, fmt.Errorf("failed to duplicate file: %w", err) | ||
| } | ||
|
|
||
| err = setStdHandle(syscall.STD_ERROR_HANDLE, fHandle) | ||
| if err != nil { | ||
| return nil, errors.New("Failed to redirect stderr to file: " + err.Error()) | ||
| return nil, fmt.Errorf("failed to redirect stderr to file: %w", err) | ||
| } | ||
|
|
||
| undo := func() error { | ||
| err := setStdHandle(syscall.STD_ERROR_HANDLE, stderrFd) | ||
| if err != nil { | ||
| return errors.New("Failed to redirect stderr to file: " + err.Error()) | ||
| return fmt.Errorf("failed to redirect stderr to file: %w", err) | ||
| } | ||
| err = syscall.CloseHandle(fHandle) | ||
| if err != nil { | ||
| return errors.New("Failed to close STD_ERROR handle: " + err.Error()) | ||
| return fmt.Errorf("failed to close STD_ERROR handle: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,9 @@ func (r *Runner) Execute() error { | |
|
|
||
| // Runner interrupts the running osquery process. | ||
| func (r *Runner) Interrupt(err error) { | ||
|
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. 𦩠π Interrupt() silently discards a nil cancel func without wrapping/logging In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer
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. 𦩠π Interrupt() silently discards a nil cancel func without wrapping/logging In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer
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. 𦩠π Interrupt() silently discards a nil cancel func without wrapping/logging In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| if err != nil { | ||
| log.Info().Err(fmt.Errorf("interrupt osqueryd runner: %w", err)).Msg("osqueryd runner interrupted") | ||
| } | ||
| if _, cancel := r.getContextAndCancel(); cancel != nil { | ||
| cancel() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ func buildNFPM(opt Options, pkger nfpm.Packager) (string, error) { | |
| } | ||
|
|
||
| if opt.Architecture != ArchAmd64 && opt.Architecture != ArchArm64 { | ||
|
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. 𦩠π buildNFPM bare return without wrapping for architecture validation error In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change. π€ Prompt for AI agentsfix confidence: π’ 98 high β react π/π to teach the reviewer
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. 𦩠π buildNFPM bare return without wrapping for architecture validation error In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change. π€ Prompt for AI agentsfix confidence: π’ 98 high β react π/π to teach the reviewer
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. 𦩠π buildNFPM bare return without wrapping for architecture validation error In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change. π€ Prompt for AI agentsfix confidence: π’ 98 high β react π/π to teach the reviewer |
||
| return "", fmt.Errorf("Invalid architecture: %s", opt.Architecture) | ||
| return "", fmt.Errorf("invalid architecture: %s", opt.Architecture) | ||
| } | ||
|
|
||
| // Initialize autoupdate metadata | ||
|
|
@@ -543,3 +543,4 @@ pkill fleet-desktop || true | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,23 @@ import ( | |
| ) | ||
|
|
||
| func rSign(pkgPath, cert string) error { | ||
|
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. 𦩠π Private key material written to a predictable path in the shared OS temp directory In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself. π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer
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. 𦩠π Private key material written to a predictable path in the shared OS temp directory In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself. π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer
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. 𦩠π Private key material written to a predictable path in the shared OS temp directory In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself. π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| pemPath := filepath.Join(os.TempDir(), "cert.pem") | ||
| defer os.Remove(pemPath) | ||
| err := os.WriteFile(pemPath, []byte(cert), 0o600) | ||
| pemFile, err := os.CreateTemp("", "cert-*.pem") | ||
| if err != nil { | ||
| return fmt.Errorf("creating cert temp file: %s", err) | ||
| } | ||
| pemPath := pemFile.Name() | ||
| defer os.Remove(pemPath) | ||
| if err := pemFile.Chmod(0o600); err != nil { | ||
| pemFile.Close() | ||
| return fmt.Errorf("setting cert temp file permissions: %s", err) | ||
| } | ||
| if _, err := pemFile.WriteString(cert); err != nil { | ||
| pemFile.Close() | ||
| return fmt.Errorf("writing cert data: %s", err) | ||
| } | ||
| if err := pemFile.Close(); err != nil { | ||
| return fmt.Errorf("closing cert temp file: %s", err) | ||
| } | ||
|
|
||
| return retry.Do(func() error { | ||
| var outBuf bytes.Buffer | ||
|
|
@@ -30,8 +41,7 @@ func rSign(pkgPath, cert string) error { | |
| cmd.Stdout = &outBuf | ||
| cmd.Stderr = &outBuf | ||
| if err := cmd.Run(); err != nil { | ||
|
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. 𦩠π rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer
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. 𦩠π rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer
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. 𦩠π rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
| fmt.Println(outBuf.String()) | ||
| return fmt.Errorf("rcodesign: %w", err) | ||
| return fmt.Errorf("rcodesign: %w: %s", err, outBuf.String()) | ||
| } | ||
| return nil | ||
| }, retry.WithMaxAttempts(3)) | ||
|
|
@@ -56,8 +66,7 @@ func rNotarizeStaple(pkg, apiKeyID, apiKeyIssuer, apiKeyContent string) error { | |
| cmd.Stdout = &outBuf | ||
| cmd.Stderr = &outBuf | ||
| if err := cmd.Run(); err != nil { | ||
|
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. 𦩠π rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer
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. 𦩠π rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer
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. 𦩠π rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself. π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
| fmt.Println(outBuf.String()) | ||
| return fmt.Errorf("rcodesign notarize: %w", err) | ||
| return fmt.Errorf("rcodesign notarize: %w: %s", err, outBuf.String()) | ||
| } | ||
| return nil | ||
| }, retry.WithMaxAttempts(3)) | ||
|
|
@@ -72,8 +81,8 @@ func writeAPIKeys(issuer, id, content string) (string, error) { | |
| // The underliying tools (rcodesign and Transporter) expect to find a | ||
| // certificate key in this path. | ||
| path := filepath.Join(homedir, ".appstoreconnect", "private_keys") | ||
|
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. 𦩠π writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory. π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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. 𦩠π writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory. π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
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. 𦩠π writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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. 𦩠π secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory. π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err = secure.MkdirAll(path, 0o600); err != nil { | ||
| return "", fmt.Errorf("finding home dir: %s", err) | ||
| if err = secure.MkdirAll(path, 0o700); err != nil { | ||
| return "", fmt.Errorf("creating private keys dir: %s", err) | ||
| } | ||
|
|
||
| keyPath := filepath.Join(path, fmt.Sprintf("AuthKey_%s.p8", id)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "encoding/xml" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| ) | ||
|
|
||
|
|
@@ -64,13 +65,35 @@ func TransformHeat(path string) error { | |
| return fmt.Errorf("marshal xml: %w", err) | ||
| } | ||
|
|
||
| // Write to a temp file in the same directory first, then rename over the | ||
| // original. This avoids destroying the original file if the write fails, | ||
| // and the rename is atomic on the same filesystem. | ||
| dir := filepath.Dir(path) | ||
| tmp, err := os.CreateTemp(dir, filepath.Base(path)+".tmp-*") | ||
| if err != nil { | ||
| return fmt.Errorf("create temp file: %w", err) | ||
| } | ||
| tmpPath := tmp.Name() | ||
| defer os.Remove(tmpPath) | ||
|
|
||
| if _, err := tmp.Write(contents); err != nil { | ||
| tmp.Close() | ||
| return fmt.Errorf("write temp file: %w", err) | ||
| } | ||
| if err := tmp.Close(); err != nil { | ||
| return fmt.Errorf("close temp file: %w", err) | ||
| } | ||
| if err := os.Chmod(tmpPath, 0o600); err != nil { | ||
| return fmt.Errorf("chmod temp file: %w", err) | ||
| } | ||
|
|
||
| // Remove first as we encounter permission errors on some Linux configurations. | ||
|
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. 𦩠π os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution. π€ Prompt for AI agentsfix confidence: π‘ 65 medium β react π/π to teach the reviewer
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. 𦩠π os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution. π€ Prompt for AI agentsfix confidence: π‘ 65 medium β react π/π to teach the reviewer
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. 𦩠π os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution. π€ Prompt for AI agentsfix confidence: π‘ 65 medium β react π/π to teach the reviewer |
||
| if err := os.Remove(path); err != nil { | ||
| return fmt.Errorf("remove old file: %w", err) | ||
| } | ||
|
|
||
| if err := os.WriteFile(path, contents, 0o600); err != nil { | ||
| return fmt.Errorf("write file: %w", err) | ||
| if err := os.Rename(tmpPath, path); err != nil { | ||
| return fmt.Errorf("rename temp file: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ func (r *Runner) Execute() error { | |
| r.srv.RegisterPlugin(plugins...) | ||
|
|
||
| if err := r.srv.Run(); err != nil { | ||
|
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 table extension.go Execute() In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 table extension.go Execute() In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer
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 table extension.go Execute() In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| return err | ||
| return fmt.Errorf("running extension manager server: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
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.
𦩠π NewProxy leaks the listener if handler creation fails after listener is bound
In
NewProxy, addedlistener.Close()before returning the error whennewProxyHandlerfails, preventing the bound TLS listener socket from leaking on that error path.π€ Prompt for AI agents
fix confidence: π’ 90 high β react π/π to teach the reviewer