Documentation
¶
Index ¶
- Constants
- Variables
- func ACLJoinPath(parts ...string) string
- func ACLNormPath(path string) string
- func ACLPathSegments(path string) []string
- type ACLCache
- type ACLDepth
- type ACLNode
- func (n *ACLNode) ClearRules()
- func (n *ACLNode) DeleteChild(key string)
- func (n *ACLNode) Equal(other *ACLNode) bool
- func (n *ACLNode) FindBestRule(path string) (*ACLRule, error)
- func (n *ACLNode) GetChild(key string) (*ACLNode, bool)
- func (n *ACLNode) GetChildCount() int
- func (n *ACLNode) GetDepth() ACLDepth
- func (n *ACLNode) GetOwner() string
- func (n *ACLNode) GetRules() []*ACLRule
- func (n *ACLNode) GetTerminal() bool
- func (n *ACLNode) GetVersion() ACLVersion
- func (n *ACLNode) SetChild(key string, child *ACLNode)
- func (n *ACLNode) SetRules(rules []*aclspec.Rule, terminal bool)
- type ACLRule
- type ACLService
- func (s *ACLService) AddRuleSet(ruleSet *aclspec.RuleSet) (ACLVersion, error)
- func (s *ACLService) CanAccess(user *User, file *File, level AccessLevel) error
- func (s *ACLService) GetRule(path string) (*ACLRule, error)
- func (s *ACLService) RemoveRuleSet(path string) bool
- func (s *ACLService) Shutdown(ctx context.Context) error
- func (s *ACLService) Start(ctx context.Context) error
- func (s *ACLService) String() string
- type ACLTree
- func (t *ACLTree) AddRuleSet(ruleset *aclspec.RuleSet) (*ACLNode, error)
- func (t *ACLTree) GetEffectiveRule(path string) (*ACLRule, error)
- func (t *ACLTree) GetNode(path string) *ACLNode
- func (t *ACLTree) LookupNearestNode(normalizedPath string) *ACLNode
- func (t *ACLTree) RemoveRuleSet(path string) bool
- func (t *ACLTree) String() string
- type ACLVersion
- type AccessLevel
- type File
- type Service
- type User
Constants ¶
const ( ACLMaxDepth = 1<<8 - 1 // keep this in sync with the type ACLDepth ACLMaxVersion = 1<<16 - 1 // keep this in sync with the type ACLVersion )
const ACLPathSep = "/"
The ACL system follows the Unix file system hierarchy.
Variables ¶
var ( ErrNoAdminAccess = errors.New("no admin access") ErrNoWriteAccess = errors.New("no write access") ErrNoReadAccess = errors.New("no read access") ErrDirsNotAllowed = errors.New("directories not allowed") ErrSymlinksNotAllowed = errors.New("symlinks not allowed") ErrFileSizeExceeded = errors.New("file size exceeds limits") ErrInvalidAccessLevel = errors.New("invalid access level") )
Functions ¶
func ACLJoinPath ¶
ACLJoinPath joins multiple path segments into a single normalized path string. It uses the ACL path separator and ensures forward slashes are used consistently across different operating systems. Each part can be a sub-path, so the result is normalized using filepath.ToSlash to handle any internal path separators.
func ACLNormPath ¶
ACLNormPath normalizes a file system path for use in ACL operations by: 1. Converting all path separators to forward slashes 2. Cleaning the path (resolving . and ..) 3. Removing leading path separators This ensures consistent path handling across different operating systems and compatibility with glob pattern matching.
func ACLPathSegments ¶
ACLPathSegments splits a file system path into its component segments. It first normalizes the path using ACLNormPath to ensure consistent handling across operating systems, then splits it into segments using the ACL path separator.
Types ¶
type ACLCache ¶
type ACLCache struct {
// contains filtered or unexported fields
}
ACLCache stores the effective ACL rule for a given path.
func (*ACLCache) DeletePrefix ¶
DeletePrefix deletes the effective ACL rule for all paths that match the given prefix.
type ACLNode ¶
type ACLNode struct {
// contains filtered or unexported fields
}
ACLNode represents a node in the ACL tree. Each node corresponds to a part of the path and contains rules for that part.
func NewACLNode ¶
NewACLNode creates a new ACLNode.
func (*ACLNode) ClearRules ¶
func (n *ACLNode) ClearRules()
ClearRules clears the rules for the node.
func (*ACLNode) DeleteChild ¶
DeleteChild deletes the child for the node.
func (*ACLNode) FindBestRule ¶
FindBestRule finds the best matching rule for the given path.
func (*ACLNode) GetChildCount ¶
GetChildCount returns the number of children for the node.
func (*ACLNode) GetTerminal ¶
GetTerminal returns true if the node is a terminal node.
func (*ACLNode) GetVersion ¶
func (n *ACLNode) GetVersion() ACLVersion
GetVersion returns the version of the node.
type ACLRule ¶
type ACLRule struct {
// contains filtered or unexported fields
}
ACLRule represents an access control rule for a file or directory in an ACL Node. It contains the full pattern of the rule, the rule itself, and the node it applies to
func (*ACLRule) CheckAccess ¶
func (r *ACLRule) CheckAccess(user *User, level AccessLevel) error
CheckAccess checks if the user has permission to perform the specified action on the node.
func (*ACLRule) CheckLimits ¶
CheckLimits checks if the file is within the limits specified by the rule.
func (*ACLRule) Version ¶
func (r *ACLRule) Version() ACLVersion
Version returns the version of the rule (inherited from the node)s
type ACLService ¶
type ACLService struct {
// contains filtered or unexported fields
}
ACLService helps to manage and enforce access control rules for file system operations.
func NewACLService ¶
func NewACLService(blob blob.Service) *ACLService
NewACLService creates a new ACL service instance
func (*ACLService) AddRuleSet ¶
func (s *ACLService) AddRuleSet(ruleSet *aclspec.RuleSet) (ACLVersion, error)
AddRuleSet adds or updates a new set of rules to the service.
func (*ACLService) CanAccess ¶
func (s *ACLService) CanAccess(user *User, file *File, level AccessLevel) error
CanAccess checks if a user has the specified access permission for a file.
func (*ACLService) GetRule ¶
func (s *ACLService) GetRule(path string) (*ACLRule, error)
GetRule finds the most specific rule applicable to the given path.
func (*ACLService) RemoveRuleSet ¶
func (s *ACLService) RemoveRuleSet(path string) bool
RemoveRuleSet removes a ruleset at the specified path. Returns true if a ruleset was removed, false otherwise. path must be a dir or dir/syft.pub.yaml
func (*ACLService) Shutdown ¶ added in v0.6.1
func (s *ACLService) Shutdown(ctx context.Context) error
func (*ACLService) String ¶
func (s *ACLService) String() string
String returns a string representation of the ACL service's rule tree.
type ACLTree ¶
type ACLTree struct {
// contains filtered or unexported fields
}
ACLTree stores the ACL rules in a n-ary tree for efficient lookups.
func (*ACLTree) AddRuleSet ¶
Add or update a ruleset in the tree.
func (*ACLTree) GetEffectiveRule ¶
GetEffectiveRule returns the most specific rule applicable to the given path.
func (*ACLTree) LookupNearestNode ¶
LookupNearestNode returns the nearest node in the tree that has associated rules for the given path. It returns nil if no such node is found.
func (*ACLTree) RemoveRuleSet ¶
Removes a ruleset at the specified path
type ACLVersion ¶
type ACLVersion = uint16
ACLVersion is the version of the node. overflow will reset it to 0.
type AccessLevel ¶
type AccessLevel uint8
AccessLevel represents a permission bit flag for different file operations.
const ( AccessRead AccessLevel = 1 << iota AccessCreate AccessWrite AccessAdmin )
Action constants define different types of file permissions
func (AccessLevel) String ¶
func (a AccessLevel) String() string