platformiac

package
v4.24.21 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 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 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

View Source
const APIVersion = "vulnetix.com/v1"

APIVersion is the only apiVersion a document has.

View Source
const ConfigDir = ".vulnetix/config"

ConfigDir is the folder of Platform IaC documents in a repository.

Variables

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

func Flatten(v any) any

Flatten returns the repository form: apiVersion and kind, with spec's fields at the top level. A document already flat passes through.

func IsDocument

func IsDocument(v any) bool

IsDocument reports whether v is a Platform IaC document.

func IsKnownKind

func IsKnownKind(kind string) bool

IsKnownKind reports whether kind is a Platform IaC kind.

func IsLocal

func IsLocal(kind string) bool

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 Kinds

func Kinds() []string

Kinds lists every kind config-schemas releases, sorted.

func Normalize

func Normalize(v any) any

Normalize returns the config form: metadata.name defaults to "default", and top-level fields move under spec.

func WellKnownPath

func WellKnownPath(kind string) string

WellKnownPath returns the well-known file for kind, or "".

Types

type Class

type Class int

Class is what a decoded value is.

const (
	// NotDocument has no vulnetix.com/v1 apiVersion.
	NotDocument Class = iota
	// IsDoc is a vulnetix.com/v1 document of a known kind.
	IsDoc
	// UnknownKind is a vulnetix.com/v1 document of a kind nobody knows.
	UnknownKind
)

func Classify

func Classify(v any) (Class, string)

Classify sorts one decoded value.

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

func Discover(o Options) ([]Document, error)

Discover returns the documents the options name, in a stable order: folder files sorted by path, then the well-known files.

func LoadSingleton

func LoadSingleton(root, kind string) (*Document, error)

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.

func (*Document) FlatYAML

func (d *Document) FlatYAML() ([]byte, error)

FlatYAML is the document in its repository form as YAML, for the parsers that read the repository files (license.ParsePolicy, ParseExceptions).

func (*Document) JSON

func (d *Document) JSON() ([]byte, error)

JSON is the document as JSON.

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

func NewValidator() (*Validator, error)

NewValidator compiles every schema once.

func (*Validator) Validate

func (v *Validator) Validate(d configschemas.Document) error

Validate checks one document.

type WellKnownFile

type WellKnownFile struct {
	Path string
	Kind string
}

WellKnownFile is a singleton document with a fixed path of its own.

Jump to

Keyboard shortcuts

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