modules

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, factory func(*Config) Analyzer)

Register adds a response module. Call from init() in your module file so that new modules can be added without editing this file. name is the module name (e.g. "links"); factory receives the module config and returns the Analyzer.

func Run

func Run(ctx context.Context, analyzers []Analyzer, in Input) map[string]map[string]any

Run runs all analyzers and merges their outputs into a single map keyed by module name. Skips errors (failed module does not block others).

Types

type AIAnalyzer

type AIAnalyzer struct {
	Prompt    string
	Provider  string
	Endpoint  string
	Model     string
	MaxTokens int
}

AIAnalyzer sends a truncated response body to an AI backend (openai, ollama, gemini) and returns a short verdict. Uses the shared llm package; provider and API key from config (openai: OPENAI_API_KEY; gemini: GEMINI_API_KEY or GOOGLE_API_KEY; ollama: usually no key). When the API key is missing or the API call fails, the module returns structured error info in Data ("skipped" or "error"/"message") so reports show the reason.

func (AIAnalyzer) Analyze

func (a AIAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (AIAnalyzer) Name

func (AIAnalyzer) Name() string

type Analyzer

type Analyzer interface {
	Name() string
	Analyze(ctx context.Context, in Input) (Output, error)
}

Analyzer is the interface for response-analysis modules (fingerprint, CORS, AI, etc.).

func Enabled

func Enabled(mc *Config) []Analyzer

Enabled returns the list of analyzers for the given module config. Only names in mc.Modules that have been registered are included (unknown names are skipped). Duplicate names appear only once (first occurrence wins).

type AuthAnalyzer

type AuthAnalyzer struct{}

AuthAnalyzer detects auth-related responses: login/logout forms, 401/302 to login, "session expired" / "please log in" text, and cookie-based auth hints (Set-Cookie). Helps prioritize auth flows for testing.

func (AuthAnalyzer) Analyze

func (AuthAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (AuthAnalyzer) Name

func (AuthAnalyzer) Name() string

type CORSAnalyzer

type CORSAnalyzer struct{}

CORSAnalyzer reads CORS-related headers from the response and reports findings. It does not send a separate request with Origin; it only inspects the current response.

func (CORSAnalyzer) Analyze

func (CORSAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (CORSAnalyzer) Name

func (CORSAnalyzer) Name() string

type Config

type Config struct {
	// Modules is the list of enabled response-analysis module names (e.g. fingerprint,cors,ai,urlextract,links).
	Modules []string
	// AIPrompt is the custom prompt for the AI module; placeholders: {{status}}, {{method}}, {{url}}, {{body}}. Empty = default.
	AIPrompt string
	// AIProvider is the AI backend for the ai module: openai | ollama | gemini. Default openai.
	AIProvider string
	// AIEndpoint overrides the API base URL (e.g. http://localhost:11434 for Ollama).
	AIEndpoint string
	// AIModel overrides the model name (default per provider: gpt-4o-mini, llama3.1, gemini-1.5-flash).
	AIModel string
	// AIMaxTokens is the max tokens for the AI module response (0 = use default 150).
	AIMaxTokens int
	// EnqueueModuleUrls is a comma-separated list of module names whose "urls" output is queued for scanning (e.g. urlextract,links).
	EnqueueModuleUrls string
	// ExtractedURLsFile, if set, is the path where all extracted URLs (from any module with "urls" output) are written, one per line.
	ExtractedURLsFile string
}

Config holds all module-related settings. Kept in the modules package so the module system stays separate from the main config; the main config only embeds or references this struct.

type FingerprintAnalyzer

type FingerprintAnalyzer struct{}

FingerprintAnalyzer detects technologies from response headers and body.

func (FingerprintAnalyzer) Analyze

func (FingerprintAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (FingerprintAnalyzer) Name

func (FingerprintAnalyzer) Name() string

type HeadersAnalyzer

type HeadersAnalyzer struct{}

HeadersAnalyzer evaluates security-related response headers and flags missing or weak values. Covers: Content-Security-Policy, X-Frame-Options, Strict-Transport-Security, X-Content-Type-Options, and Set-Cookie (Secure, HttpOnly).

func (HeadersAnalyzer) Analyze

func (HeadersAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (HeadersAnalyzer) Name

func (HeadersAnalyzer) Name() string

type Input

type Input struct {
	URL         string
	Method      string
	StatusCode  int
	Headers     map[string]string
	Body        string
	ContentType string
	Length      int
	Words       int
	Lines       int
}

Input holds the request/response data passed to analyzers. Kept independent of engine so modules do not depend on engine or httpx.

type LinksAnalyzer

type LinksAnalyzer struct{}

LinksAnalyzer extracts links from HTML (href, action, src), resolves them against the request URL, deduplicates and returns them in module output. Output is stored in report.ModuleData["links"]["urls"] ([]string). Use with -enqueue-module-urls links to enqueue discovered URLs into the scan queue.

func (LinksAnalyzer) Analyze

func (LinksAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (LinksAnalyzer) Name

func (LinksAnalyzer) Name() string

type Output

type Output struct {
	Data map[string]any
}

Output is the result of one analyzer. Data is module-specific (e.g. "technologies": ["nginx","php"]).

type SecretsAnalyzer

type SecretsAnalyzer struct{}

SecretsAnalyzer scans response body and headers for common secret/key patterns. Reports potential leaks: AWS keys, JWTs, GitHub/Slack tokens, password= in response, etc. Findings are type labels only; no secret values are stored.

func (SecretsAnalyzer) Analyze

func (SecretsAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (SecretsAnalyzer) Name

func (SecretsAnalyzer) Name() string

type URLExtractAnalyzer

type URLExtractAnalyzer struct{}

URLExtractAnalyzer parses URLs from the response body and Location header, deduplicates and normalizes them, and returns them in module output. Output is stored per result in report.ModuleData["urlextract"]["urls"] ([]string).

func (URLExtractAnalyzer) Analyze

func (URLExtractAnalyzer) Analyze(ctx context.Context, in Input) (Output, error)

func (URLExtractAnalyzer) Name

func (URLExtractAnalyzer) Name() string

Jump to

Keyboard shortcuts

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