From 7d8ae16d85332314a3bed394ac8203e72245bb6e Mon Sep 17 00:00:00 2001 From: vthiery Date: Mon, 9 Mar 2026 18:04:47 +0100 Subject: [PATCH] Add configurable HTTP request timeout to SentinelOne connection --- config/sentinelone.spc | 4 ++++ sentinelone/client.go | 14 +++++++++++++- sentinelone/connection_config.go | 5 +++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/sentinelone.spc b/config/sentinelone.spc index 0227809..2efb9de 100644 --- a/config/sentinelone.spc +++ b/config/sentinelone.spc @@ -8,4 +8,8 @@ connection "sentinelone" { # SentinelOne JWT Token # Can also be set with the SENTINELONE_API_TOKEN environment variable # api_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30" + + # HTTP request timeout in seconds for each SentinelOne API call. + # Increase this if queries time out on large tenants. Default: 30. + # request_timeout = 30 } diff --git a/sentinelone/client.go b/sentinelone/client.go index c3b5225..9af0e22 100644 --- a/sentinelone/client.go +++ b/sentinelone/client.go @@ -249,7 +249,7 @@ func Connect(_ context.Context, d *plugin.QueryData) (*SentinelOneClient, error) BaseURL: tenant, APIToken: token, HTTPClient: &http.Client{ - Timeout: 30 * time.Second, + Timeout: requestTimeout(cfg), Transport: &authTransport{underlying: http.DefaultTransport, token: token}, }, } @@ -257,3 +257,15 @@ func Connect(_ context.Context, d *plugin.QueryData) (*SentinelOneClient, error) d.ConnectionManager.Cache.Set(cacheKey, client) return client, nil } + +// requestTimeout returns the configured HTTP timeout, defaulting to 30s. +func requestTimeout(cfg sentineloneConfig) time.Duration { + const defaultTimeout = 30 * time.Second + if cfg.RequestTimeout == nil { + return defaultTimeout + } + if *cfg.RequestTimeout <= 0 { + return defaultTimeout + } + return time.Duration(*cfg.RequestTimeout) * time.Second +} diff --git a/sentinelone/connection_config.go b/sentinelone/connection_config.go index 436c86e..41ed6b3 100644 --- a/sentinelone/connection_config.go +++ b/sentinelone/connection_config.go @@ -5,8 +5,9 @@ import ( ) type sentineloneConfig struct { - ClientID *string `hcl:"client_id"` - APIToken *string `hcl:"api_token"` + ClientID *string `hcl:"client_id"` + APIToken *string `hcl:"api_token"` + RequestTimeout *int `hcl:"request_timeout"` } func ConfigInstance() interface{} {