2024-05-25 23:17:32 +02:00
|
|
|
// 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 (
|
2024-05-28 19:15:22 +02:00
|
|
|
HAT Kind = "hat"
|
2024-05-25 23:17:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Hat represents a single AppArmor hat.
|
|
|
|
type Hat struct {
|
2024-06-25 20:50:27 +02:00
|
|
|
Base
|
2024-05-25 23:17:32 +02:00
|
|
|
Name string
|
|
|
|
Rules Rules
|
|
|
|
}
|
|
|
|
|
2024-06-25 20:56:36 +02:00
|
|
|
func (p *Hat) Kind() Kind {
|
|
|
|
return HAT
|
2024-05-25 23:36:39 +02:00
|
|
|
}
|
|
|
|
|
2024-06-27 19:45:32 +02:00
|
|
|
func (p *Hat) Constraint() Constraint {
|
|
|
|
return BlockRule
|
2024-05-25 23:17:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Hat) String() string {
|
|
|
|
return renderTemplate(p.Kind(), p)
|
|
|
|
}
|
|
|
|
|
2024-06-25 20:56:36 +02:00
|
|
|
func (r *Hat) Validate() error {
|
|
|
|
return nil
|
2024-05-25 23:17:32 +02:00
|
|
|
}
|
|
|
|
|
2024-06-25 20:56:36 +02:00
|
|
|
func (r *Hat) Compare(other Rule) int {
|
|
|
|
o, _ := other.(*Hat)
|
|
|
|
return compare(r.Name, o.Name)
|
2024-05-25 23:17:32 +02:00
|
|
|
}
|
2024-06-25 21:10:12 +02:00
|
|
|
|
|
|
|
func (r *Hat) Merge(other Rule) bool {
|
|
|
|
return false // Never merge hat blocks
|
|
|
|
}
|
2024-06-29 23:27:39 +02:00
|
|
|
|
|
|
|
func (r *Hat) Lengths() []int {
|
|
|
|
return []int{} // No len for hat
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Hat) setPaddings(max []int) {} // No paddings for hat
|