plugin

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 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 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

View Source
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

func Register

func Register(p Plugin)

Register adds a built-in plugin. It panics on an invalid or duplicate name, because both are programming errors caught by any test run.

Types

type Consumer

type Consumer interface {
	Plugin
	Consumes() []string
	RunWith(r *repo.Repo, in []fact.Fact) Result
}

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.

func All

func All() []Plugin

All returns every registered plugin, sorted by name, so the run order and therefore the output never depend on import order.

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).

Jump to

Keyboard shortcuts

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