Skip to content

Commit

Permalink
run presets test suite on bpflsm only
Browse files Browse the repository at this point in the history
Signed-off-by: rksharma95 <[email protected]>
  • Loading branch information
rksharma95 committed Oct 18, 2024
1 parent 653e453 commit 0dee72e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 78 deletions.
72 changes: 0 additions & 72 deletions KubeArmor/presets/base/containers.go

This file was deleted.

2 changes: 1 addition & 1 deletion KubeArmor/presets/filelessexec/preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (p *Preset) TraceEvents() {
log.Type = "MatchedPolicy"
}

log.Operation = "File"
log.Operation = "Process"

if event.Retval >= 0 {
log.Result = "Passed"
Expand Down
3 changes: 3 additions & 0 deletions tests/k8s_env/presets/presets_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 Authors of KubeArmor

package presets_test

import (
Expand Down
16 changes: 13 additions & 3 deletions tests/k8s_env/presets/presets_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 Authors of KubeArmor

package presets

import (
"fmt"
"strings"
"time"

"github.com/kubearmor/KubeArmor/protobuf"
Expand Down Expand Up @@ -37,7 +41,7 @@ var _ = Describe("Presets", func() {
var fp string

BeforeEach(func() {
fp = getfilelessPod("fileless-", nil)
fp = getfilelessPod("fileless-", []string{"kubearmor-policy: enabled"})
})

AfterEach(func() {
Expand All @@ -50,12 +54,15 @@ var _ = Describe("Presets", func() {

Describe("Policy Apply", func() {
It("can audit fileless execution", func() {
if !strings.Contains(K8sRuntimeEnforcer(), "bpf") {
Skip("fileless execution preset requires bpf-lsm")
}
// Apply policy
err := K8sApplyFile("res/ksp-preset-audit-fileless.yaml")
Expect(err).To(BeNil())

// Start Kubearmor Logs
err = KarmorLogStart("policy", "presets", "File", fp)
err = KarmorLogStart("policy", "presets", "Process", fp)
Expect(err).To(BeNil())

// wait for policy creation
Expand All @@ -80,12 +87,15 @@ var _ = Describe("Presets", func() {
})

It("can block fileless execution", func() {
if !strings.Contains(K8sRuntimeEnforcer(), "bpf") {
Skip("fileless execution preset requires bpf-lsm")
}
// Apply policy
err := K8sApplyFile("res/ksp-preset-block-fileless.yaml")
Expect(err).To(BeNil())

// Start Kubearmor Logs
err = KarmorLogStart("policy", "presets", "File", fp)
err = KarmorLogStart("policy", "presets", "Process", fp)
Expect(err).To(BeNil())

// wait for policy creation
Expand Down
3 changes: 1 addition & 2 deletions tests/k8s_env/presets/res/python-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ spec:
spec:
containers:
- name: fileless
image: rksharma95/python:fileless
command: ["tail", "-f", "/dev/null"]
image: kubearmor/ubuntu-w-utils:0.1

0 comments on commit 0dee72e

Please sign in to comment.