Documentation
¶
Overview ¶
Package intercept implements the request hold queue (Burp-style intercept) and the request-side match-&-replace engine. The proxy calls Hold on every request; when intercept is enabled the calling goroutine blocks until the UI forwards (optionally with edits) or drops it.
Index ¶
- Variables
- type Decision
- type Engine
- func (e *Engine) ApplyResponseRules(h http.Header, body []byte) (http.Header, []byte)
- func (e *Engine) ApplyRules(req *http.Request) error
- func (e *Engine) Drop(id int64) error
- func (e *Engine) DropResponse(id int64) error
- func (e *Engine) Enabled() bool
- func (e *Engine) Forward(id int64, editedRaw []byte) error
- func (e *Engine) ForwardResponse(id int64, editedRaw []byte) error
- func (e *Engine) HasResponseRules() bool
- func (e *Engine) Hold(flow *store.Flow, req *http.Request, raw []byte) Decision
- func (e *Engine) HoldResponse(flow *store.Flow, raw []byte) ResponseDecision
- func (e *Engine) InterceptFilter() (bool, string, string)
- func (e *Engine) Queue() []Held
- func (e *Engine) ResponseEnabled() bool
- func (e *Engine) ResponseQueue() []HeldResponse
- func (e *Engine) SetEnabled(on bool)
- func (e *Engine) SetInterceptFilter(enabled bool, target, pattern string) error
- func (e *Engine) SetNotifier(fn func())
- func (e *Engine) SetResponseEnabled(on bool)
- func (e *Engine) SetRules(rules []store.Rule) error
- type Held
- type HeldResponse
- type ResponseDecision
Constants ¶
This section is empty.
Variables ¶
var ErrNotHeld = errors.New("intercept: request not held")
ErrNotHeld is returned when resolving an id that is not (or no longer) held.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Drop bool
Edited bool
Held bool // the request actually entered the hold queue (vs. filtered straight through)
Request *http.Request
}
Decision is the outcome of a hold: forward the (possibly edited) request, or drop it.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns the hold queue and the compiled rule set.
func (*Engine) ApplyResponseRules ¶
ApplyResponseRules applies enabled response-side rules to a response's headers and body, returning the transformed pair.
func (*Engine) ApplyRules ¶
ApplyRules mutates req per the enabled request-side rules, in order.
func (*Engine) DropResponse ¶
DropResponse drops a held response (client receives nothing).
func (*Engine) Forward ¶
Forward releases a held request. If editedRaw is non-empty it replaces the request with the re-parsed edited version (forwarding target preserved).
func (*Engine) ForwardResponse ¶
ForwardResponse releases a held response (optionally replacing its raw bytes).
func (*Engine) HasResponseRules ¶
HasResponseRules reports whether any enabled response-side rule exists.
func (*Engine) Hold ¶
Hold submits a request to the gate. If intercept is off it returns immediately with a forward decision; otherwise it blocks until the UI resolves it. raw is the editable origin-form snapshot shown in the UI.
func (*Engine) HoldResponse ¶
func (e *Engine) HoldResponse(flow *store.Flow, raw []byte) ResponseDecision
HoldResponse blocks (when response interception is on) until the UI forwards or drops the response. raw is the editable response snapshot.
func (*Engine) InterceptFilter ¶ added in v0.3.0
InterceptFilter returns the current filter (enabled, target, pattern).
func (*Engine) ResponseEnabled ¶
ResponseEnabled reports whether response interception is on.
func (*Engine) ResponseQueue ¶
func (e *Engine) ResponseQueue() []HeldResponse
ResponseQueue returns a snapshot of held responses in arrival order.
func (*Engine) SetEnabled ¶
SetEnabled toggles intercept. Turning it off forwards everything currently held.
func (*Engine) SetInterceptFilter ¶ added in v0.3.0
SetInterceptFilter configures the conditional-intercept filter. When enabled with a valid pattern, only requests whose chosen field matches the regex are held. An invalid regex is returned as an error and the filter is left unchanged.
func (*Engine) SetNotifier ¶
func (e *Engine) SetNotifier(fn func())
SetNotifier registers a callback invoked whenever the queue changes.
func (*Engine) SetResponseEnabled ¶
SetResponseEnabled toggles response interception. Turning it off forwards everything currently held (unchanged).
type Held ¶
type Held struct {
ID int64
Flow *store.Flow
Raw []byte // origin-form raw request bytes, editable before forwarding
}
Held is a UI-facing snapshot of a request waiting in the hold queue.
type HeldResponse ¶
HeldResponse is a UI-facing snapshot of a response waiting in the hold queue.
type ResponseDecision ¶
type ResponseDecision struct {
Drop bool
Edited bool
Raw []byte // the raw response bytes to send to the client
}
ResponseDecision is the outcome of holding a response: forward the (possibly edited) raw response, or drop it.