Skip to content

Commit 2cfc2e2

Browse files
Merge pull request #1885 from daemon1024/fix-apparmor-fromsource-process-block-clone
fix(apparmor): clone non conflicting proc rules to from source subprofiles
2 parents 3574106 + f16ad02 commit 2cfc2e2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

KubeArmor/enforcer/appArmorProfile.go

+6
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ func (ae *AppArmorEnforcer) GenerateProfileBody(securityPolicies []tp.SecurityPo
433433
ae.Logger.Errf("Error while copying global rules to local profile for %s: %s", source, err.Error())
434434
continue
435435
}
436+
for proc, config := range profile.ProcessPaths {
437+
add := checkIfGlobalRuleToBeAdded(proc, val.ProcessPaths)
438+
if add {
439+
newval.ProcessPaths[proc] = config
440+
}
441+
}
436442
for file, config := range profile.FilePaths {
437443
add := checkIfGlobalRuleToBeAdded(file, val.FilePaths)
438444
if add {

KubeArmor/enforcer/appArmorTemplate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
7979
{{template "file-section" . }}
8080
## == DISPATCHER START == ##
8181
{{- range $source, $value:= $.FromSource}}
82-
{{$source}} px -> {{$v := $.Name | split "."}}{{$v._0}}_{{ $source | replace "/" "" | replace "." "" }},
82+
{{$source}} px -> {{$v := $.Name | split "."}}{{$v._0}}_{{ regexReplaceAllLiteral "[^a-z A-Z 0-9]" $source "" }},
8383
{{- end}}
8484
{{- range $value, $data := .ProcessPaths}}
8585
{{- $suffix := ""}}
@@ -146,7 +146,7 @@ profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
146146
147147
## == FromSource per binary profiles START == ##
148148
{{- range $source, $value := $.FromSource}}
149-
profile {{$v := $.Name | split "."}}{{$v._0}}_{{ $source | replace "/" "" | replace "." "" }} {
149+
profile {{$v := $.Name | split "."}}{{$v._0}}_{{ regexReplaceAllLiteral "[^a-z A-Z 0-9]" $source "" }} {
150150
{{$source}} rix,
151151
{{template "pre-section" $value }}
152152
{{template "file-section" $value}}

0 commit comments

Comments
 (0)