Skip to content

Commit 01521b2

Browse files
authored
fix(audit): record integrity check event for d8-virtualization serviceaccounts (#1637)
Do not ignore integrity checks audit events from d8-virtualizatin serviceaccounts. Integrity check event was not recorded. Critical for CSE. Signed-off-by: Ivan Mikheykin <[email protected]>
1 parent 75a9923 commit 01521b2

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

images/virtualization-artifact/pkg/audit/events/integrity/integrity_check_vm.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"strings"
2222

23+
authnv1 "k8s.io/api/authentication/v1"
2324
"k8s.io/apiserver/pkg/apis/audit"
2425

2526
"github.com/deckhouse/virtualization-controller/pkg/audit/events"
@@ -55,8 +56,7 @@ func (m *IntegrityCheckVM) IsMatched() bool {
5556
return false
5657
}
5758

58-
if strings.HasPrefix(m.event.User.Username, "system:") &&
59-
!strings.HasPrefix(m.event.User.Username, "system:serviceaccount:d8-service-accounts") {
59+
if m.ignoreForSystemUsers(m.event.User) {
6060
return false
6161
}
6262

@@ -92,3 +92,16 @@ func (m *IntegrityCheckVM) Fill() error {
9292

9393
return nil
9494
}
95+
96+
func (m *IntegrityCheckVM) ignoreForSystemUsers(userInfo authnv1.UserInfo) bool {
97+
// Do not ignore for d8 service accounts.
98+
if strings.HasPrefix(userInfo.Username, "system:serviceaccount:d8-service-accounts") {
99+
return false
100+
}
101+
// Do not ignore for virtualization controller.
102+
if strings.HasPrefix(userInfo.Username, "system:serviceaccount:d8-virtualization") {
103+
return false
104+
}
105+
// Ignore for all other system users, not ignore for non-system users.
106+
return strings.HasPrefix(m.event.User.Username, "system:")
107+
}

images/virtualization-artifact/werf.inc.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ shell:
4040
- |
4141
echo "Build virtualization-controller binary"
4242
{{- $_ := set $ "ProjectName" (list $.ImageName "virtualization-controller" | join "/") }}
43-
43+
4444
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-controller" }}
4545
go build -tags {{ .MODULE_EDITION }} -v -a -o /out/virtualization-controller ./cmd/virtualization-controller
4646
{{- else }}
4747
{{- $buildCommand := printf "go build -ldflags=\"-s -w\" -tags %s -v -a -o /out/virtualization-controller ./cmd/virtualization-controller" .MODULE_EDITION -}}
4848
{{- include "image-build.build" (set $ "BuildCommand" $buildCommand) | nindent 4 }}
4949
{{- end }}
50-
50+
5151
- |
5252
echo "Build virtualization-api binary"
5353
{{- $_ := set $ "ProjectName" (list $.ImageName "virtualization-api" | join "/") }}
54-
54+
5555
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-api" }}
5656
go build -v -o /out/virtualization-api ./cmd/virtualization-api
5757
{{- else }}

0 commit comments

Comments
 (0)