mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user