Problem
querySecurityAdvisories in pkg/cli/deps_security.go makes an outbound HTTP request to the GitHub Security Advisory API but has no context.Context parameter, meaning it cannot be cancelled, timed out by the caller, or participate in context propagation chains.
Evidence
// pkg/cli/deps_security.go:133-148
func querySecurityAdvisories(depVersions map[string]string, verbose bool) ([]SecurityAdvisory, error) {
url := "https://api.github.com/advisories?ecosystem=go&per_page=100"
client := &http.Client{Timeout: 30 * time.Second}
req, err := http.NewRequest(http.MethodGet, url, nil) // ← no context
// ...
resp, err := client.Do(req)
The function uses http.NewRequest instead of http.NewRequestWithContext, so the 30s client-level timeout is the only cancellation mechanism. If the caller receives a context cancellation (e.g., user presses Ctrl+C), this request cannot be interrupted.
Impact
- Severity: Medium
- Affected files:
pkg/cli/deps_security.go
- Risk: Security advisory checks cannot be cancelled mid-flight. In interactive CLI sessions, Ctrl+C will not abort an in-flight API request, degrading UX and potentially causing hangs on slow/unreliable networks.
Recommendation
// Before
func querySecurityAdvisories(depVersions map[string]string, verbose bool) ([]SecurityAdvisory, error) {
req, err := http.NewRequest(http.MethodGet, url, nil)
...
}
// After
func querySecurityAdvisories(ctx context.Context, depVersions map[string]string, verbose bool) ([]SecurityAdvisory, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
...
}
Propagate the context from the calling function and update callers accordingly.
Validation
Estimated Effort: Small
Generated by Sergo — The Serena Go Expert | Run §25417004230
Generated by Sergo - Serena Go Expert · ● 439.7K · ◷
Problem
querySecurityAdvisoriesinpkg/cli/deps_security.gomakes an outbound HTTP request to the GitHub Security Advisory API but has nocontext.Contextparameter, meaning it cannot be cancelled, timed out by the caller, or participate in context propagation chains.Evidence
The function uses
http.NewRequestinstead ofhttp.NewRequestWithContext, so the30sclient-level timeout is the only cancellation mechanism. If the caller receives a context cancellation (e.g., user presses Ctrl+C), this request cannot be interrupted.Impact
pkg/cli/deps_security.goRecommendation
Propagate the context from the calling function and update callers accordingly.
Validation
context.Contextas first parameter toquerySecurityAdvisorieshttp.NewRequestwithhttp.NewRequestWithContextEstimated Effort: Small
Generated by Sergo — The Serena Go Expert | Run §25417004230