apparmor.d/pkg/aa/blocks.go
Alexandre Pujol 4cbacc186c
feat(aa): rule interface: replace less & equal by the compare method.
- set a new alphabet order to sort AARE based string.
- unify compare function for all rules
- handle some special sort order, eg: base include
2024-06-19 18:34:58 +01:00

38 lines
611 B
Go

// apparmor.d - Full set of apparmor profiles
// Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
// SPDX-License-Identifier: GPL-2.0-only
package aa
const (
HAT Kind = "hat"
)
// Hat represents a single AppArmor hat.
type Hat struct {
RuleBase
Name string
Rules Rules
}
func (r *Hat) Validate() error {
return nil
}
func (r *Hat) Compare(other Rule) int {
o, _ := other.(*Hat)
return compare(r.Name, o.Name)
}
func (p *Hat) String() string {
return renderTemplate(p.Kind(), p)
}
func (p *Hat) Constraint() constraint {
return blockKind
}
func (p *Hat) Kind() Kind {
return HAT
}