Documentation
¶
Overview ¶
Package wasm runs outside plugins: WebAssembly modules, signed with ed25519, loaded through wazero (pure Go, no cgo).
A module runs with WASI preview 1 and nothing else: no preopened directories, no sockets, an empty environment, a fixed clock and a fixed random seed, a memory cap and a time limit. It reads the matching tracked files on stdin and writes facts on stdout. The scanner validates every fact against the published schema and drops what the plugin may not say: kinds outside its manifest, evidence in files it was not sent. See https://cernly.dev/how/wasm-plugins/.
Index ¶
- Constants
- func CheckManifest(m sdk.Manifest) error
- func EncodeKeys(priv ed25519.PrivateKey) (privPEM, pubPEM []byte, err error)
- func KeyID(pub ed25519.PublicKey) string
- func Load(bundlePath string, trust *Trust, lim Limits) (plugin.Plugin, error)
- func LoadDir(dir string, trust *Trust, lim Limits) ([]plugin.Plugin, error)
- func ModuleHash(module []byte) string
- func New(b Bundle, module []byte, trust *Trust, lim Limits) (plugin.Plugin, error)
- func ParsePrivateKey(data []byte) (ed25519.PrivateKey, error)
- func ParsePublicKey(data []byte) (ed25519.PublicKey, error)
- func TestKey() ed25519.PrivateKey
- func TestSigner() string
- type Bundle
- type Key
- type Limits
- type Plugin
- func (p *Plugin) Close() error
- func (p *Plugin) Manifest() sdk.Manifest
- func (p *Plugin) Name() string
- func (p *Plugin) Run(r *repo.Repo) plugin.Result
- func (p *Plugin) SHA256() string
- func (p *Plugin) Signer() string
- func (p *Plugin) Source() string
- func (p *Plugin) Version() string
- func (p *Plugin) Watches(path string) bool
- type Signature
- type Trust
Constants ¶
const BundleSuffix = ".plugin.json"
BundleSuffix ends every signed manifest file.
const TestSignerPrefix = "test-key-not-for-production:"
TestSignerPrefix marks the test key in a scan's plugins list.
Variables ¶
This section is empty.
Functions ¶
func CheckManifest ¶
CheckManifest validates a manifest's fields.
func EncodeKeys ¶
func EncodeKeys(priv ed25519.PrivateKey) (privPEM, pubPEM []byte, err error)
EncodeKeys returns the PEM private and public key of priv.
func Load ¶
Load reads a bundle (<name>.plugin.json) and its module (<name>.wasm), checks the module's hash and the signature, and returns the plugin. A module that is unsigned, signed by a key outside trust or changed after signing does not load.
func LoadDir ¶
LoadDir loads every bundle in dir, sorted by file name. One bad bundle fails the whole load: the operator asked for each of them.
func ParsePrivateKey ¶
func ParsePrivateKey(data []byte) (ed25519.PrivateKey, error)
ParsePrivateKey reads a PEM "PRIVATE KEY" (PKCS #8) holding an ed25519 key, as `openssl genpkey -algorithm ed25519` writes it.
func ParsePublicKey ¶
ParsePublicKey reads a PEM "PUBLIC KEY" (PKIX) holding an ed25519 key, as `openssl pkey -pubout` writes it.
func TestKey ¶
func TestKey() ed25519.PrivateKey
TestKey is a fixed ed25519 key derived from a public seed, for tests and local builds. Anyone can sign with it, so nobody trusts it in production: it is never in the built-in keys, and a scan that trusts it records the signer as TestSigner(), so every report shows it.
Types ¶
type Bundle ¶
type Bundle struct {
Manifest sdk.Manifest `json:"manifest"`
Signature Signature `json:"signature"`
}
Bundle is the signed manifest file next to a module: <name>.plugin.json beside <name>.wasm.
type Limits ¶
type Limits struct {
MemoryPages uint32 // 64 KiB pages; default 16384 (1 GiB)
Timeout time.Duration // default 2 minutes
Input int64 // bytes of file content sent; default 256 MiB
Output int64 // bytes the plugin may write; default 64 MiB
}
Limits bound one plugin run. Exceeding one fails that plugin; the scan goes on.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is one loaded, verified module.
type Signature ¶
type Signature struct {
Key string `json:"key"` // key id, see KeyID
Sig string `json:"sig"` // base64, standard encoding
}
Signature is an ed25519 signature over the manifest, which carries the module's hash.