Skip to content

Commit edcb97d

Browse files
committed
Fix gosec lint warnings in auth package
- G118: make OAuth callback server shutdown synchronous instead of launching a goroutine, so context cancel is deferred in the same scope - G117: suppress false positives on credential marshaling in the credential store (intentional serialization for keyring/file storage)
1 parent c2281ef commit edcb97d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

internal/auth/auth.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,10 @@ func (m *Manager) waitForCallback(ctx context.Context, expectedState, authURL, c
278278
shutdownServer := func() {
279279
shutdownOnce.Do(func() {
280280
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
281-
go func() {
282-
defer cancel()
283-
if shutdownErr := server.Shutdown(shutdownCtx); shutdownErr != nil && !errors.Is(shutdownErr, http.ErrServerClosed) {
284-
fmt.Fprintf(os.Stderr, "warning: callback server shutdown failed: %v\n", shutdownErr)
285-
}
286-
}()
281+
defer cancel()
282+
if shutdownErr := server.Shutdown(shutdownCtx); shutdownErr != nil && !errors.Is(shutdownErr, http.ErrServerClosed) {
283+
fmt.Fprintf(os.Stderr, "warning: callback server shutdown failed: %v\n", shutdownErr)
284+
}
287285
})
288286
}
289287

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)