Documentation
¶
Overview ¶
Package fact defines the scan output (schema cernly.scan/v1) and its canonical, deterministic encoding.
Index ¶
- Constants
- func Canonical(v any) ([]byte, error)
- func SortedSet(m map[string]bool) []any
- func SortedValues[V any](m map[string]V) []any
- func Strings(xs []string) []any
- type Commit
- type Declared
- type DeclaredDomain
- type DeclaredGate
- type DeclaredStack
- type DeclaredTag
- type Evidence
- type Exclusion
- type Extractor
- type Fact
- type LocationError
- type PluginRun
- type Scan
- type ScanConfig
Constants ¶
const ( KindDependency = "dependency" KindService = "service" KindDatastore = "datastore" KindEnvVar = "env_var" KindOutboundHost = "outbound_host" KindDBTable = "db_table" KindDBColumn = "db_column" KindSecretFound = "secret_found" KindImageBuild = "image_build" KindImageRecipe = "image_recipe" KindStack = "stack" KindAgentConfig = "agent_config" KindRoute = "route" // Ownership: who owns the repo, as the repo says it. KindOwner = "owner" KindCatalogEntity = "catalog_entity" // Tests: test files per module, and the commands // that run them. KindTestSuite = "test_suite" KindTestRun = "test_run" // Size: files and lines per folder, and imports between // the repo's own packages. KindSourceSize = "source_size" KindImport = "import" // The HTTP endpoints the code registers, and the host-level auth policies that cover them. KindEndpoint = "endpoint" KindAuthPolicy = "auth_policy" )
Kinds allowed by scan.v1.schema.json.
const ( SourceBuiltin = "builtin" SourceWasm = "wasm" )
Plugin sources. Built-in plugins are compiled into the binary; wasm plugins are loaded from signed modules and carry their hash and signer.
const SchemaID = "cernly.scan/v1"
SchemaID names the facts format in every scan.
Variables ¶
This section is empty.
Functions ¶
func Canonical ¶
Canonical encodes v as canonical JSON: object keys sorted, no insignificant whitespace, no HTML escaping. Values in this schema are strings, booleans, integers, arrays and objects only, which keeps this equivalent to RFC 8785.
func SortedValues ¶
SortedValues is the values of a map as an attr list, in key order.
Types ¶
type Declared ¶
type Declared struct {
OwnDomains []DeclaredDomain `json:"own_domains,omitempty"`
Stacks []DeclaredStack `json:"stacks,omitempty"`
// Gate levels per rule, from the repo and the operator. Both sides are
// kept: the gate takes the stricter one.
Gate []DeclaredGate `json:"gate,omitempty"`
// Tags on the repo: key:value labels; per key the operator's entry
// replaces the repo's.
Tags []DeclaredTag `json:"tags,omitempty"`
}
Declared holds what a person declared about the repo: never a fact, always shown as declared with who said it. The rules read it.
type DeclaredDomain ¶
type DeclaredGate ¶
type DeclaredGate struct {
Rule string `json:"rule"`
Level string `json:"level"` // off, warn or block
By string `json:"by"`
Line int `json:"line,omitempty"`
// Licences is the licence ids licence_not_allowed watches.
Licences []string `json:"licences,omitempty"`
}
DeclaredGate is one gate rule's level as one side declared it.
type DeclaredStack ¶
type DeclaredTag ¶
type DeclaredTag struct {
Key string `json:"key"`
Value string `json:"value"`
By string `json:"by"`
Line int `json:"line,omitempty"`
}
DeclaredTag is one key:value label on the repo.
type Fact ¶
type Fact struct {
Kind string `json:"kind"`
Key string `json:"key"`
Attrs map[string]any `json:"attrs"`
Plugin string `json:"plugin"`
Evidence []Evidence `json:"evidence"`
}
type LocationError ¶
type Scan ¶
type Scan struct {
Schema string `json:"schema"`
Repo string `json:"repo"`
Commit Commit `json:"commit"`
Extractor Extractor `json:"extractor"`
Config *ScanConfig `json:"config,omitempty"`
Plugins []PluginRun `json:"plugins"`
Facts []Fact `json:"facts"`
}
func (*Scan) Normalise ¶
Normalise merges facts with the same (kind, key) and sorts everything into the canonical order. Two facts with the same key but different attributes are an extractor bug: the first one (in plugin output order) wins and the clash is reported, so the output never silently depends on map iteration order.
type ScanConfig ¶
type ScanConfig struct {
File string `json:"file,omitempty"`
IgnoredByOperator bool `json:"ignored_by_operator,omitempty"`
Exclusions []Exclusion `json:"exclusions,omitempty"`
Include []string `json:"include,omitempty"`
Declared *Declared `json:"declared,omitempty"`
Errors []LocationError `json:"errors,omitempty"`
}
ScanConfig records what was excluded from a scan and who decided it: the repo's hint file or the operator. Present only when either said something.