feat(aa-log): add AppArmorProfile.String using a template.

This commit is contained in:
Alexandre Pujol 2023-08-17 23:11:11 +01:00
parent 4f40cb6d78
commit 574891d445
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 341 additions and 0 deletions

View file

@ -7,8 +7,30 @@ package aa
import (
_ "embed"
"strings"
"text/template"
)
const indentation = " "
//go:embed template.j2
var tmplFileAppArmorProfile string
var tmplFunctionMap = template.FuncMap{
"indent": indent,
"overindent": indentDbus,
}
var tmplAppArmorProfile = template.Must(template.New("profile").
Funcs(tmplFunctionMap).Parse(tmplFileAppArmorProfile))
func indent(s string) string {
return indentation + s
}
func indentDbus(s string) string {
return indentation + " " + s
}
// TODO: Should be a map of slice, not exhausive yet
var maskToAccess = map[string]string{
"a": "w",