Documentation
¶
Overview ¶
Package platformiac decides what is a Platform IaC document and finds them.
The rule, in one place: a document is Platform IaC if and only if its apiVersion is vulnetix.com/v1 and its kind is one config-schemas knows. A kind whose schema carries x-vulnetix.validateOnly is validated here and never sent to the config engine. Everything else under .vulnetix/ (SARIF, CycloneDX, OpenVEX, memory, credentials) is not, and is skipped where it sits in a folder.
| Case | Result | |-----------------------------------------------------------|----------------------------| | A folder file with no vulnetix.com/v1 content | skipped; a note with -v | | A vulnetix.com/v1 document whose kind is unknown | error | | A file that mixes documents with other content | error | | A well-known file holding the wrong kind | error | | A file named with -f that is not a document | error |
Index ¶
Constants ¶
const APIVersion = "vulnetix.com/v1"
APIVersion is the only apiVersion a document has.
const ConfigDir = ".vulnetix/config"
ConfigDir is the folder of Platform IaC documents in a repository.
Variables ¶
var WellKnown = []WellKnownFile{
{Path: ".vulnetix/ai-firewall.yaml", Kind: "AiFirewallPolicy"},
{Path: ".vulnetix/license-policy.yaml", Kind: "LicensePolicy"},
{Path: ".vulnetix/license-exceptions.yaml", Kind: "LicenseExceptions"},
}
WellKnown are the files read beside .vulnetix/config.
Functions ¶
func Flatten ¶
Flatten returns the repository form: apiVersion and kind, with spec's fields at the top level. A document already flat passes through.
func IsDocument ¶
IsDocument reports whether v is a Platform IaC document.
func IsKnownKind ¶
IsKnownKind reports whether kind is a Platform IaC kind.
func IsLocal ¶
IsLocal reports whether kind is validated here and never sent to the config engine: its schema carries x-vulnetix.validateOnly, because nothing on the server stores it yet.
func Normalize ¶
Normalize returns the config form: metadata.name defaults to "default", and top-level fields move under spec.
func WellKnownPath ¶
WellKnownPath returns the well-known file for kind, or "".
Types ¶
type Document ¶
type Document struct {
configschemas.Document
Path string
Index int // 1-based position in its file
// WellKnown marks a document read from a WellKnown file.
WellKnown bool
}
Document is one Platform IaC document and where it came from.
func Discover ¶
Discover returns the documents the options name, in a stable order: folder files sorted by path, then the well-known files.
func LoadSingleton ¶
LoadSingleton finds the one document of a singleton kind in a repository: its well-known file, or a document of that kind under .vulnetix/config. Defining it in both is an error, as is defining it twice, because which one wins would be a guess. It returns nil when there is none.
type Options ¶
type Options struct {
// Root is the repository root; .vulnetix/config and the well-known files
// are under it.
Root string
// Files are -f arguments: files, directories ("-" is Stdin). When set,
// only they are read. A named file must hold documents; a named
// directory is read like the config folder.
Files []string
Stdin io.Reader
// IncludeWellKnown reads the WellKnown files too when Files is empty.
IncludeWellKnown bool
// Notes receives one line per skipped file (the -v note). Nil is silent.
Notes io.Writer
}
Options select what Discover reads.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator checks a document against its kind's schema.
func NewValidator ¶
NewValidator compiles every schema once.
type WellKnownFile ¶
WellKnownFile is a singleton document with a fixed path of its own.