Skip to content
Changes

Reference

sumologickey · Oct 7, 2026

What this change means

Verification endpoint changed. Changes how the detector verifies or what it treats as the credential.

Field changes
FieldBeforeAfter
Verification endpointBefore: https://%s/api/v1/usersAfter: %s/api/v1/users
pkg/detectors/sumologickey/sumologickey.go+69−33View file
@@ -1,10 +1,12 @@
11package sumologickey
22
33import (
4added: "cmp"
45 "context"
56 "fmt"
67 "io"
78 "net/http"
9added: "net/url"
810 "strings"
911
1012 "github.com/trufflesecurity/trufflehog/v3/pkg/common"
@@ -44,8 +46,10 @@ func (s Scanner) Keywords() []string {
4446 return []string{"sumo", "accessId", "accessKey"}
4547}
4648
47removed: // Default US API endpoint.
48removed: func (Scanner) CloudEndpoint() string { return "api.sumologic.com" }
49added: // CloudEndpoint is the US API endpoint. Endpoints are full URLs so that
50added: // configured verifier endpoints, which may carry a path prefix, are used as
51added: // given.
52added: func (Scanner) CloudEndpoint() string { return "https://api.sumologic.com" }
4953
5054// FromData will find and optionally verify SumoLogicKey secrets in a given set of bytes.
5155func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
@@ -59,50 +63,67 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5963 for _, match := range keyPat.FindAllStringSubmatch(dataStr, -1) {
6064 keyMatches[match[1]] = struct{}{}
6165 }
62removed: endpointMatches := make(map[string]struct{})
66added: hostMatches := make(map[string]struct{})
6367 for _, match := range urlPat.FindAllStringSubmatch(dataStr, -1) {
64removed: endpointMatches[match[0]] = struct{}{}
68added: hostMatches[match[0]] = struct{}{}
6569 }
66removed: if len(endpointMatches) == 0 {
67removed: endpointMatches[s.CloudEndpoint()] = struct{}{}
70added: foundEndpoints := make([]string, 0, len(hostMatches))
71added: for host := range hostMatches {
72added: foundEndpoints = append(foundEndpoints, "https://"+host)
6873 }
6974
75added: // RawV2 identifies the secret, so it is built only from what the data
76added: // says and never from the verification outcome. Otherwise the same key
77added: // gets a different identity when it flips between verified and
78added: // unverified (for example when it is revoked), and consumers that dedupe
79added: // on RawV2 record it as a new secret. The access ID and regional host are
80added: // included only when the data names exactly one of each. The host is kept
81added: // bare (no scheme) because existing identities were recorded that way.
82added: rawV2Id := soleKey(idMatches)
83added: rawV2URL := soleKey(hostMatches)
84added:
7085 for accessKey := range keyMatches {
7186 var (
72removed: r *detectors.Result
73removed: accessId string
74removed: apiEndpoint string
87added: verified bool
88added: verifiedId string
89added: verifiedEndpoint string
90added: lastErr error
7591 )
7692
77removed: for id := range idMatches {
78removed: accessId = id
79removed:
80removed: for e := range endpointMatches {
81removed: apiEndpoint = e
82removed:
83removed: if verify {
84removed: client := s.client
85removed: if client == nil {
86removed: client = defaultClient
93added: if verify {
94added: client := s.VerificationClient(cmp.Or(s.client, defaultClient))
95added:
96added: // Endpoints applies the engine's endpoint configuration:
97added: // configured verifier endpoints, the US cloud endpoint, and
98added: // regional hosts found in the data, each only when enabled.
99added: //
100added: // Only non-nil errors overwrite lastErr so that a clean 401 from
101added: // the wrong region or access ID doesn't erase a failure (500,
102added: // timeout) from a pair that might be authoritative.
103added: endpoints := s.Endpoints(foundEndpoints...)
104added: verification:
105added: for id := range idMatches {
106added: for _, baseURL := range endpoints {
107added: isVerified, vErr := verifyMatch(ctx, client, baseURL, id, accessKey)
108added: if vErr != nil {
109added: lastErr = vErr
87110 }
88removed:
89removed: isVerified, verificationErr := verifyMatch(ctx, client, apiEndpoint, accessId, accessKey)
90111 if isVerified {
91removed: r = createResult(accessId, accessKey, apiEndpoint, isVerified, verificationErr)
112added: verified, verifiedId, verifiedEndpoint, lastErr = true, id, baseURL, nil
113added: break verification
92114 }
93115 }
94116 }
95117 }
96118
97removed: if r == nil {
98removed: // Only include the accessId if we're confident which one it is.
99removed: if len(idMatches) != 1 {
100removed: accessId = ""
101removed: }
102removed: if len(endpointMatches) != 1 || apiEndpoint == s.CloudEndpoint() {
103removed: apiEndpoint = ""
104removed: }
105removed: r = createResult(accessId, accessKey, apiEndpoint, false, nil)
119added: r := createResult(rawV2Id, accessKey, rawV2URL, verified, lastErr)
120added: // Which access ID and endpoint a key verified with are reported here
121added: // rather than in RawV2, so they don't affect the secret's identity.
122added: // RawV2 omits the access ID when the data names several, and keys
123added: // are managed by access ID, so triage needs it from here.
124added: if verified {
125added: r.ExtraData["access_id"] = verifiedId
126added: r.ExtraData["endpoint"] = verifiedEndpoint
106127 }
107128 results = append(results, *r)
108129 }
@@ -110,8 +131,23 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
110131 return results, nil
111132}
112133
113removed: func verifyMatch(ctx context.Context, client *http.Client, endpoint string, id string, key string) (bool, error) {
114removed: req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://%s/api/v1/users", endpoint), nil)
134added: // soleKey returns the only key in m, or "" when m has zero or several keys.
135added: func soleKey(m map[string]struct{}) string {
136added: if len(m) != 1 {
137added: return ""
138added: }
139added: for k := range m {
140added: return k
141added: }
142added: return ""
143added: }
144added:
145added: func verifyMatch(ctx context.Context, client *http.Client, baseURL string, id string, key string) (bool, error) {
146added: endpoint, err := url.JoinPath(baseURL, "/api/v1/users")
147added: if err != nil {
148added: return false, err
149added: }
150added: req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
115151 if err != nil {
116152 return false, err
117153 }