Skip to content

Commit 11e98dc

Browse files
committed
Fix gosec lint warnings in auth package
- G118: suppress false positive on async shutdown goroutine — cancel is deferred inside the goroutine; the goroutine is required to avoid handler self-deadlock (Shutdown waits for active handlers to return) - G117: suppress false positives on credential marshaling in the credential store (intentional serialization for keyring/file storage)
1 parent c2281ef commit 11e98dc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

internal/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (m *Manager) waitForCallback(ctx context.Context, expectedState, authURL, c
277277

278278
shutdownServer := func() {
279279
shutdownOnce.Do(func() {
280-
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
280+
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) //nolint:gosec // G118: cancel deferred in goroutine; async shutdown required to avoid handler self-deadlock
281281
go func() {
282282
defer cancel()
283283
if shutdownErr := server.Shutdown(shutdownCtx); shutdownErr != nil && !errors.Is(shutdownErr, http.ErrServerClosed) {

internal/auth/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (s *Store) loadFromKeyring(origin string) (*Credentials, error) {
102102
}
103103

104104
func (s *Store) saveToKeyring(origin string, creds *Credentials) error {
105-
data, err := json.Marshal(creds)
105+
data, err := json.Marshal(creds) //nolint:gosec // G117: intentional credential marshaling for storage
106106
if err != nil {
107107
return err
108108
}
@@ -134,7 +134,7 @@ func (s *Store) saveAllToFile(all map[string]*Credentials) error {
134134
return err
135135
}
136136

137-
data, err := json.MarshalIndent(all, "", " ")
137+
data, err := json.MarshalIndent(all, "", " ") //nolint:gosec // G117: intentional credential marshaling for storage
138138
if err != nil {
139139
return err
140140
}

0 commit comments

Comments
 (0)