Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/sentinelone.spc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
14 changes: 13 additions & 1 deletion sentinelone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,23 @@ 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},
},
}

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
}
5 changes: 3 additions & 2 deletions sentinelone/connection_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down