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:
@@ -62,6 +62,11 @@ type ProxyConfig struct {
|
||||
// Interceptors
|
||||
Interceptors []Interceptor
|
||||
|
||||
// BlockMessageRenderer composes the response body for blocked requests
|
||||
// from the interceptor's structured block decision. nil falls back to
|
||||
// the generic block message.
|
||||
BlockMessageRenderer func(BlockReason, *BlockContext) string
|
||||
|
||||
// Other configuration
|
||||
EnableMITM bool
|
||||
RequestTimeout time.Duration
|
||||
@@ -561,6 +566,9 @@ func (ps *proxyServer) registerHandlers() {
|
||||
}
|
||||
|
||||
message := resp.BlockMessage
|
||||
if message == "" && ps.config.BlockMessageRenderer != nil {
|
||||
message = ps.config.BlockMessageRenderer(resp.BlockReason, resp.BlockContext)
|
||||
}
|
||||
if message == "" {
|
||||
message = "Blocked by proxy interceptor"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user