From ad81c39e31be631f55bdb7cfaacb2e97f7f7fc1e Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 5 May 2024 14:10:14 +0100 Subject: [PATCH] feat(aa): remove now unsused rule.Sort method. --- pkg/aa/rules.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/pkg/aa/rules.go b/pkg/aa/rules.go index c6c5446b..4cfdda3b 100644 --- a/pkg/aa/rules.go +++ b/pkg/aa/rules.go @@ -4,11 +4,6 @@ package aa -import ( - "reflect" - "sort" -) - const ( tokALLOW = "allow" tokAUDIT = "audit" @@ -37,24 +32,3 @@ type Rules []Rule func (r Rules) String() string { return renderTemplate("rules", r) } - -// Sort the rules in a profile. -// Follow: https://apparmor.pujol.io/development/guidelines/#guidelines -func (r Rules) Sort() { - sort.Slice(r, func(i, j int) bool { - typeOfI := reflect.TypeOf(r[i]) - typeOfJ := reflect.TypeOf(r[j]) - if typeOfI != typeOfJ { - valueOfI := typeToValue(typeOfI) - valueOfJ := typeToValue(typeOfJ) - if typeOfI == reflect.TypeOf((*Include)(nil)) && r[i].(*Include).IfExists { - valueOfI = "include_if_exists" - } - if typeOfJ == reflect.TypeOf((*Include)(nil)) && r[j].(*Include).IfExists { - valueOfJ = "include_if_exists" - } - return ruleWeights[valueOfI] < ruleWeights[valueOfJ] - } - return r[i].Less(r[j]) - }) -}