feat(aa): sort local include at the end of a profile.
This commit is contained in:
parent
bd4e9bb135
commit
26d05f1869
2 changed files with 7 additions and 1 deletions
|
|
@ -128,6 +128,12 @@ func (p *AppArmorProfile) Sort() {
|
||||||
if typeOfI != typeOfJ {
|
if typeOfI != typeOfJ {
|
||||||
valueOfI := typeToValue(typeOfI)
|
valueOfI := typeToValue(typeOfI)
|
||||||
valueOfJ := typeToValue(typeOfJ)
|
valueOfJ := typeToValue(typeOfJ)
|
||||||
|
if typeOfI == reflect.TypeOf((*Include)(nil)) && p.Rules[i].(*Include).IfExists {
|
||||||
|
valueOfI = "include_if_exists"
|
||||||
|
}
|
||||||
|
if typeOfJ == reflect.TypeOf((*Include)(nil)) && p.Rules[j].(*Include).IfExists {
|
||||||
|
valueOfJ = "include_if_exists"
|
||||||
|
}
|
||||||
return ruleWeights[valueOfI] < ruleWeights[valueOfJ]
|
return ruleWeights[valueOfI] < ruleWeights[valueOfJ]
|
||||||
}
|
}
|
||||||
return p.Rules[i].Less(p.Rules[j])
|
return p.Rules[i].Less(p.Rules[j])
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ var (
|
||||||
"iouring",
|
"iouring",
|
||||||
"dbus",
|
"dbus",
|
||||||
"file",
|
"file",
|
||||||
"include_local",
|
"include_if_exists",
|
||||||
}
|
}
|
||||||
ruleWeights = map[string]int{}
|
ruleWeights = map[string]int{}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue