Skip to content
Changes

Reference

fireworks · Oct 24, 2026

What this change means

Atlas added fireworks to its detector catalog in this update.

pkg/detectors/fireworks/fireworks.go+104−0View file
@@ -0,0 +1,104 @@
1added: package fireworks
2added:
3added: import (
4added: "context"
5added: "fmt"
6added: "io"
7added: "net/http"
8added:
9added: regexp "github.com/wasilibs/go-re2"
10added:
11added: "github.com/trufflesecurity/trufflehog/v3/pkg/common"
12added: "github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
13added: "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detector_typepb"
14added: )
15added:
16added: type Scanner struct {
17added: client *http.Client
18added: }
19added:
20added: // Ensure the Scanner satisfies the interface at compile time.
21added: var _ detectors.Detector = (*Scanner)(nil)
22added:
23added: var (
24added: defaultClient = common.SaneHttpClient()
25added: keyPat = regexp.MustCompile(`\b(fw_[a-zA-Z0-9]{20,40})\b`)
26added: )
27added:
28added: func (s Scanner) Keywords() []string {
29added: return []string{"fw_"}
30added: }
31added:
32added: // FromData will find and optionally verify Fireworks AI secrets in a given set of bytes.
33added: func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
34added: dataStr := string(data)
35added:
36added: uniqueMatches := make(map[string]struct{})
37added: for _, match := range keyPat.FindAllStringSubmatch(dataStr, -1) {
38added: uniqueMatches[match[1]] = struct{}{}
39added: }
40added:
41added: for match := range uniqueMatches {
42added: s1 := detectors.Result{
43added: DetectorType: detector_typepb.DetectorType_Fireworks,
44added: Raw: []byte(match),
45added: ExtraData: map[string]string{
46added: "rotation_guide": "https://docs.fireworks.ai/api-reference/introduction",
47added: },
48added: SecretParts: map[string]string{"key": match},
49added: }
50added:
51added: if verify {
52added: client := s.client
53added: if client == nil {
54added: client = defaultClient
55added: }
56added:
57added: isVerified, extraData, verificationErr := verifyMatch(ctx, client, match)
58added: s1.Verified = isVerified
59added: for k, v := range extraData {
60added: s1.ExtraData[k] = v
61added: }
62added: s1.SetVerificationError(verificationErr, match)
63added: }
64added:
65added: results = append(results, s1)
66added: }
67added:
68added: return
69added: }
70added:
71added: func verifyMatch(ctx context.Context, client *http.Client, token string) (bool, map[string]string, error) {
72added: // Fireworks AI models list endpoint returns 200 OK on valid keys and 401 Unauthorized on invalid keys.
73added: req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.fireworks.ai/inference/v1/models", nil)
74added: if err != nil {
75added: return false, nil, err
76added: }
77added: req.Header.Add("Authorization", "Bearer "+token)
78added:
79added: res, err := client.Do(req)
80added: if err != nil {
81added: return false, nil, err
82added: }
83added: defer func() {
84added: _, _ = io.Copy(io.Discard, res.Body)
85added: _ = res.Body.Close()
86added: }()
87added:
88added: switch res.StatusCode {
89added: case http.StatusOK:
90added: return true, nil, nil
91added: case http.StatusUnauthorized:
92added: return false, nil, nil
93added: default:
94added: return false, nil, fmt.Errorf("unexpected HTTP response status %d", res.StatusCode)
95added: }
96added: }
97added:
98added: func (s Scanner) Type() detector_typepb.DetectorType {
99added: return detector_typepb.DetectorType_Fireworks
100added: }
101added:
102added: func (s Scanner) Description() string {
103added: return "Fireworks AI is an inference platform for generative AI models. Fireworks API keys grant access to hosted model inference and management APIs."
104added: }