mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-30 23:05:11 +01:00
chore: minor cosmetic.
This commit is contained in:
parent
cad0b936e5
commit
6810fe679e
1 changed files with 6 additions and 5 deletions
|
@ -182,7 +182,8 @@ func (p *AppArmorProfile) MergeRules() {
|
|||
// Format the profile for better readability before printing it
|
||||
// Follow: https://apparmor.pujol.io/development/guidelines/#the-file-block
|
||||
func (p *AppArmorProfile) Format() {
|
||||
hasOwnedRule := false
|
||||
const prefixOwner = " "
|
||||
hasOwnerRule := false
|
||||
for i := len(p.Rules) - 1; i > 0; i-- {
|
||||
j := i - 1
|
||||
typeOfI := reflect.TypeOf(p.Rules[i])
|
||||
|
@ -195,14 +196,14 @@ func (p *AppArmorProfile) Format() {
|
|||
|
||||
// Add prefix before rule path to align with other rule
|
||||
if p.Rules[i].(*File).Owner {
|
||||
hasOwnedRule = true
|
||||
} else if hasOwnedRule {
|
||||
p.Rules[i].(*File).Prefix = " "
|
||||
hasOwnerRule = true
|
||||
} else if hasOwnerRule {
|
||||
p.Rules[i].(*File).Prefix = prefixOwner
|
||||
}
|
||||
|
||||
if letterI != letterJ {
|
||||
// Add a new empty line between Files rule of different type
|
||||
hasOwnedRule = false
|
||||
hasOwnerRule = false
|
||||
p.Rules = append(p.Rules[:i], append([]ApparmorRule{&Rule{}}, p.Rules[i:]...)...)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue