Documentation
¶
Overview ¶
Package store persists flow metadata in SQLite and bodies on disk.
Index ¶
- Constants
- type APIKey
- type BodyWriter
- type Flow
- type FlowFilter
- type Issue
- type Rule
- type SavedView
- type ScopeRule
- type Store
- func (s *Store) ClearIssues() error
- func (s *Store) Close() error
- func (s *Store) CreateAPIKey(label string) (token string, key APIKey, err error)
- func (s *Store) CreateRule(r *Rule) (int64, error)
- func (s *Store) CreateScopeRule(r *ScopeRule) (int64, error)
- func (s *Store) CreateView(v *SavedView) (int64, error)
- func (s *Store) DeleteAPIKey(id int64) error
- func (s *Store) DeleteRule(id int64) error
- func (s *Store) DeleteScopeRule(id int64) error
- func (s *Store) DeleteView(id int64) error
- func (s *Store) GetFlow(id int64) (*Flow, error)
- func (s *Store) GetSetting(key string) (string, bool, error)
- func (s *Store) InsertFlow(f *Flow) (int64, error)
- func (s *Store) ListAPIKeys() ([]APIKey, error)
- func (s *Store) ListIssues() ([]Issue, error)
- func (s *Store) ListRules() ([]Rule, error)
- func (s *Store) ListScopeRules() ([]ScopeRule, error)
- func (s *Store) ListViews() ([]SavedView, error)
- func (s *Store) NewBodyWriter() (*BodyWriter, error)
- func (s *Store) OpenBody(sum string) (io.ReadCloser, error)
- func (s *Store) QueryFlows(limit int) ([]*Flow, error)
- func (s *Store) QueryFlowsFilter(f FlowFilter) ([]*Flow, error)
- func (s *Store) QueryWSFrames(flowID int64, limit int) ([]*WSFrame, error)
- func (s *Store) SaveIssues(issues []Issue) error
- func (s *Store) SaveWSFrame(f *WSFrame) error
- func (s *Store) SetSetting(key, value string) error
- func (s *Store) UpdateRule(r *Rule) error
- func (s *Store) UpdateScopeRule(r *ScopeRule) error
- func (s *Store) VerifyAPIKey(token string) (bool, error)
- type WSFrame
Constants ¶
const ( FlagIntercepted int64 = 1 << iota // request passed through the intercept hold queue FlagEdited // request was edited before forwarding FlagDropped // request was dropped by the user (not forwarded) FlagCaptureError // a body could not be captured; forwarding still succeeded FlagTLSFailed // TLS interception failed for this flow FlagWebSocket // a protocol-upgrade (WebSocket) handshake, tunneled transparently FlagRepeater // a request sent from the Repeater module FlagIntruder // a request sent from the Intruder module FlagImported // a flow imported from a HAR file (not proxied) FlagActiveScan // a probe sent by the active scanner )
Flow flag bits, OR'd into Flow.Flags.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
ID int64 `json:"id"`
Label string `json:"label"`
Prefix string `json:"prefix"`
Created int64 `json:"created"` // unix millis
}
APIKey is metadata for an issued control-API key. The secret token itself is never stored — only its SHA-256 hash and a short identifying prefix.
type BodyWriter ¶
type BodyWriter struct {
// contains filtered or unexported fields
}
BodyWriter streams bytes to a temp file while hashing them, then commits the file to a content-addressed path on Finalize. Safe for bounded memory: bytes are never buffered whole.
func (*BodyWriter) Abort ¶
func (w *BodyWriter) Abort()
Abort discards an in-progress body (e.g. on error).
type Flow ¶
type Flow struct {
ID int64
TS time.Time
Method string
Scheme string
Host string
Port int
Path string
HTTPVersion string
Status int
ReqHeaders map[string][]string
ResHeaders map[string][]string
ReqBodyHash string
ResBodyHash string
ReqLen int64
ResLen int64
Mime string
DurationMs int64
ClientAddr string
Error string
Flags int64
}
Flow is one captured request/response exchange. Bodies are referenced by content hash, never embedded.
type FlowFilter ¶
type FlowFilter struct {
Limit int // max rows (defaults to 200 when <= 0)
BeforeID int64 // cursor: only rows with id < BeforeID (0 = newest)
Method string // exact method match
Host string // case-insensitive substring of host
Search string // case-insensitive substring of path
Scheme string // exact scheme match ("http"/"https")
StatusClass int // 1..5 → 1xx..5xx; 0 = any
RequireFlags int64 // only rows with any of these flag bits set
ExcludeFlags int64 // only rows with none of these flag bits set
}
FlowFilter selects and pages flows. Zero-valued fields are ignored.
type Issue ¶
type Issue struct {
ID int64 `json:"id"`
FlowID int64 `json:"flowId"`
Severity string `json:"severity"`
Title string `json:"title"`
Target string `json:"target"`
Detail string `json:"detail"`
Evidence string `json:"evidence"`
Fix string `json:"fix"`
}
Issue is one scanner finding. Severity is "High" | "Medium" | "Low" | "Info".
type Rule ¶
Rule is one ordered match-&-replace transform. Type is one of "req-header", "req-body" (response-side types are reserved for a later slice).
type SavedView ¶
SavedView is a named history filter (its Data is an opaque JSON blob the UI understands: scheme/method/status/search/host/inScope).
type ScopeRule ¶
type ScopeRule struct {
ID int64 `json:"id"`
Ord int `json:"ord"`
Enabled bool `json:"enabled"`
Action string `json:"action"`
Host string `json:"host"`
Path string `json:"path"`
Scheme string `json:"scheme"`
Port int `json:"port"`
}
ScopeRule is one target-scope rule. Action is "include" | "exclude". Empty host/path/scheme and port 0 mean "any" for that field.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns the SQLite database and the on-disk body directory.
func (*Store) CreateAPIKey ¶
CreateAPIKey mints a new key, returning the full token (shown to the user once) and its stored metadata. The token is "ick_" + 48 hex chars.
func (*Store) CreateRule ¶
CreateRule inserts a rule and returns its id.
func (*Store) CreateScopeRule ¶
CreateScopeRule inserts a scope rule and returns its id.
func (*Store) CreateView ¶
CreateView stores a named view and returns its id.
func (*Store) DeleteAPIKey ¶
DeleteAPIKey revokes a key by id.
func (*Store) DeleteRule ¶
DeleteRule removes a rule by id.
func (*Store) DeleteScopeRule ¶
DeleteScopeRule removes a scope rule by id.
func (*Store) DeleteView ¶
DeleteView removes a view by id.
func (*Store) GetSetting ¶
GetSetting returns the value and whether it was present.
func (*Store) InsertFlow ¶
InsertFlow stores a new flow and sets f.ID to the assigned row id.
func (*Store) ListAPIKeys ¶
ListAPIKeys returns all key metadata (never the token or hash), newest first.
func (*Store) ListIssues ¶
ListIssues returns all issues ordered by severity (High→Info) then id.
func (*Store) ListScopeRules ¶
ListScopeRules returns scope rules ordered by ord then id.
func (*Store) NewBodyWriter ¶
func (s *Store) NewBodyWriter() (*BodyWriter, error)
NewBodyWriter starts a new body capture.
func (*Store) OpenBody ¶
func (s *Store) OpenBody(sum string) (io.ReadCloser, error)
OpenBody returns a reader for the body with the given hash. An empty hash yields an empty reader (no body).
func (*Store) QueryFlows ¶
QueryFlows returns up to limit flows, newest first.
func (*Store) QueryFlowsFilter ¶
func (s *Store) QueryFlowsFilter(f FlowFilter) ([]*Flow, error)
QueryFlowsFilter returns flows matching f, newest first. Filtering and paging are pushed down to SQL so large histories never materialize in memory.
func (*Store) QueryWSFrames ¶
QueryWSFrames returns up to limit frames for a flow, oldest first.
func (*Store) SaveIssues ¶
SaveIssues upserts issues, deduplicated by (title, target).
func (*Store) SaveWSFrame ¶
SaveWSFrame records a captured frame.
func (*Store) SetSetting ¶
SetSetting upserts a key/value setting.
func (*Store) UpdateRule ¶
UpdateRule overwrites the rule identified by r.ID.
func (*Store) UpdateScopeRule ¶
UpdateScopeRule overwrites the rule identified by r.ID.
type WSFrame ¶
type WSFrame struct {
ID int64 `json:"id"`
FlowID int64 `json:"flowId"`
TS time.Time `json:"-"`
Dir string `json:"dir"`
Opcode int `json:"opcode"`
Length int64 `json:"length"`
Preview string `json:"preview"`
}
WSFrame is one captured WebSocket frame. Dir is "send" (client→server) or "recv" (server→client). Preview holds a bounded prefix of the (unmasked) payload; Length is the full frame payload length.