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) 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)
- func (n *ACLNode) String() string
- type ACLRequest
- type ACLRule
- func (r *ACLRule) CheckAccess(req *ACLRequest) error
- func (r *ACLRule) CheckLimits(req *ACLRequest) error
- func (r *ACLRule) Clone() *ACLRule
- func (r *ACLRule) Compile(user *User) *ACLRule
- func (r *ACLRule) GetAccess() *aclspec.Access
- func (r *ACLRule) GetLimits() *aclspec.Limits
- func (r *ACLRule) Match(path string, user *User) (bool, error)
- func (r *ACLRule) Owner() string
- func (r *ACLRule) String() string
- func (r *ACLRule) Version() ACLVersion
- type ACLService
- func (s *ACLService) AddRuleSet(ruleSet *aclspec.RuleSet) (ACLVersion, error)
- func (s *ACLService) CanAccess(req *ACLRequest) 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) GetCompiledRule(req *ACLRequest) (*ACLRule, error)
- func (t *ACLTree) GetNearestNode(path string) *ACLNode
- func (t *ACLTree) GetNode(path string) *ACLNode
- func (t *ACLTree) RemoveRuleSet(path string) bool
- func (t *ACLTree) String() string
- type ACLVersion
- type AccessLevel
- type ExactMatcher
- type File
- type GlobMatcher
- type MatchContext
- type Matcher
- type MatcherType
- type Service
- type TemplateMatcher
- type User
Constants ¶
const ( ACLMaxDepth = 1<<8 - 1 ACLMaxVersion = 1<<16 - 1 )
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 access level for a given path and user.
func (*ACLCache) Clear ¶ added in v0.8.4
func (c *ACLCache) Clear()
Clear removes all entries from the cache
func (*ACLCache) DeletePrefix ¶
DeletePrefix deletes the access level for all paths that match the given prefix.
func (*ACLCache) Get ¶
func (c *ACLCache) Get(req *ACLRequest) (bool, bool)
Get returns the access level for the given path and user.
func (*ACLCache) Set ¶
func (c *ACLCache) Set(req *ACLRequest, canAccess bool)
Set sets the access level for the given path and user.
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) 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 ACLRequest ¶ added in v0.8.4
type ACLRequest struct {
Path string
Level AccessLevel
User *User
File *File
}
func NewRequest ¶ added in v0.8.4
func NewRequest(path string, user *User, level AccessLevel) *ACLRequest
func NewRequestWithFile ¶ added in v0.8.4
func NewRequestWithFile(path string, user *User, level AccessLevel, file *File) *ACLRequest
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 todo decouple this from aclspec.Rule
func NewACLRule ¶ added in v0.8.4
NewACLRule creates a new ACLRule with template compilation
func (*ACLRule) CheckAccess ¶
func (r *ACLRule) CheckAccess(req *ACLRequest) error
CheckAccess checks if the user has permission to perform the specified action on the node.
func (*ACLRule) CheckLimits ¶
func (r *ACLRule) CheckLimits(req *ACLRequest) error
CheckLimits checks if the file is within the limits specified by the rule.
func (*ACLRule) Compile ¶ added in v0.8.4
Compile creates a user-specific copy of a rule with USER tokens resolved
func (*ACLRule) Match ¶ added in v0.8.4
Match checks if this rule matches the given path for the given user
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(req *ACLRequest) error
CanAccess checks if a user has the specified access permission for a file.
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) GetCompiledRule ¶ added in v0.8.4
func (t *ACLTree) GetCompiledRule(req *ACLRequest) (*ACLRule, error)
func (*ACLTree) GetNearestNode ¶ added in v0.8.4
GetNearestNode 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
type ExactMatcher ¶ added in v0.8.4
type ExactMatcher struct {
Value string
}
func (*ExactMatcher) Match ¶ added in v0.8.4
func (e *ExactMatcher) Match(path string, ctx MatchContext) (bool, error)
func (*ExactMatcher) Type ¶ added in v0.8.4
func (e *ExactMatcher) Type() MatcherType
type GlobMatcher ¶ added in v0.8.4
type GlobMatcher struct {
// contains filtered or unexported fields
}
func (*GlobMatcher) Match ¶ added in v0.8.4
func (g *GlobMatcher) Match(path string, ctx MatchContext) (bool, error)
func (*GlobMatcher) Type ¶ added in v0.8.4
func (g *GlobMatcher) Type() MatcherType
type MatchContext ¶ added in v0.8.4
type MatchContext any // i don't know what all we'll need, so just putting it as any
type Matcher ¶ added in v0.8.4
type Matcher interface {
Match(path string, ctx MatchContext) (bool, error)
Type() MatcherType
}
type MatcherType ¶ added in v0.8.4
type MatcherType int
const ( MatcherTypeExact MatcherType = iota MatcherTypeGlob MatcherTypeTemplate )
type Service ¶ added in v0.6.1
type Service interface {
AddRuleSet(ruleSet *aclspec.RuleSet) (ACLVersion, error)
RemoveRuleSet(path string) bool
CanAccess(ctx *ACLRequest) error
}
type TemplateMatcher ¶ added in v0.8.4
type TemplateMatcher struct {
// contains filtered or unexported fields
}
func (*TemplateMatcher) Match ¶ added in v0.8.4
func (t *TemplateMatcher) Match(path string, ctx MatchContext) (bool, error)
func (*TemplateMatcher) Type ¶ added in v0.8.4
func (t *TemplateMatcher) Type() MatcherType