Skip to content
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

[Refactor] Use JoinHostPort instead of fmt.Sprintf("%s:%d", host, port) #4873

Open
robertdunlap-servicenow opened this issue Sep 26, 2022 · 0 comments

Comments

@robertdunlap-servicenow

Go‑Lang’s best practices point out that using net.JoinHostPort will reduce the chances of bugs within the application.

Feature Suggestion

Use of JoinHostPort over fmt.Sprintf(..) to manually join hostname and port combinations.

Possible Implementation

Review all manually combined hostnames and ports, and where possible use Go‑Lang best practices, by
replacing fmt.Sprintf(..) with the recommended net.JoinHostPort.

Affected Files

/agent/sockets.go
/agent/api.go
/agent/statsd_server.go
/backend/agentd/agentd.go
/backend/dashboardd/dashboardd.go
/backend/pipelined/handle.go
/util/url/url.go

Context

No specific security risk in the current use of manually combining the hostname and port, but using of Go-Lang library might prevent an subtle issue in the future that is unseen. Reference to golang/go#28308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants