Documentation
¶
Overview ¶
Package plugin defines the contract every extractor plugin follows: read tracked files, return facts with evidence, nothing else. No network, no clock, no randomness, no environment variables.
Plugins are stack adapters: each translates one stack's files into the shared fact vocabulary in package fact. Built-in plugins register themselves from an init function; see https://cernly.dev/how/plugins/ for WebAssembly plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NamePattern = regexp.MustCompile(`^[a-z][a-z0-9-]{1,40}$`)
NamePattern is the rule every plugin name follows; the scan schema uses the same pattern.
Functions ¶
Types ¶
type Consumer ¶
Consumer is a phase-2 plugin: a tool adapter that runs after every plain plugin and gets their facts of the kinds it consumes, such as the stacks an invocation reader found. Phase-2 plugins never see each other's output.
type Origin ¶
type Origin interface {
Source() string // fact.SourceWasm
SHA256() string // hex hash of the module
Signer() string // key id that signed it
}
Origin is implemented by plugins that are not compiled in: WebAssembly modules. The scan records where each came from.
type Plugin ¶
type Plugin interface {
Name() string
Version() string
// Watches reports whether a change to this repo-relative path can change
// the plugin's output. Core uses it to choose the files a WebAssembly plugin
// receives and the files kubernetes reads; a caller may use it to skip a
// plugin when only other files changed.
Watches(path string) bool
Run(r *repo.Repo) Result
}
Plugin reads the tracked files of a repo and returns facts with evidence. Run must be deterministic and must not touch the network, the clock or the environment.
type Result ¶
type Result struct {
Facts []fact.Fact
Errors []fact.LocationError
// Failed marks a run that produced nothing usable (a WebAssembly module
// that trapped, ran out of time or wrote invalid output); Errors says why.
Failed bool
}
Result is what one plugin run returns: its facts, the errors it hit and whether the run failed as a whole.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package plugintest is the golden-test harness for WebAssembly plugin authors.
|
Package plugintest is the golden-test harness for WebAssembly plugin authors. |
|
Package sdk is what a WebAssembly plugin imports: the wire format between the scanner and a plugin, and a Main that reads the input from stdin and writes the output to stdout.
|
Package sdk is what a WebAssembly plugin imports: the wire format between the scanner and a plugin, and a Main that reads the input from stdin and writes the output to stdout. |
|
Package wasm runs outside plugins: WebAssembly modules, signed with ed25519, loaded through wazero (pure Go, no cgo).
|
Package wasm runs outside plugins: WebAssembly modules, signed with ed25519, loaded through wazero (pure Go, no cgo). |