Benign go Download

github.com/obot-platform/obot/apiclient v0.0.0-20260617201554-3899751eecb8

imports encoding/jsonimports net/http
SHA-256bdee16594f7ab6607342665619a696be0af7ba4a6bdbd204befb6cf2fe018f19
MaleculeH₂(Cm₃F)

Evidence

imports encoding/json lines 1–20
1package apiclient
2
3import (
4 "bytes"
5 "context"
6 "encoding/json"
7 "fmt"
8 "io"
9 "net/http"
10 "slices"
11 "strings"
12 "unicode/utf8"
13
14 "github.com/obot-platform/obot/apiclient/types"
15 "github.com/obot-platform/obot/logger"
16)
17
18var log = logger.Package()
19
20type tokenFetcher func(context.Context, string, TokenFetchOpti …
Native HTTP JSON content type lines 71–90
71:2… / TokenHasScopes reports whether token is valid for baseURL and includes all requested scopes.
72func TokenHasScopes(ctx context.Context, baseURL, token string, scopes []string) error {
73 req, err := http.NewRequestWithContext(ctx, http.MethodPost, strings.TrimRight(baseURL, "/")+"/api-keys/auth", strings.NewReader(`{"validateOnly": true}`))
74 if err != nil {
75 return fmt.Errorf("failed to create request: %w", err)
76 }
77 req.Header.Set("Authorization", "Bearer "+token)
78 req.Header.Set("Content-Type", "application/json")
79
80 resp, err := http.DefaultClient.Do(req)
81 if err != nil {
82 return fmt.Errorf("failed to send request: %w", err)
83 }
84 defer resp.Body.Close()
85
86 var validation tokenScopeValidationResponse
87 if err := json.NewDecoder(resp.Body).Decode(&validation); err != nil {
88 return fmt.Errorf("failed to decode response: %w", err)
89 }
90 if !validation.Allow …
Go JSON marshal call lines 133–142
133:12… " {
134 body = strings.NewReader(v)
135 }
136 default:
137 data, err := json.Marshal(obj)
138 if err != nil {
139 return nil, nil, err
140 }
141 body = bytes.NewBuffer(data)
142 headerKV = append(headerKV, "Content-Type", …
Attaches an HTTP cookie to Go request lines 194–203
194:20… uthorization", "Bearer "+c.Token)
195 }
196 if c.Cookie != nil {
197 req.AddCookie(c.Cookie)
198 }
199
⋯4 lines
Go reads an HTTP response body lines 208–217
208:4… eturn nil, nil, err
209 }
210 if resp.StatusCode > 399 {
211 data, _ := io.ReadAll(resp.Body)
212 msg := string(data)
213 if len(msg) == 0 {
⋯4 lines

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.