pathpolicy

package
v0.3.0-r9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomDirectoriesPolicies = NewPathPolicies(map[string]PathPolicy{
	"/":    {Deny: true},
	"/etc": {},
})

CustomDirectoriesPolicies is a set of default policies for custom directories

View Source
var CustomFilesPolicies = NewPathPolicies(map[string]PathPolicy{
	"/":           {Deny: true},
	"/etc":        {},
	"/root":       {},
	"/etc/fstab":  {Deny: true},
	"/etc/shadow": {Deny: true},
	"/etc/passwd": {Deny: true},
	"/etc/group":  {Deny: true},
})

CustomFilesPolicies is a set of default policies for custom files

View Source
var MountpointPolicies = NewPathPolicies(map[string]PathPolicy{
	"/":     {Exact: true},
	"/boot": {Exact: true},
	"/var":  {},
	"/opt":  {},
	"/srv":  {},
	"/usr":  {},
	"/app":  {},
	"/data": {},
	"/home": {},
	"/tmp":  {},
})

MountpointPolicies is a set of default mountpoint policies used for filesystem customizations

Functions

This section is empty.

Types

type PathPolicies

type PathPolicies = PathTrie

func NewPathPolicies

func NewPathPolicies(entries map[string]PathPolicy) *PathPolicies

Create a new PathPolicies trie from a map of path to PathPolicy

func (*PathPolicies) Check

func (pol *PathPolicies) Check(fsPath string) error

Check a given path against the PathPolicies

type PathPolicy

type PathPolicy struct {
	Deny  bool // explicitly do not allow this entry
	Exact bool // require and exact match, no subdirs
}

type PathTrie

type PathTrie struct {
	Name    []string
	Paths   []*PathTrie
	Payload interface{}
}

func NewPathTrieFromMap

func NewPathTrieFromMap(entries map[string]interface{}) *PathTrie

Construct a new trie from a map of paths to their payloads. Returns the root node of the trie.

func (*PathTrie) Lookup

func (root *PathTrie) Lookup(path string) (*PathTrie, []string)

Lookup returns the node that is the prefix of path and the unmatched path segment. Must be called on the root trie node.

Jump to

Keyboard shortcuts

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