feat(aa): add the Kind struct to manage aa rules.

This commit is contained in:
Alexandre Pujol 2024-05-28 18:15:22 +01:00
parent 1333ec2025
commit 3b0944c615
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
23 changed files with 239 additions and 223 deletions

View file

@ -59,7 +59,7 @@ func (f *AppArmorProfileFile) Resolve() error {
}
func (f *AppArmorProfileFile) resolveValues(input string) ([]string, error) {
if !strings.Contains(input, tokVARIABLE) {
if !strings.Contains(input, VARIABLE.Tok()) {
return []string{input}, nil
}
@ -76,7 +76,7 @@ func (f *AppArmorProfileFile) resolveValues(input string) ([]string, error) {
if vrbl.Name == varname {
found = true
for _, v := range vrbl.Values {
if strings.Contains(v, tokVARIABLE+varname+"}") {
if strings.Contains(v, VARIABLE.Tok()+varname+"}") {
return nil, fmt.Errorf("recursive variable found in: %s", varname)
}
newValues := strings.ReplaceAll(input, variable, v)
@ -152,7 +152,7 @@ func (f *AppArmorProfileFile) resolveInclude(include *Include) error {
}
// Remove all includes in iFile
iFile.Preamble = iFile.Preamble.DeleteKind(tokINCLUDE)
iFile.Preamble = iFile.Preamble.DeleteKind(INCLUDE)
// Cache the included file
includeCache[include] = iFile