Skip to content

Commit 3ec353c

Browse files
authored
Merge pull request #24 from git-pkgs/fix-error-disclosure
Stop leaking internal error details to clients
2 parents 68a8af5 + 3d6ebc9 commit 3ec353c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

internal/server/api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (h *APIHandler) HandleGetPackage(w http.ResponseWriter, r *http.Request) {
161161

162162
info, err := h.enrichment.EnrichPackage(r.Context(), ecosystem, name)
163163
if err != nil {
164-
http.Error(w, err.Error(), http.StatusInternalServerError)
164+
http.Error(w, "failed to enrich package", http.StatusInternalServerError)
165165
return
166166
}
167167

@@ -209,7 +209,7 @@ func (h *APIHandler) HandleGetVersion(w http.ResponseWriter, r *http.Request) {
209209

210210
result, err := h.enrichment.EnrichFull(r.Context(), ecosystem, name, version)
211211
if err != nil {
212-
http.Error(w, err.Error(), http.StatusInternalServerError)
212+
http.Error(w, "failed to enrich version", http.StatusInternalServerError)
213213
return
214214
}
215215

@@ -291,7 +291,7 @@ func (h *APIHandler) HandleGetVulns(w http.ResponseWriter, r *http.Request) {
291291

292292
vulns, err := h.enrichment.CheckVulnerabilities(r.Context(), ecosystem, name, version)
293293
if err != nil {
294-
http.Error(w, err.Error(), http.StatusInternalServerError)
294+
http.Error(w, "failed to check vulnerabilities", http.StatusInternalServerError)
295295
return
296296
}
297297

@@ -485,7 +485,7 @@ func (h *APIHandler) HandleSearch(w http.ResponseWriter, r *http.Request) {
485485
// Search in database
486486
results, err := h.db.SearchPackages(query, ecosystem, limit, (page-1)*limit)
487487
if err != nil {
488-
http.Error(w, err.Error(), http.StatusInternalServerError)
488+
http.Error(w, "search failed", http.StatusInternalServerError)
489489
return
490490
}
491491

@@ -592,7 +592,7 @@ func (h *APIHandler) HandlePackagesList(w http.ResponseWriter, r *http.Request)
592592

593593
packages, err := h.db.ListCachedPackages(ecosystem, sortBy, limit, (page-1)*limit)
594594
if err != nil {
595-
http.Error(w, err.Error(), http.StatusInternalServerError)
595+
http.Error(w, "failed to list packages", http.StatusInternalServerError)
596596
return
597597
}
598598

internal/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
686686
// Check database connectivity
687687
if _, err := s.db.SchemaVersion(); err != nil {
688688
w.WriteHeader(http.StatusServiceUnavailable)
689-
_, _ = fmt.Fprintf(w, "database error: %v", err)
689+
_, _ = fmt.Fprint(w, "database error")
690690
return
691691
}
692692

0 commit comments

Comments
 (0)