policy

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BannedFilePath

func BannedFilePath() (string, error)

BannedFilePath returns ~/.config/autoscan/banned.yaml.

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns ~/.config/autoscan.

func LoadGlobalBanned

func LoadGlobalBanned(path string) ([]string, error)

Types

type CompileConfig

type CompileConfig struct {
	GCC        string   `yaml:"gcc"`
	Flags      []string `yaml:"flags"`
	SourceFile string   `yaml:"source_file,omitempty"`
}

type MultiProcessConfig

type MultiProcessConfig struct {
	Enabled       bool                   `yaml:"enabled"`
	Executables   []ProcessConfig        `yaml:"executables"`
	TestScenarios []MultiProcessScenario `yaml:"test_scenarios,omitempty"`
}

type MultiProcessScenario

type MultiProcessScenario struct {
	Name            string              `yaml:"name"`
	ProcessArgs     map[string][]string `yaml:"process_args,omitempty"`
	ProcessInputs   map[string]string   `yaml:"process_inputs,omitempty"`
	ExpectedExits   map[string]int      `yaml:"expected_exits,omitempty"`
	ExpectedOutputs map[string]string   `yaml:"expected_outputs,omitempty"`
}

type Policy

type Policy struct {
	Name            string        `yaml:"name"`
	Compile         CompileConfig `yaml:"compile"`
	Run             RunConfig     `yaml:"run"`
	LibraryFiles    []string      `yaml:"library_files"` // .c/.o/.h files from ~/.config/autoscan/libraries/
	TestFiles       []string      `yaml:"test_files,omitempty"`
	FilePath        string        `yaml:"-"` // Set after loading
	BannedFunctions []string      `yaml:"-"` // Loaded from global banned.yaml
}

func Discover

func Discover(dir string) ([]*Policy, error)

Discover finds all .yaml/.yml policy files in dir and attaches global banned functions.

func Load

func Load(path string) (*Policy, error)

func LoadWithGlobals

func LoadWithGlobals(path string) (*Policy, error)

func (*Policy) BannedSet

func (p *Policy) BannedSet() map[string]struct{}

func (*Policy) BuildGCCArgs

func (p *Policy) BuildGCCArgs(sourceFiles []string, libraryFiles []string, outputPath string) []string

BuildGCCArgs constructs gcc arguments with proper ordering: compiler flags -> source files -> library files (.c/.o only) -> linker flags (-l*) -> output

type ProcessConfig

type ProcessConfig struct {
	Name         string   `yaml:"name"`
	SourceFile   string   `yaml:"source_file"`
	Args         []string `yaml:"args,omitempty"`
	Input        string   `yaml:"input,omitempty"`
	StartDelayMs int      `yaml:"start_delay_ms,omitempty"`
}

type RunConfig

type RunConfig struct {
	TestCases    []TestCase          `yaml:"test_cases"`
	MultiProcess *MultiProcessConfig `yaml:"multi_process,omitempty"`
}

type TestCase

type TestCase struct {
	Name               string   `yaml:"name"`
	Args               []string `yaml:"args"`
	Input              string   `yaml:"input"`
	ExpectedExit       *int     `yaml:"expected_exit"`
	ExpectedOutputFile string   `yaml:"expected_output_file,omitempty"`
}

Jump to

Keyboard shortcuts

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