fix(lint): address G114 gosec findings in ready, pprof, and health plugins#7798
Merged
thevilledev merged 1 commit intocoredns:masterfrom Jan 1, 2026
Merged
Conversation
…ugins
Replace http.Serve() with http.Server{} configured with timeouts to
address G114 gosec findings (HTTP server without timeouts). This
prevents potential slowloris attacks and resource exhaustion.
Changes:
- Add ReadTimeout, WriteTimeout, IdleTimeout (5s each) to HTTP servers
- Use srv.Shutdown(ctx) for graceful shutdown instead of ln.Close()
- Follow existing pattern from plugin/metrics
Fixes part of coredns#7793
Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
thevilledev
approved these changes
Jan 1, 2026
Collaborator
thevilledev
left a comment
There was a problem hiding this comment.
I think following the approach from #7469 is fine. The timeout defaults are sensible but we can always parameterise them later if there's a need for it.
LGTM, thanks!
thevilledev
reviewed
Jan 1, 2026
| h.srv = &http.Server{ | ||
| Handler: h.mux, | ||
| ReadTimeout: 5 * time.Second, | ||
| WriteTimeout: 5 * time.Second, |
Collaborator
There was a problem hiding this comment.
Verified that profiling with >5s of sampling works just fine. I guess pprof buffers the data internally and then does the write call. So all good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace http.Serve() with http.Server{} configured with timeouts to address G114 gosec findings (HTTP server without timeouts). This prevents potential slowloris attacks and resource exhaustion.
Changes:
Fixes part of #7793