mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
chore(aa): minor cosmetic of the rule interface.
This commit is contained in:
parent
86b2f74a24
commit
191c72fcb6
@ -20,8 +20,8 @@ func (r *All) Kind() Kind {
|
||||
return ALL
|
||||
}
|
||||
|
||||
func (r *All) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *All) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *All) String() string {
|
||||
|
@ -19,8 +19,8 @@ func (p *Hat) Kind() Kind {
|
||||
return HAT
|
||||
}
|
||||
|
||||
func (p *Hat) Constraint() constraint {
|
||||
return blockKind
|
||||
func (p *Hat) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (p *Hat) String() string {
|
||||
|
@ -55,8 +55,8 @@ func (r *Capability) Kind() Kind {
|
||||
return CAPABILITY
|
||||
}
|
||||
|
||||
func (r *Capability) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Capability) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Capability) String() string {
|
||||
|
@ -71,8 +71,8 @@ func (r *ChangeProfile) Kind() Kind {
|
||||
return CHANGEPROFILE
|
||||
}
|
||||
|
||||
func (r *ChangeProfile) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *ChangeProfile) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *ChangeProfile) String() string {
|
||||
|
@ -78,8 +78,8 @@ func (r *Dbus) Kind() Kind {
|
||||
return DBUS
|
||||
}
|
||||
|
||||
func (r *Dbus) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Dbus) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Dbus) String() string {
|
||||
|
@ -107,8 +107,8 @@ func (r *File) Kind() Kind {
|
||||
return FILE
|
||||
}
|
||||
|
||||
func (r *File) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *File) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *File) String() string {
|
||||
@ -213,8 +213,8 @@ func (r *Link) Kind() Kind {
|
||||
return LINK
|
||||
}
|
||||
|
||||
func (r *Link) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Link) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Link) String() string {
|
||||
|
@ -49,8 +49,8 @@ func (r *IOUring) Kind() Kind {
|
||||
return IOURING
|
||||
}
|
||||
|
||||
func (r *IOUring) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *IOUring) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *IOUring) String() string {
|
||||
|
@ -124,8 +124,8 @@ func (r *Mount) Kind() Kind {
|
||||
return MOUNT
|
||||
}
|
||||
|
||||
func (r *Mount) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Mount) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Mount) String() string {
|
||||
@ -206,8 +206,8 @@ func (r *Umount) Kind() Kind {
|
||||
return UMOUNT
|
||||
}
|
||||
|
||||
func (r *Umount) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Umount) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Umount) String() string {
|
||||
@ -285,8 +285,8 @@ func (r *Remount) Kind() Kind {
|
||||
return REMOUNT
|
||||
}
|
||||
|
||||
func (r *Remount) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Remount) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Remount) String() string {
|
||||
|
@ -77,8 +77,8 @@ func (r *Mqueue) Kind() Kind {
|
||||
return MQUEUE
|
||||
}
|
||||
|
||||
func (r *Mqueue) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Mqueue) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Mqueue) String() string {
|
||||
|
@ -103,8 +103,8 @@ func (r *Network) Kind() Kind {
|
||||
return NETWORK
|
||||
}
|
||||
|
||||
func (r *Network) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Network) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Network) String() string {
|
||||
|
@ -188,7 +188,7 @@ func parseParagraph(input string) (Rules, error) {
|
||||
|
||||
res = append(res, rrr...)
|
||||
for _, r := range res {
|
||||
if r.Constraint() == preambleKind {
|
||||
if r.Constraint() == PreambleRule {
|
||||
return nil, fmt.Errorf("Rule not allowed in block: %s", r)
|
||||
}
|
||||
}
|
||||
@ -588,7 +588,7 @@ func (f *AppArmorProfileFile) parsePreamble(preamble string) error {
|
||||
f.Preamble = append(f.Preamble, commaRules...)
|
||||
|
||||
for _, r := range f.Preamble {
|
||||
if r.Constraint() == blockKind {
|
||||
if r.Constraint() == BlockRule {
|
||||
f.Preamble = nil
|
||||
return fmt.Errorf("Rule not allowed in preamble: %s", r)
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ func (r *PivotRoot) Kind() Kind {
|
||||
return PIVOTROOT
|
||||
}
|
||||
|
||||
func (r *PivotRoot) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *PivotRoot) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *PivotRoot) String() string {
|
||||
|
@ -33,8 +33,8 @@ func (r *Comment) Kind() Kind {
|
||||
return COMMENT
|
||||
}
|
||||
|
||||
func (r *Comment) Constraint() constraint {
|
||||
return anyKind
|
||||
func (r *Comment) Constraint() Constraint {
|
||||
return AnyRule
|
||||
}
|
||||
|
||||
func (r *Comment) String() string {
|
||||
@ -85,8 +85,8 @@ func (r *Abi) Kind() Kind {
|
||||
return ABI
|
||||
}
|
||||
|
||||
func (r *Abi) Constraint() constraint {
|
||||
return preambleKind
|
||||
func (r *Abi) Constraint() Constraint {
|
||||
return PreambleRule
|
||||
}
|
||||
|
||||
func (r *Abi) String() string {
|
||||
@ -133,8 +133,8 @@ func (r *Alias) Kind() Kind {
|
||||
return ALIAS
|
||||
}
|
||||
|
||||
func (r *Alias) Constraint() constraint {
|
||||
return preambleKind
|
||||
func (r *Alias) Constraint() Constraint {
|
||||
return PreambleRule
|
||||
}
|
||||
|
||||
func (r *Alias) String() string {
|
||||
@ -200,8 +200,8 @@ func (r *Include) Kind() Kind {
|
||||
return INCLUDE
|
||||
}
|
||||
|
||||
func (r *Include) Constraint() constraint {
|
||||
return anyKind
|
||||
func (r *Include) Constraint() Constraint {
|
||||
return AnyRule
|
||||
}
|
||||
|
||||
func (r *Include) String() string {
|
||||
@ -272,8 +272,8 @@ func (r *Variable) Kind() Kind {
|
||||
return VARIABLE
|
||||
}
|
||||
|
||||
func (r *Variable) Constraint() constraint {
|
||||
return preambleKind
|
||||
func (r *Variable) Constraint() Constraint {
|
||||
return PreambleRule
|
||||
}
|
||||
|
||||
func (r *Variable) String() string {
|
||||
|
@ -73,8 +73,8 @@ func (p *Profile) Kind() Kind {
|
||||
return PROFILE
|
||||
}
|
||||
|
||||
func (p *Profile) Constraint() constraint {
|
||||
return blockKind
|
||||
func (p *Profile) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (p *Profile) String() string {
|
||||
|
@ -51,8 +51,8 @@ func (r *Ptrace) Kind() Kind {
|
||||
return PTRACE
|
||||
}
|
||||
|
||||
func (r *Ptrace) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Ptrace) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Ptrace) String() string {
|
||||
|
@ -55,8 +55,8 @@ func (r *Rlimit) Kind() Kind {
|
||||
return RLIMIT
|
||||
}
|
||||
|
||||
func (r *Rlimit) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Rlimit) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Rlimit) String() string {
|
||||
|
@ -13,12 +13,12 @@ import (
|
||||
|
||||
type requirement map[string][]string
|
||||
|
||||
type constraint uint
|
||||
type Constraint uint
|
||||
|
||||
const (
|
||||
anyKind constraint = iota // The rule can be found in either preamble or profile
|
||||
preambleKind // The rule can only be found in the preamble
|
||||
blockKind // The rule can only be found in a profile
|
||||
AnyRule Constraint = iota // The rule can be found in either preamble or profile
|
||||
PreambleRule // The rule can only be found in the preamble
|
||||
BlockRule // The rule can only be found in a profile
|
||||
)
|
||||
|
||||
// Kind represents an AppArmor rule kind.
|
||||
@ -37,12 +37,12 @@ func (k Kind) Tok() string {
|
||||
|
||||
// Rule generic interface for all AppArmor rules
|
||||
type Rule interface {
|
||||
Kind() Kind
|
||||
Constraint() constraint
|
||||
String() string
|
||||
Validate() error
|
||||
Compare(other Rule) int
|
||||
Merge(other Rule) bool
|
||||
Kind() Kind // Kind of the rule
|
||||
Constraint() Constraint // Where the rule can be found (preamble, profile, any)
|
||||
String() string // Render the rule as a string
|
||||
Validate() error // Validate the rule. Return an error if the rule is invalid
|
||||
Compare(other Rule) int // Compare two rules. Return 0 if they are identical
|
||||
Merge(other Rule) bool // Merge rules of same kind together. Return true if merged
|
||||
}
|
||||
|
||||
type Rules []Rule
|
||||
|
@ -71,8 +71,8 @@ func (r *Signal) Kind() Kind {
|
||||
return SIGNAL
|
||||
}
|
||||
|
||||
func (r *Signal) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Signal) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Signal) String() string {
|
||||
|
@ -74,8 +74,8 @@ func (r *Unix) Kind() Kind {
|
||||
return UNIX
|
||||
}
|
||||
|
||||
func (r *Unix) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Unix) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Unix) String() string {
|
||||
|
@ -46,8 +46,8 @@ func (r *Userns) Kind() Kind {
|
||||
return USERNS
|
||||
}
|
||||
|
||||
func (r *Userns) Constraint() constraint {
|
||||
return blockKind
|
||||
func (r *Userns) Constraint() Constraint {
|
||||
return BlockRule
|
||||
}
|
||||
|
||||
func (r *Userns) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user