Skip to content

Ensure http.Server has idle and read timeouts configured#30151

Merged
jentfoo merged 2 commits intomasterfrom
jent/http_server_timeouts
Aug 8, 2023
Merged

Ensure http.Server has idle and read timeouts configured#30151
jentfoo merged 2 commits intomasterfrom
jent/http_server_timeouts

Conversation

@jentfoo
Copy link
Copy Markdown
Contributor

@jentfoo jentfoo commented Aug 7, 2023

Configures the ReadHeaderTimeout and IdleTimeout for instances of http.Server highlighted by gosec. Similar to the PR here: https://github.com/gravitational/teleport.e/pull/1948

Configures the `ReadHeaderTimeout` and `IdleTimeout` for instances of `http.Server` highlighted by `gosec`.
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/proto"

apidefaults "github.com/gravitational/teleport/api/defaults"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there's only a single defaults package imported here so we can drop the alias

Suggested change
apidefaults "github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/defaults"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current imports of this defaults all seemed to be consistently aliasing to apidefaults. So I was just trying to stay consistent to that existing usage. Let me know your thoughts

Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's likely only the case when "github.com/gravitational/teleport/lib/defaults" is also imported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO having the same aliases across all files makes things simpler. Otherwise, if lib/defaults is added to these files, we may end up with libdefaults and defaults, which points to something completely different than you would expect.

Comment thread lib/client/redirect.go Outdated
@jentfoo jentfoo added this pull request to the merge queue Aug 8, 2023
@jentfoo jentfoo removed this pull request from the merge queue due to a manual request Aug 8, 2023
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
@jentfoo jentfoo enabled auto-merge August 8, 2023 14:41
@jentfoo jentfoo added this pull request to the merge queue Aug 8, 2023
Merged via the queue into master with commit 20d62a4 Aug 8, 2023
@jentfoo jentfoo deleted the jent/http_server_timeouts branch August 8, 2023 15:10
jentfoo added a commit that referenced this pull request Aug 10, 2023
This commit builds on the work from #30151 in the following ways:
* A couple additional server configuartions that were missing timeouts are now covered
* Timeouts are now configured in a consistent way.  This means:
  - Configuring the `ReadTimeout` which was not covered by only setting `ReadHeaderTimeout`
  - Set `ReadHeaderTimeout` to be the more aggressive (1 second) `defaults.ReadHeadersTimeout`
  - Set a `WriteTimeout` in cases of potential large responses
jentfoo added a commit that referenced this pull request Aug 11, 2023
This commit builds on the work from #30151 in the following ways:
* A couple additional server configuartions that were missing timeouts are now covered
* Timeouts are now configured in a consistent way.  This means:
  - Configuring the `ReadTimeout` which was not covered by only setting `ReadHeaderTimeout`
  - Set `ReadHeaderTimeout` to be the more aggressive (1 second) `defaults.ReadHeadersTimeout`
  - Set a `WriteTimeout` in cases of potential large responses
github-merge-queue Bot pushed a commit that referenced this pull request Aug 11, 2023
* Consistent `http.Server` timeout configurations

This commit builds on the work from #30151 in the following ways:
* A couple additional server configuartions that were missing timeouts are now covered
* Timeouts are now configured in a consistent way.  This means:
  - Configuring the `ReadTimeout` which was not covered by only setting `ReadHeaderTimeout`
  - Set `ReadHeaderTimeout` to be the more aggressive (1 second) `defaults.ReadHeadersTimeout`
  - Set a `WriteTimeout` in cases of potential large responses

* defaults.go: Update ReadHeadersTimeout to 10 seconds

* alpnproxy/local_proxy.go: Move http timeouts to the top
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants