fix: test-login hardening and agent CLI access for harness-config#237
fix: test-login hardening and agent CLI access for harness-config#237ptone wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces several harness-config commands to the allowed agent CLI modes, adds request body size limits, basic email validation, and improved database error handling to the test login handler, along with corresponding unit tests. The review feedback suggests aligning the newly added CLI mode map values for consistency and using net/mail.ParseAddress for more robust email validation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "harness-config": true, | ||
| "harness-config.list": true, | ||
| "harness-config.show": true, | ||
| "harness-config.install": true, | ||
| "harness-config.sync": true, | ||
| "harness-config.push": true, | ||
| "harness-config.pull": true, | ||
| "harness-config.delete": true, | ||
| "harness-config.reset": true, | ||
| "harness-config.upgrade": true, |
There was a problem hiding this comment.
For better readability and consistency with the existing code in this file, please align the true values for the newly added harness-config commands.
| "harness-config": true, | |
| "harness-config.list": true, | |
| "harness-config.show": true, | |
| "harness-config.install": true, | |
| "harness-config.sync": true, | |
| "harness-config.push": true, | |
| "harness-config.pull": true, | |
| "harness-config.delete": true, | |
| "harness-config.reset": true, | |
| "harness-config.upgrade": true, | |
| "harness-config": true, | |
| "harness-config.list": true, | |
| "harness-config.show": true, | |
| "harness-config.install": true, | |
| "harness-config.sync": true, | |
| "harness-config.push": true, | |
| "harness-config.pull": true, | |
| "harness-config.delete": true, | |
| "harness-config.reset": true, | |
| "harness-config.upgrade": true, |
| if !strings.Contains(req.Email, "@") { | ||
| http.Error(w, "email must contain @", http.StatusBadRequest) | ||
| return | ||
| } |
There was a problem hiding this comment.
The current email validation is very basic and can be easily bypassed (e.g., with inputs like "@"). For more robust validation, I recommend using net/mail.ParseAddress from the standard library.
To use this, you'll need to add "net/mail" to your imports.
| if !strings.Contains(req.Email, "@") { | |
| http.Error(w, "email must contain @", http.StatusBadRequest) | |
| return | |
| } | |
| if _, err := mail.ParseAddress(req.Email); err != nil { | |
| http.Error(w, "invalid email address", http.StatusBadRequest) | |
| return | |
| } |
7f8afdc to
56ed788
Compare
Summary
pkg/hub/handlers_test_login.go):store.ErrNotFoundfrom transient DB errors inGetUserByEmail— return 500 for unexpected failures instead of silently creating duplicate user recordshttp.MaxBytesReader(4096)body size limit before JSON decoding@before processingdisplayNamewas explicitly provided so the default (email) doesn't overwrite an existing user's display namecmd/cli_mode.go): Add allharness-configsubcommands toagentAllowedso agents can manage harness configs via the CLIFixes 3 (file-browser badge) and 4 (page title) from the brief were already resolved in the codebase.
Refs GoogleCloudPlatform#396
Test plan
go test ./pkg/hub/ -run TestHandleTestLogin— all tests passgo build ./cmd/— compiles cleanly