mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 00:48:10 +01:00
feat(aa): ensure comments are neither merged nor sorted.
This commit is contained in:
parent
58c07e5ea5
commit
d6424cb950
2 changed files with 5 additions and 6 deletions
|
@ -34,7 +34,7 @@ func (r *Comment) Validate() error {
|
|||
}
|
||||
|
||||
func (r *Comment) Compare(other Rule) int {
|
||||
return 0
|
||||
return 0 // Comments are always equal to each other as they are not compared
|
||||
}
|
||||
|
||||
func (r *Comment) String() string {
|
||||
|
|
|
@ -157,20 +157,19 @@ func (r Rules) Merge() Rules {
|
|||
continue
|
||||
}
|
||||
kindOfI := r[i].Kind()
|
||||
kindOfJ := r[j].Kind()
|
||||
if kindOfI != kindOfJ {
|
||||
if kindOfI != r[j].Kind() {
|
||||
continue
|
||||
}
|
||||
|
||||
// If rules are identical, merge them
|
||||
if r[i].Compare(r[j]) == 0 {
|
||||
// If rules are identical, merge them. Ignore comments
|
||||
if kindOfI != COMMENT && r[i].Compare(r[j]) == 0 {
|
||||
r = r.Delete(j)
|
||||
j--
|
||||
continue
|
||||
}
|
||||
|
||||
// File rule
|
||||
if kindOfI == FILE && kindOfJ == FILE {
|
||||
if kindOfI == FILE {
|
||||
// Merge access
|
||||
fileI := r[i].(*File)
|
||||
fileJ := r[j].(*File)
|
||||
|
|
Loading…
Reference in a new issue