pulse

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package pulse manages authentication session lifecycle across a scan. It detects session expiry (redirect to login, 401/403 responses, body changes), re-authenticates using a stored profile, and resumes scanning. This enables long-running thorough scans without manual intervention.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Baseline

type Baseline struct {
	Status    int
	BodyLen   int
	BodyHash  string // simple fingerprint
	Redirects bool
	Location  string
}

Baseline captures the healthy-state response signature.

type Beat

type Beat struct {
	Name     string
	Target   string
	Cookies  []*http.Cookie
	Headers  map[string]string
	Baseline *Baseline // snapshot of a healthy session response
	// contains filtered or unexported fields
}

Beat tracks one session's health and renewal state.

func New

func New(name, target string, cookies []*http.Cookie, headers map[string]string, renewFn func() (*Beat, error)) *Beat

New creates a fresh session Beat. Provide a renew function that can re-authenticate and return a new Beat when the session expires.

func (*Beat) Alive

func (b *Beat) Alive(client *http.Client) bool

Alive returns true if the session is still valid. It sends a probe request and compares against the baseline signature.

func (*Beat) CookieHeader

func (b *Beat) CookieHeader() string

CookieHeader returns the Cookie header value for the session.

func (*Beat) Jar

func (b *Beat) Jar() http.CookieJar

Jar creates an http.CookieJar pre-filled with the session cookies.

func (*Beat) Round

func (b *Beat) Round(client *http.Client, method, rawURL string, body io.Reader) (*http.Response, error)

Round sends a request through the session. If the session is dead, it renews and retries once. Returns the final response.

func (*Beat) Snapshot

func (b *Beat) Snapshot(client *http.Client) error

Snapshot captures the healthy-state baseline. Call after authentication.

func (*Beat) Stay

func (b *Beat) Stay(client *http.Client) (*Beat, error)

Stay ensures the session is alive. If not, it renews via the auth profile and re-snapshots the baseline. Returns the renewed Beat (or same if alive).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL