SEC-9872 - #83
Conversation
📝 WalkthroughWalkthroughThe changes introduce three new DNS-safe naming helper functions in e2e_tests.go and replace existing ad-hoc naming logic in push_events.go and workflow_run.go with unified calls to these helpers, removing redundant sanitization and length-truncation logic across E2E test instance creation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/e2e_tests.go (1)
41-48: Consider handling additional invalid DNS characters.The current implementation only replaces
_,.,/but DNS labels may only containa-z,0-9, and-(not at start/end). Characters like spaces,@,#, or other special characters would pass through unchanged.If inputs are guaranteed to be well-formed version strings, this is likely fine. Otherwise, consider a more robust approach.
♻️ Suggested more robust sanitization
func sanitizeForDNS(s string) string { s = strings.ToLower(s) - s = strings.ReplaceAll(s, "_", "-") - s = strings.ReplaceAll(s, ".", "-") - s = strings.ReplaceAll(s, "/", "-") + var result strings.Builder + for _, r := range s { + if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') { + result.WriteRune(r) + } else { + result.WriteRune('-') + } + } + // Collapse consecutive hyphens and trim leading/trailing hyphens + s = result.String() + for strings.Contains(s, "--") { + s = strings.ReplaceAll(s, "--", "-") + } + s = strings.Trim(s, "-") return s }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/e2e_tests.go` around lines 41 - 48, sanitizeForDNS currently only replaces "_", ".", "/" and may leave other invalid characters (spaces, punctuation, etc.) in the output; update sanitizeForDNS to be robust: lowercase input, replace any character not in [a-z0-9-] with '-', collapse consecutive '-' into a single '-', and trim leading/trailing '-' so the result is a valid DNS label; use a regexp or rune loop inside sanitizeForDNS to implement these steps and keep the function signature the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/e2e_tests.go`:
- Around line 41-48: sanitizeForDNS currently only replaces "_", ".", "/" and
may leave other invalid characters (spaces, punctuation, etc.) in the output;
update sanitizeForDNS to be robust: lowercase input, replace any character not
in [a-z0-9-] with '-', collapse consecutive '-' into a single '-', and trim
leading/trailing '-' so the result is a valid DNS label; use a regexp or rune
loop inside sanitizeForDNS to implement these steps and keep the function
signature the same.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d1627e43-68c2-4afa-a486-6a0cd7d9ade6
📒 Files selected for processing (3)
server/e2e_tests.goserver/push_events.goserver/workflow_run.go
This pull request refactors the logic for generating names for E2E and CMT test instances to improve consistency, maintainability, and DNS safety. Helper functions are introduced to centralize and standardize name creation, replacing repeated string manipulation code throughout the codebase.
Summary by CodeRabbit