chore(aa): minor cosmetic of the rule interface.

This commit is contained in:
Alexandre Pujol 2024-06-27 18:45:32 +01:00
parent 86b2f74a24
commit 191c72fcb6
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
20 changed files with 62 additions and 62 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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)
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {