Skip to content
Changes

Reference

lambdacloud · Oct 21, 2026

What this change means

Atlas added lambdacloud to its detector catalog in this update.

pkg/detectors/lambdacloud/lambdacloud.go+126−0View file
@@ -0,0 +1,126 @@
1added: package lambdacloud
2added:
3added: import (
4added: "context"
5added: "encoding/json"
6added: "fmt"
7added: "io"
8added: "net/http"
9added:
10added: regexp "github.com/wasilibs/go-re2"
11added:
12added: "github.com/trufflesecurity/trufflehog/v3/pkg/common"
13added: "github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
14added: "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detector_typepb"
15added: )
16added:
17added: const verifyURL = "https://cloud.lambda.ai/api/v1/identity"
18added:
19added: type Scanner struct {
20added: client *http.Client
21added: }
22added:
23added: var _ detectors.Detector = (*Scanner)(nil)
24added:
25added: var (
26added: defaultClient = common.SaneHttpClient()
27added:
28added: keyPat = regexp.MustCompile(`\b(secret_[a-z0-9][a-z0-9-]{0,63}_[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}\.[A-Za-z0-9]{32})(?:[^A-Za-z0-9]|$)`)
29added: )
30added:
31added: func (s Scanner) Keywords() []string {
32added: return []string{"secret_"}
33added: }
34added:
35added: func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) ([]detectors.Result, error) {
36added: var results []detectors.Result
37added: seen := make(map[string]struct{})
38added: for _, match := range keyPat.FindAllSubmatchIndex(data, -1) {
39added: token := string(data[match[2]:match[3]])
40added: if _, ok := seen[token]; ok {
41added: continue
42added: }
43added: seen[token] = struct{}{}
44added:
45added: result := detectors.Result{
46added: DetectorType: s.Type(),
47added: Raw: []byte(token),
48added: SecretParts: map[string]string{"key": token},
49added: }
50added:
51added: if verify {
52added: client := s.client
53added: if client == nil {
54added: client = defaultClient
55added: }
56added: verified, extraData, verificationErr := verifyToken(ctx, client, token)
57added: result.Verified = verified
58added: result.ExtraData = extraData
59added: result.SetVerificationError(verificationErr, token)
60added: }
61added: results = append(results, result)
62added: }
63added: return results, nil
64added: }
65added:
66added: func verifyToken(ctx context.Context, client *http.Client, token string) (bool, map[string]string, error) {
67added: req, err := http.NewRequestWithContext(ctx, http.MethodGet, verifyURL, nil)
68added: if err != nil {
69added: return false, nil, err
70added: }
71added: req.Header.Set("Authorization", "Bearer "+token)
72added: req.Header.Set("Accept", "application/json")
73added:
74added: res, err := client.Do(req)
75added: if err != nil {
76added: return false, nil, err
77added: }
78added: defer func() {
79added: _, _ = io.Copy(io.Discard, res.Body)
80added: _ = res.Body.Close()
81added: }()
82added:
83added: switch res.StatusCode {
84added: case http.StatusOK:
85added: var response struct {
86added: Data identityResponse `json:"data"`
87added: }
88added: if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
89added: return false, nil, err
90added: }
91added: if response.Data.ID == "" || response.Data.AccountID == "" {
92added: return false, nil, fmt.Errorf("unexpected Lambda Cloud identity response")
93added: }
94added:
95added: extraData := map[string]string{
96added: "identity_id": response.Data.ID,
97added: "account_id": response.Data.AccountID,
98added: }
99added: if response.Data.IdentityType != "" {
100added: extraData["identity_type"] = response.Data.IdentityType
101added: }
102added: if response.Data.Email != "" {
103added: extraData["email"] = response.Data.Email
104added: }
105added: return true, extraData, nil
106added: case http.StatusUnauthorized:
107added: return false, nil, nil
108added: default:
109added: return false, nil, fmt.Errorf("unexpected HTTP response status %d", res.StatusCode)
110added: }
111added: }
112added:
113added: func (s Scanner) Type() detector_typepb.DetectorType {
114added: return detector_typepb.DetectorType_LambdaCloud
115added: }
116added:
117added: func (s Scanner) Description() string {
118added: return "Lambda Cloud provides GPU computing infrastructure. Lambda Cloud API keys can be used to manage instances, filesystems, SSH keys, and other cloud resources."
119added: }
120added:
121added: type identityResponse struct {
122added: ID string `json:"id"`
123added: AccountID string `json:"account_id"`
124added: IdentityType string `json:"identity_type"`
125added: Email string `json:"email"`
126added: }