Skip to content

Commit 737f66c

Browse files
committed
Fix linting issues
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
1 parent 89a5dfd commit 737f66c

File tree

12 files changed

+22
-16
lines changed

12 files changed

+22
-16
lines changed

cmd/thv/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func setupSignalHandler() context.Context {
8484
sigCh := make(chan os.Signal, 1)
8585
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
8686

87-
ctx, cancel := context.WithCancel(context.Background())
87+
ctx, cancel := context.WithCancel(context.Background()) //nolint:gosec // G118 - cancel called in signal handler goroutine
8888
go func() {
8989
<-sigCh
9090
slog.Debug("received signal, cleaning up lock files")

pkg/auth/github_provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (*GitHubProvider) CanHandle(introspectURL string) bool {
127127
// IntrospectToken introspects a GitHub OAuth token and returns JWT claims
128128
// This calls GitHub's token validation API to verify the token and extract user information
129129
func (g *GitHubProvider) IntrospectToken(ctx context.Context, token string) (jwt.MapClaims, error) {
130+
//nolint:gosec // G706 - baseURL is a configured GitHub API endpoint
130131
slog.Debug("using GitHub token validation provider", "url", g.baseURL)
131132

132133
// Apply rate limiting to prevent DoS and respect GitHub API limits
@@ -142,6 +143,7 @@ func (g *GitHubProvider) IntrospectToken(ctx context.Context, token string) (jwt
142143
}
143144

144145
// Create POST request
146+
//nolint:gosec // G704 - URL is configured GitHub API endpoint
145147
req, err := http.NewRequestWithContext(ctx, "POST", g.baseURL, bytes.NewReader(bodyBytes))
146148
if err != nil {
147149
return nil, fmt.Errorf("failed to create GitHub validation request: %w", err)

pkg/auth/token.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (g *GoogleProvider) IntrospectToken(ctx context.Context, token string) (jwt
115115
u.RawQuery = query.Encode()
116116

117117
// Create the GET request
118+
//nolint:gosec // G704 - URL from trusted OIDC discovery config
118119
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
119120
if err != nil {
120121
return nil, fmt.Errorf("failed to create Google tokeninfo request: %w", err)
@@ -290,6 +291,7 @@ func (r *RFC7662Provider) IntrospectToken(ctx context.Context, token string) (jw
290291
formData.Set("token_type_hint", "access_token")
291292

292293
// Create POST request with form data
294+
//nolint:gosec // G704 - URL is configured introspection endpoint
293295
req, err := http.NewRequestWithContext(ctx, "POST", r.url, strings.NewReader(formData.Encode()))
294296
if err != nil {
295297
return nil, fmt.Errorf("failed to create introspection request: %w", err)

pkg/authserver/server/handlers/callback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (h *Handler) writeAuthorizationResponse(
209209
authorizeRequest.RequestedScope = append(authorizeRequest.RequestedScope, scope)
210210
authorizeRequest.GrantedScope = append(authorizeRequest.GrantedScope, scope)
211211
} else {
212-
slog.Warn("filtered unregistered scope from authorization",
212+
slog.Warn("filtered unregistered scope from authorization", //nolint:gosec // G706 - scope from server-side storage
213213
"scope", scope,
214214
"client_id", pending.ClientID,
215215
)
@@ -242,7 +242,7 @@ func (h *Handler) buildAuthorizeRequesterFromPending(
242242
// so failure indicates storage corruption
243243
redirectURI, err := url.Parse(pending.RedirectURI)
244244
if err != nil {
245-
slog.Error("stored redirect URI is invalid",
245+
slog.Error("stored redirect URI is invalid", //nolint:gosec // G706 - redirect URI from server-side storage
246246
"redirect_uri", pending.RedirectURI,
247247
"error", err,
248248
)

pkg/authserver/storage/redis.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (s *RedisStorage) RegisterClient(ctx context.Context, client fosite.Client)
240240
Public: client.IsPublic(),
241241
}
242242

243-
data, err := json.Marshal(stored)
243+
data, err := json.Marshal(stored) //nolint:gosec // G117 - internal Redis storage serialization, not exposed to users
244244
if err != nil {
245245
return fmt.Errorf("failed to marshal client: %w", err)
246246
}
@@ -760,7 +760,7 @@ func marshalUpstreamTokensWithTTL(tokens *UpstreamTokens) ([]byte, time.Duration
760760
ClientID: tokens.ClientID,
761761
}
762762

763-
data, err := json.Marshal(stored)
763+
data, err := json.Marshal(stored) //nolint:gosec // G117 - internal Redis storage serialization, not exposed to users
764764
if err != nil {
765765
return nil, 0, fmt.Errorf("failed to marshal upstream tokens: %w", err)
766766
}
@@ -932,7 +932,7 @@ func (s *RedisStorage) StorePendingAuthorization(ctx context.Context, state stri
932932
CreatedAt: pending.CreatedAt.Unix(),
933933
}
934934

935-
data, err := json.Marshal(stored)
935+
data, err := json.Marshal(stored) //nolint:gosec // G117 - internal Redis storage serialization, not exposed to users
936936
if err != nil {
937937
return fmt.Errorf("failed to marshal pending authorization: %w", err)
938938
}
@@ -1021,7 +1021,7 @@ func (s *RedisStorage) CreateUser(ctx context.Context, user *User) error {
10211021
UpdatedAt: user.UpdatedAt.Unix(),
10221022
}
10231023

1024-
data, err := json.Marshal(stored)
1024+
data, err := json.Marshal(stored) //nolint:gosec // G117 - internal Redis storage serialization, not exposed to users
10251025
if err != nil {
10261026
return fmt.Errorf("failed to marshal user: %w", err)
10271027
}
@@ -1153,7 +1153,7 @@ func (s *RedisStorage) CreateProviderIdentity(ctx context.Context, identity *Pro
11531153
LastUsedAt: identity.LastUsedAt.Unix(),
11541154
}
11551155

1156-
data, err := json.Marshal(stored)
1156+
data, err := json.Marshal(stored) //nolint:gosec // G117 - internal Redis storage serialization, not exposed to users
11571157
if err != nil {
11581158
return fmt.Errorf("failed to marshal identity: %w", err)
11591159
}

pkg/authz/response_filter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ func (rfw *ResponseFilteringWriter) FlushAndFilter() error {
6161
// If it's not a successful response, just pass it through
6262
if rfw.statusCode != http.StatusOK && rfw.statusCode != http.StatusAccepted {
6363
rfw.ResponseWriter.WriteHeader(rfw.statusCode)
64-
_, err := rfw.ResponseWriter.Write(rfw.buffer.Bytes())
64+
_, err := rfw.ResponseWriter.Write(rfw.buffer.Bytes()) //nolint:gosec // G705 - JSON-RPC response, not rendered as HTML
6565
return err
6666
}
6767

6868
// Check if this is a list operation that needs filtering
6969
if !isListOperation(rfw.method) {
7070
rfw.ResponseWriter.WriteHeader(rfw.statusCode)
71-
_, err := rfw.ResponseWriter.Write(rfw.buffer.Bytes())
71+
_, err := rfw.ResponseWriter.Write(rfw.buffer.Bytes()) //nolint:gosec // G705 - JSON-RPC response, not rendered as HTML
7272
return err
7373
}
7474

@@ -77,7 +77,7 @@ func (rfw *ResponseFilteringWriter) FlushAndFilter() error {
7777
// Skip filtering for empty responses (common in SSE scenarios where actual data comes via SSE stream)
7878
if len(rawResponse) == 0 {
7979
rfw.ResponseWriter.WriteHeader(rfw.statusCode)
80-
_, err := rfw.ResponseWriter.Write(rawResponse)
80+
_, err := rfw.ResponseWriter.Write(rawResponse) //nolint:gosec // G705 - JSON-RPC response, not rendered as HTML
8181
return err
8282
}
8383

pkg/container/images/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func createTarFromDir(srcDir string, writer io.Writer) error {
247247
// If it's a regular file, write the contents
248248
if !info.IsDir() {
249249
// #nosec G304 - This is safe because we're only opening files within the specified context directory
250-
file, err := os.Open(path)
250+
file, err := os.Open(path) //nolint:gosec // G122 - path from filepath.Walk within validated source directory
251251
if err != nil {
252252
return fmt.Errorf("failed to open file: %w", err)
253253
}

pkg/transport/stdio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (t *StdioTransport) Start(ctx context.Context) error {
220220
}
221221

222222
// Start a goroutine to handle container exit
223-
go t.handleContainerExit(ctx)
223+
go t.handleContainerExit(ctx) //nolint:gosec // G118 - background goroutine manages container lifecycle, outlives request
224224

225225
return nil
226226
}

pkg/updates/checker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ func (d *defaultUpdateChecker) CheckLatestVersion() error {
211211
}
212212
defer lockfile.ReleaseTrackedLock(lockPath, lockFile)
213213

214+
//nolint:gosec // G703 - path from trusted app config directory
214215
if err := os.WriteFile(d.updateFilePath, updatedData, 0600); err != nil {
215216
return fmt.Errorf("failed to write updated file: %w", err)
216217
}

pkg/vmcp/health/monitor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (m *Monitor) Start(ctx context.Context) error {
241241
for i := range m.backends {
242242
backend := &m.backends[i] // Capture backend pointer for this iteration
243243

244-
backendCtx, cancel := context.WithCancel(m.ctx)
244+
backendCtx, cancel := context.WithCancel(m.ctx) //nolint:gosec // G118 - cancel stored in m.activeChecks, called during Stop
245245
m.activeChecks[backend.ID] = cancel
246246
m.wg.Add(1)
247247
m.initialCheckWg.Add(1) // Track initial health check
@@ -331,7 +331,7 @@ func (m *Monitor) UpdateBackends(newBackends []vmcp.Backend) {
331331

332332
// Circuit breaker will be lazily initialized on first health check
333333

334-
backendCtx, cancel := context.WithCancel(m.ctx)
334+
backendCtx, cancel := context.WithCancel(m.ctx) //nolint:gosec // G118 - cancel stored in m.activeChecks, called during Stop
335335
m.activeChecks[id] = cancel
336336
m.wg.Add(1)
337337
// Clear the "removed" flag if this backend was previously removed

0 commit comments

Comments
 (0)