manifest

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package manifest loads and merges YAML command registries.

Index

Constants

This section is empty.

Variables

View Source
var SubcommandCommands = map[string]bool{
	"docker":    true,
	"kubectl":   true,
	"svn":       true,
	"systemctl": true,
	"aws":       true,
	"abaqus":    true,
	"apachectl": true,
	"openssl":   true,
}

SubcommandCommands identifies commands that use subcommand-style dispatch (e.g. "docker ps", "kubectl get"). Both the validator and server packages reference this map so they stay in sync.

Functions

func LoadDir

func LoadDir(dir string) (map[string]*Manifest, error)

LoadDir loads manifests from dir (recursive). Skips _-prefixed and non-YAML files.

func LoadEmbedded

func LoadEmbedded() (map[string]*Manifest, error)

func Merge

func Merge(base, overlay map[string]*Manifest) map[string]*Manifest

Merge combines base and overlay; overlay wins on conflict. Does not mutate inputs.

Types

type Flag

type Flag struct {
	Flag          string   `yaml:"flag"`
	Description   string   `yaml:"description"`
	TakesValue    bool     `yaml:"takes_value"`
	PatternValue  bool     `yaml:"pattern_value"`
	AllowedValues []string `yaml:"allowed_values"`
	Deny          bool     `yaml:"deny"`
	Reason        string   `yaml:"reason"`
}

type Manifest

type Manifest struct {
	Name             string   `yaml:"name"`
	Description      string   `yaml:"description"`
	Category         string   `yaml:"category"`
	Timeout          int      `yaml:"timeout"`
	Deny             bool     `yaml:"deny"`
	Reason           string   `yaml:"reason"`
	Flags            []Flag   `yaml:"flags"`
	AllowsPathArgs   bool     `yaml:"allows_path_args"`
	RestrictedPaths  []string `yaml:"restricted_paths"`
	Stdin            bool     `yaml:"stdin"`
	Stdout           bool     `yaml:"stdout"`
	RegexArgPosition *int     `yaml:"regex_arg_position"`
	Shell            string   `yaml:"shell"` // "powershell" or "" (bash)
	RequiresOneOf    []string `yaml:"requires_one_of"`
	// PositionalAllowlist constrains one positional argument to a fixed set of
	// values. Flag validation cannot reach tools that dispatch on a positional
	// word rather than a flag -- jcmd's diagnostic command sits at positional 1
	// (after the pid), and jcmd GC.run, VM.set_flag, and JVMTI.agent_load all
	// change the target JVM. Without this, such a tool is all-or-nothing.
	PositionalAllowlist *PositionalAllowlist `yaml:"positional_allowlist"`
	// AllowsFlagBundling re-enables POSIX-style short-flag bundling for a
	// manifest that declares shell: powershell. Native Windows executables
	// (netstat, tracert, ping) run on a Windows host but use DOS-style bundled
	// switches — `netstat -ano` is -a -n -o — whereas PowerShell cmdlets do not
	// bundle at all and must not be split (`-Match` is one parameter, never
	// -M -a -t -c -h). `shell: powershell` conflates "runs on Windows" with
	// "uses PowerShell parameter conventions"; this field separates them.
	AllowsFlagBundling bool `yaml:"allows_flag_bundling"`
	// contains filtered or unexported fields
}

func (*Manifest) GetFlag

func (m *Manifest) GetFlag(name string) *Flag

type ManifestError

type ManifestError struct {
	Message string
}

func (*ManifestError) Error

func (e *ManifestError) Error() string

type PositionalAllowlist added in v0.9.4

type PositionalAllowlist struct {
	Index  int      `yaml:"index"`
	Values []string `yaml:"values"`
}

PositionalAllowlist restricts the positional argument at Index (0-based, counting only non-flag arguments) to one of Values. Positional arguments at other indexes are unaffected, and an invocation with fewer positionals than Index is not constrained -- the tool itself rejects those.

func (*PositionalAllowlist) Allows added in v0.9.4

func (p *PositionalAllowlist) Allows(value string) bool

Allows reports whether value is permitted at the constrained position. Matching is case-sensitive: jcmd's diagnostic command names are.

Jump to

Keyboard shortcuts

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