behavioral

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package behavioral compares what an MCP capability says it does against what its handler actually reaches, using only the graph the source pass already built: no LLM, just a fixed vocabulary matched against the description and a fixed catalogue of filesystem/network/process/credential calls matched against everything the handler statically reaches. Reachability is co-occurrence evidence, not a traced dataflow proof.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CredentialLikeName added in v1.3.0

func CredentialLikeName(name string) bool

CredentialLikeName reports whether an environment variable or setting name looks like it holds a credential (KEY, SECRET, TOKEN, PASSWORD, ...), by the vocabulary the credential checks use

func Declared added in v1.2.0

func Declared(description string) (filesystem, network, process bool)

Declared reports which capability categories a description affirmatively claims, with the same vocabulary and negation handling the mismatch checks use. Other analyzers use it to tell a tool's stated purpose from an injection into it.

Types

type Analyzer

type Analyzer struct{}

func (*Analyzer) Analyze

func (*Analyzer) AppliesTo

func (*Analyzer) AppliesTo(kind model.TargetKind) bool

func (*Analyzer) Describe

func (*Analyzer) Describe() analyzer.Description

func (*Analyzer) Name

func (*Analyzer) Name() string

type CredentialCall added in v1.3.0

type CredentialCall struct {
	Call string `json:"call"`
	// Address is fixed, configured, caller or unsettled
	Address string `json:"address"`
	To      string `json:"to,omitempty"`
}

CredentialCall is one network call that carries a credential. To is the host, the name of the constant or setting that starts the address, or what the address is when neither is known.

type Effects added in v1.3.0

type Effects struct {
	WritesFiles  []string `json:"writes_files,omitempty"`
	RunsPrograms []string `json:"runs_programs,omitempty"`
	SendsData    []string `json:"sends_data,omitempty"`
	// ReadsText: the handler reaches a request or reads a file, so what it returns may carry text
	// from outside the server: "network", "files"
	ReadsText []string `json:"reads_text,omitempty"`
}

Effects is what the calls a handler reaches change or send, read from the names of the calls. Every list holds "file:line callee" and is empty when the names show nothing of the kind.

func EffectsOf added in v1.3.0

func EffectsOf(g *graph.Graph, handler graph.SymbolID) Effects

EffectsOf reads what the calls handler reaches change or send. The call graph follows only project functions, so a library's own effects do not show.

func (Effects) Empty added in v1.3.0

func (e Effects) Empty() bool

Empty reports whether the effects show nothing

type Egress added in v1.3.0

type Egress struct {
	// FixedHosts are literal hosts in the code: in a call's address, or in the constant it starts with
	FixedHosts []string `json:"fixed_hosts,omitempty"`
	// Configured are the constants and settings that start an address the code does not spell out
	Configured []string `json:"configured_addresses,omitempty"`
	// CallerAddressed are the calls whose address the caller's data starts
	CallerAddressed []string `json:"caller_addressed,omitempty"`
	// Unsettled counts the network calls whose address the names do not settle
	Unsettled int `json:"unsettled,omitempty"`
	// CredentialNames are the environment variables the handler reads that are named like a credential
	CredentialNames []string `json:"credential_names,omitempty"`
	// CredentialCalls are the network calls that carry a credential, and where each is addressed
	CredentialCalls []CredentialCall `json:"credential_calls,omitempty"`
	// CredentialInResult: the handler's own result carries a credential
	CredentialInResult bool `json:"credential_in_result,omitempty"`
}

Egress says where the network calls a handler reaches are addressed, and where the credentials it reads go. It reads names along the handler's calls (walkFlow), not a traced flow: an address is the caller's when the caller's data starts it, the server's own when a literal host, a constant or a setting does, and unsettled when the names do not say.

func EgressOf added in v1.3.0

func EgressOf(g *graph.Graph, handler graph.SymbolID, envVars []string) *Egress

EgressOf reads the network calls handler reaches and the credentials they carry; nil when there are none. envVars are the environment variables the handler reads.

func (*Egress) LoopbackHosts added in v1.3.0

func (e *Egress) LoopbackHosts() []string

LoopbackHosts are the fixed hosts of an egress that name this machine: work a handler hands to the server's own backend or daemon, which the scanner does not follow

type HandlerBehavior added in v1.2.0

type HandlerBehavior struct {
	Network           bool     `json:"network"`
	Filesystem        bool     `json:"filesystem"`
	Process           bool     `json:"process"`
	Credentials       bool     `json:"credentials"`
	SensitivePaths    []string `json:"sensitive_paths,omitempty"`
	EnvVars           []string `json:"env_vars,omitempty"`
	URLs              []string `json:"urls,omitempty"`
	ReachedFunctions  int      `json:"reached_functions"`
	ReachesUnresolved bool     `json:"reaches_unresolved_calls"`
	// Egress is where the handler's network calls and credentials go; nil when it reaches none.
	// Only the inventory fills it (EgressOf): the analyzers do not read it.
	Egress *Egress `json:"egress,omitempty"`
}

HandlerBehavior is what a capability's handler can reach through the call graph: the categories the behavioral checks compare against the description, and the concrete evidence behind them

func Behavior added in v1.2.0

func Behavior(g *graph.Graph, handler graph.SymbolID) HandlerBehavior

Behavior summarizes what handler can reach, with the same reachability and catalogue the mismatch checks use

Jump to

Keyboard shortcuts

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