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 {
|
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 {
|
func (r *Comment) String() string {
|
||||||
|
|
|
@ -157,20 +157,19 @@ func (r Rules) Merge() Rules {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
kindOfI := r[i].Kind()
|
kindOfI := r[i].Kind()
|
||||||
kindOfJ := r[j].Kind()
|
if kindOfI != r[j].Kind() {
|
||||||
if kindOfI != kindOfJ {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If rules are identical, merge them
|
// If rules are identical, merge them. Ignore comments
|
||||||
if r[i].Compare(r[j]) == 0 {
|
if kindOfI != COMMENT && r[i].Compare(r[j]) == 0 {
|
||||||
r = r.Delete(j)
|
r = r.Delete(j)
|
||||||
j--
|
j--
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// File rule
|
// File rule
|
||||||
if kindOfI == FILE && kindOfJ == FILE {
|
if kindOfI == FILE {
|
||||||
// Merge access
|
// Merge access
|
||||||
fileI := r[i].(*File)
|
fileI := r[i].(*File)
|
||||||
fileJ := r[j].(*File)
|
fileJ := r[j].(*File)
|
||||||
|
|
Loading…
Reference in a new issue