-
Notifications
You must be signed in to change notification settings - Fork 1
fix(FLEETMDM-003): CU-86akj32d7 6 review findings across 5 files #177
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
99b177f
1305122
f142261
31eac82
22b9c5b
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 |
|---|---|---|
|
|
@@ -86,25 +86,25 @@ func unenroll(serialNumber string) error { | |
| client := fleethttp.NewClient() | ||
|
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. 𦩠π unenroll() returns bare errors from http.NewRequest / client.Do without context wrapping In unenroll() (tools/mdm/migration/kandji/main.go), wrapped every bare π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| req, err := http.NewRequest("GET", fmt.Sprintf("https://%s.api.kandji.io/api/v1/devices?serial_number=%s", *subdomainFlag, serialNumber), nil) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("creating get device request: %w", err) | ||
| } | ||
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiTokenFlag)) | ||
| req.Header.Set("Content-Type", "application/json") | ||
| resp, err := client.Do(req) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("performing get device request: %w", err) | ||
| } | ||
| defer resp.Body.Close() | ||
| bodyText, err := io.ReadAll(resp.Body) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("reading get device response body: %w", err) | ||
| } | ||
|
|
||
| var deviceInfo []struct { | ||
| DeviceID string `json:"device_id"` | ||
| } | ||
| if err = json.Unmarshal(bodyText, &deviceInfo); err != nil { | ||
| return err | ||
| return fmt.Errorf("unmarshalling get device response body: %w", err) | ||
| } | ||
| if len(deviceInfo) == 0 { | ||
| return fmt.Errorf("empty deviceInfo response, serial: %s", serialNumber) | ||
|
|
@@ -114,12 +114,12 @@ func unenroll(serialNumber string) error { | |
| // https://api-docs.kandji.io/#97deb582-d86c-444a-aa3b-3528b9a8478f | ||
| req, err = http.NewRequest("DELETE", fmt.Sprintf("https://%s.api.kandji.io/api/v1/devices/%s", *subdomainFlag, deviceInfo[0].DeviceID), nil) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("creating delete device request: %w", err) | ||
| } | ||
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiTokenFlag)) | ||
| resp, err = client.Do(req) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("performing delete device request: %w", err) | ||
| } | ||
| fmt.Println("resp.StatusCode, serialNumber, device", resp.StatusCode, serialNumber, deviceInfo[0].DeviceID) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,19 @@ import ( | |
|
|
||
| var ( | ||
|
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. 𦩠π Hardcoded default MySQL credentials in performance testing tools The hardcoded mysqlAddr/mysqlUser/mysqlPass/mysqlDB var declarations were changed to call a new getEnvOrDefault(envVar, defaultValue string) helper (added in this same file), reading from PERF_TEST_MYSQL_ADDR, PERF_TEST_MYSQL_USER, PERF_TEST_MYSQL_PASS, and PERF_TEST_MYSQL_DB environment variables, falling back to the original hardcoded local-dev values ("localhost:3306", "fleet", "insecure", "fleet") when unset. This makes the credentials overridable without touching source, per the finding's "at minimum" recommendation. Flag-based overrides were not added to keep the change minimal; a more complete fix could also expose these as CLI flags. The companion file volume_vuln_seeder.go mentioned in the finding is not modified since it is a separate file outside the scope of this fix. π€ Prompt for AI agentsfix confidence: π‘ 60 medium β react π/π to teach the reviewer |
||
| // MySQL config | ||
| mysqlAddr = "localhost:3306" | ||
| mysqlUser = "fleet" | ||
| mysqlPass = "insecure" | ||
| mysqlDB = "fleet" | ||
| mysqlAddr = getEnvOrDefault("PERF_TEST_MYSQL_ADDR", "localhost:3306") | ||
| mysqlUser = getEnvOrDefault("PERF_TEST_MYSQL_USER", "fleet") | ||
| mysqlPass = getEnvOrDefault("PERF_TEST_MYSQL_PASS", "insecure") | ||
| mysqlDB = getEnvOrDefault("PERF_TEST_MYSQL_DB", "fleet") | ||
| ) | ||
|
|
||
| func getEnvOrDefault(envVar, defaultValue string) string { | ||
| if v := os.Getenv(envVar); v != "" { | ||
| return v | ||
| } | ||
| return defaultValue | ||
| } | ||
|
|
||
| // TestFunction represents a datastore method to test | ||
| type TestFunction func(context.Context, *mysql.Datastore) error | ||
|
|
||
|
|
@@ -221,7 +228,7 @@ func main() { | |
| Database: mysqlDB, | ||
| }, clock.C) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| log.Fatalf("connect to mysql datastore: %v", err) | ||
| } | ||
| defer func() { _ = ds.Close() }() | ||
|
|
||
|
Comment on lines
228
to
234
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. 𦩠π log.Fatal(err) swallows context in performance_tester.go connection setup In main(), the log.Fatal(err) call after mysql.New(...) fails was changed to log.Fatalf("connect to mysql datastore: %v", err), wrapping the raw driver error with descriptive context as suggested by the finding. π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,11 +265,11 @@ func downloadComponents(workflowName string, headBranch string, artifactNames ma | |
| for { | ||
| workflow, _, err := gc.Actions.GetWorkflowByFileName(ctx, "fleetdm", "fleet", workflowName) | ||
|
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 returns in downloadComponents workflow lookup calls In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("get workflow %s: %w", workflowName, err) | ||
| } | ||
| workflowRuns, _, err := gc.Actions.ListWorkflowRunsByID(ctx, "fleetdm", "fleet", *workflow.ID, nil) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("list workflow runs for %s: %w", workflowName, err) | ||
| } | ||
| for _, wr := range workflowRuns.WorkflowRuns { | ||
| if headBranch == *wr.HeadBranch { | ||
|
|
@@ -306,7 +306,7 @@ func downloadComponents(workflowName string, headBranch string, artifactNames ma | |
| for { | ||
| artifactList, _, err := gc.Actions.ListWorkflowRunArtifacts(ctx, "fleetdm", "fleet", *workflowRun.ID, nil) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("list workflow run artifacts for run %d: %w", *workflowRun.ID, err) | ||
| } | ||
| urls = make(map[string]string) | ||
| for _, artifact := range artifactList.Artifacts { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,3 +106,4 @@ module.exports = { | |
|
|
||
|
|
||
| }; | ||
|
|
||
|
Comment on lines
106
to
+109
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. 𦩠π Duplicated Google Auth + intercept boilerplate across both Android proxy controllers should be extracted to a shared helper The finding recommends extracting the duplicated GoogleAuth client construction, 429 interception, and error-wrapping logic (in the π€ Prompt for AI agentsfix confidence: π΄ 20 low β review closely β react π/π to teach the reviewer |
||
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.
𦩠π execCmdWithOutput returns bare exitCode/err from RunWithOutput without wrapping
In execCmdWithOutput (orbit/pkg/kdialog/kdialog.go), wrapped the error returned from execuser.RunWithOutput with fmt.Errorf("run kdialog via execuser: %w", err) instead of returning it bare, matching the suggested fix exactly. fmt is already imported so no new imports needed.
π€ Prompt for AI agents
fix confidence: π’ 90 high β react π/π to teach the reviewer