From 6810fe679ee085923bb6f4080c61dedfb5eb2416 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Wed, 3 Apr 2024 21:06:28 +0100 Subject: [PATCH] chore: minor cosmetic. --- pkg/aa/profile.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/aa/profile.go b/pkg/aa/profile.go index b0f55995..b5aa2d7b 100644 --- a/pkg/aa/profile.go +++ b/pkg/aa/profile.go @@ -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:]...)...) } }