staticCookieJar in cookies_txt.go is a slice type with Set(), Delete(), Get(), and GetAll() methods that read and mutate the slice without synchronization.
If a CookieJar is shared between goroutines (e.g., multiple pages in the same browser context), concurrent Set() + Get() calls would cause data races.
Current risk
Low — the current codebase doesn't appear to use the cookie jar concurrently. But as a public interface (CookieJar), callers might use it in concurrent contexts.
Fix
Add a sync.RWMutex to staticCookieJar, or document that it's not safe for concurrent use. A wrapper type SafeCookieJar could be provided for thread-safe use.
**Parent:** #3
## Description
`staticCookieJar` in `cookies_txt.go` is a slice type with `Set()`, `Delete()`, `Get()`, and `GetAll()` methods that read and mutate the slice without synchronization.
If a `CookieJar` is shared between goroutines (e.g., multiple pages in the same browser context), concurrent `Set()` + `Get()` calls would cause data races.
## Current risk
Low — the current codebase doesn't appear to use the cookie jar concurrently. But as a public interface (`CookieJar`), callers might use it in concurrent contexts.
## Fix
Add a `sync.RWMutex` to `staticCookieJar`, or document that it's not safe for concurrent use. A wrapper type `SafeCookieJar` could be provided for thread-safe use.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #3
Description
staticCookieJarincookies_txt.gois a slice type withSet(),Delete(),Get(), andGetAll()methods that read and mutate the slice without synchronization.If a
CookieJaris shared between goroutines (e.g., multiple pages in the same browser context), concurrentSet()+Get()calls would cause data races.Current risk
Low — the current codebase doesn't appear to use the cookie jar concurrently. But as a public interface (
CookieJar), callers might use it in concurrent contexts.Fix
Add a
sync.RWMutextostaticCookieJar, or document that it's not safe for concurrent use. A wrapper typeSafeCookieJarcould be provided for thread-safe use.Starting work on this. Will wrap
staticCookieJarin a struct withsync.RWMutexfor thread safety.Work finished —
staticCookieJaris now a struct withsync.RWMutex. All reads useRLock, all writes useLock. Merged in PR #42.