feat(api): report upstream hosts in /api/system

Each registry upstream shows its scheme and host only. The endpoint
drops credentials, paths and query strings from the configured URL.
This commit is contained in:
2026-11-24 00:44:26 +00:00
parent 6ddc382d5b
commit a511544d7a
2 changed files with 35 additions and 0 deletions
+15
View File
@@ -2,6 +2,7 @@ package app
import (
"context"
"net/url"
"time"
"github.com/gofiber/fiber/v3"
@@ -35,6 +36,15 @@ func scannerSwitches(s config.ScannersConfig) []scannerSwitch {
}
}
// originOnly keeps scheme and host, so credentials, paths and queries in an upstream URL never leave the server.
func originOnly(raw string) string {
u, err := url.Parse(raw)
if err != nil || u.Host == "" {
return ""
}
return u.Scheme + "://" + u.Host
}
func seconds(d time.Duration) int64 { return int64(d / time.Second) }
// systemScanners joins the configured scanners with their cached health; disabled scanners report no health.
@@ -99,6 +109,11 @@ func (a *App) handleSystem(c fiber.Ctx) error {
"on_access": sec.RescanOnAccess,
},
},
"upstreams": fiber.Map{
"go": originOnly(a.config.Handlers.Go.UpstreamProxy),
"npm": originOnly(a.config.Handlers.NPM.UpstreamRegistry),
"pypi": originOnly(a.config.Handlers.PyPI.UpstreamURL),
},
"cache": fiber.Map{
"max_size": a.config.Cache.MaxSizeBytes,
"idle_ttl": seconds(a.config.Cache.IdleTTL),