refactor: move proxy block message rendering to presentation layer (#364)

* refactor: move proxy block message rendering to presentation layer

* refactor: introduce ui.ProxyPresenter with injected advisory source

* feat: friendly ecosystem labels in proxy block messages

* test: cover ecosystemLabel derivation

* fix: address review feedback on block context assertions and empty reference line
This commit is contained in:
Sahil Bansal
2026-07-10 17:42:26 +05:30
committed by GitHub
parent 2f1c348a06
commit 31e51b10dd
12 changed files with 358 additions and 97 deletions
+11 -8
View File
@@ -126,15 +126,18 @@ func (h *goCooldownHandler) CheckZipDownload(ctx *proxy.RequestContext, baseURL,
pv.SetVersion(version)
audit.LogDependencyCooldown(pv, publishTime, cooldownDays, daysAgo, daysLeft)
message := appendAdvisoryMessage(
fmt.Sprintf("Package blocked by dependency cooldown: GO/%s@%s\n\nPublished %d day(s) ago; cooldown window is %d day(s) (%d remaining).",
module, version, daysAgo, cooldownDays, daysLeft),
pmgconfig.Get().Config.AdvisoryMessage)
return &proxy.InterceptorResponse{
Action: proxy.ActionBlock,
BlockCode: http.StatusForbidden,
BlockMessage: message,
Action: proxy.ActionBlock,
BlockCode: http.StatusForbidden,
BlockReason: proxy.BlockReasonDependencyCooldown,
BlockContext: &proxy.BlockContext{
Ecosystem: packagev1.Ecosystem_ECOSYSTEM_GO,
PackageName: module,
PackageVersion: version,
CooldownDays: cooldownDays,
CooldownDaysAgo: daysAgo,
CooldownDaysLeft: daysLeft,
},
}, true
}