Documentation
¶
Overview ¶
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.
A plugin gets the tracked, non-excluded files that match its manifest's watches, plus, for a phase-2 plugin, the phase-1 facts it consumes. It returns facts in the shared vocabulary (schema/scan.v1.schema.json) whose evidence points only at files or facts it was sent. It has no file system, no network, no environment and a fixed clock, so it cannot do anything else.
The package uses only the standard library and the fact package, so it builds for GOOS=wasip1 GOARCH=wasm with the Go toolchain and with TinyGo. See https://cernly.dev/how/wasm-plugins/.
Index ¶
Constants ¶
const API = 1
API is the plugin protocol version this package speaks.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
Main reads the input, calls run and writes its output. A plugin's main function is one line: sdk.Main(run).
Types ¶
type Input ¶
type Input struct {
PluginAPI int `json:"plugin_api"`
Repo Repo `json:"repo"`
Facts []fact.Fact `json:"facts"`
}
Input is what the plugin reads on stdin.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
PluginAPI int `json:"plugin_api"`
Watches []string `json:"watches"`
Emits []string `json:"emits"`
Consumes []string `json:"consumes,omitempty"`
// Tools narrows consumed stack facts to these tools.
Tools []string `json:"tools,omitempty"`
// SHA256 is the hex hash of the .wasm module this manifest belongs to.
SHA256 string `json:"sha256"`
}
Manifest describes a plugin; it is signed together with the module's hash (schema/plugin.v1.schema.json, "manifest").