Skip to content

Commit

Permalink
Add license headers and fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Navin Chandra <[email protected]>
  • Loading branch information
navin772 committed Jul 27, 2024
1 parent fe236c5 commit e2fc0c2
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 44 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ name: ci-coverage

on:
push:
branches:
- "main"
branches: [main]
paths:
- "KubeArmor/**"
- ".github/workflows/ci-coverage.yaml"
- "tests/**"
pull_request:
branches:
- "main"
branches: [main]
paths:
- "KubeArmor/**"
- ".github/workflows/ci-coverage.yaml"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci-test-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: ci-test-docker

on:
push:
branches:
- "main"
- "non-k8s-hsp-test"
branches: [main]
paths:
- "KubeArmor/**"
- ".github/workflows/ci-test-docker.yaml"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-test-ginkgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ci-test-ginkgo

on:
push:
branches: [main, lfx-pretask-submission, non-k8s-hsp-test]
branches: [main]
paths:
- "KubeArmor/**"
- "tests/**"
Expand All @@ -11,7 +11,7 @@ on:
- "pkg/KubeArmorOperator/**"
- "deployments/helm/**"
pull_request:
branches: [main, lfx-pretask-submission]
branches: [main]
paths:
- "KubeArmor/**"
- "tests/**"
Expand All @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-latest]
os: [ubuntu-20.04]
runtime: ["containerd", "crio"]
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: ci-test-systemd

on:
push:
branches: [main, non-k8s-hsp-test]
branches: [main]
paths:
- "KubeArmor/**"
- "tests/**"
- "protobuf/**"
- ".github/workflows/ci-test-systemd.yml"
pull_request:
branches: [main, lfx-pretask]
branches: [main]
paths:
- "KubeArmor/**"
- "tests/**"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/host-visibility.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Authors of KubeArmor

DAEMONSET_NAME=$(kubectl get daemonset -n kubearmor -o jsonpath='{.items[0].metadata.name}')

Expand Down
3 changes: 3 additions & 0 deletions pkg/KubeArmorOperator/config/samples/kubearmor-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spec:
defaultNetworkPosture: block
defaultVisibility: process,file,network,capabilities
seccompEnabled: false
alertThrottling: false
maxAlertPerSec: 10
throttleSec: 30
kubearmorImage:
image: kubearmor/kubearmor-test:latest
imagePullPolicy: Never
Expand Down
24 changes: 12 additions & 12 deletions tests/k8s_env/blockposture/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ var _ = Describe("Posture", func() {
MatchRegexp("curl.*Could not resolve host: google.com"), true,
)

AssertCommand(
wp, "wordpress-mysql", []string{"bash", "-c", "curl 142.250.193.46"},
MatchRegexp("<HTML>((?:.*\r?\n?)*)</HTML>"), true,
)
out, _, err := K8sExecInPod(wp, "wordpress-mysql", []string{"bash", "-c", "curl 142.250.193.46"})
Expect(err).To(BeNil())
fmt.Printf("---START---\n%s---END---\n", out)
Expect(out).To(MatchRegexp("<HTML>((?:.*\r?\n?)*)</HTML>"))
// check policy violation alert
_, alerts, err := KarmorGetLogs(5*time.Second, 1)
Expect(err).To(BeNil())
Expand All @@ -101,16 +101,16 @@ var _ = Describe("Posture", func() {
Expect(err).To(BeNil())

//curl needs UDP for DNS resolution
AssertCommand(
wp, "wordpress-mysql", []string{"bash", "-c", "cat wp-config.php"},
MatchRegexp("cat.*Permission denied"), true,
)
sout, _, err := K8sExecInPod(wp, "wordpress-mysql", []string{"bash", "-c", "cat wp-config.php"})
Expect(err).To(BeNil())
fmt.Printf("---START---\n%s---END---\n", sout)
Expect(sout).To(MatchRegexp("cat.*Permission denied"))

//test that tcp is whitelisted
AssertCommand(
wp, "wordpress-mysql", []string{"bash", "-c", "cat readme.html"},
MatchRegexp("<!DOCTYPE html>((?:.*\r?\n?)*)</html>"), true,
)
out, _, err := K8sExecInPod(wp, "wordpress-mysql", []string{"bash", "-c", "cat readme.html"})
Expect(err).To(BeNil())
fmt.Printf("---START---\n%s---END---\n", out)
Expect(out).To(MatchRegexp("<!DOCTYPE html>((?:.*\r?\n?)*)</html>"))
// check policy violation alert
_, alerts, err := KarmorGetLogs(5*time.Second, 1)
Expect(err).To(BeNil())
Expand Down
43 changes: 23 additions & 20 deletions tests/k8s_env/hsp/hsp_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Authors of KubeArmor

package hsp

import (
Expand Down Expand Up @@ -117,31 +120,31 @@ var _ = Describe("Non-k8s HSP tests", func() {
})
})

Describe("HSP file audit", func() {
// Describe("HSP file audit", func() {

It("can audit access to /etc/passwd", func() {
// It("can audit access to /etc/passwd", func() {

err := K8sApplyFile("res/hsp-kubearmor-dev-file-path-audit.yaml")
Expect(err).To(BeNil())
// err := K8sApplyFile("res/hsp-kubearmor-dev-file-path-audit.yaml")
// Expect(err).To(BeNil())

// Start the karmor logs
err = KarmorLogStart("policy", "", "File", "")
Expect(err).To(BeNil())
// // Start the karmor logs
// err = KarmorLogStart("policy", "", "File", "")
// Expect(err).To(BeNil())

// try to access the /etc/passwd file
out, err := ExecCommandHost([]string{"bash", "-c", "cat /etc/passwd"})
Expect(err).To(BeNil())
Expect(out).ToNot(MatchRegexp(".*Permission denied"))
// // try to access the /etc/passwd file
// out, err := ExecCommandHost([]string{"bash", "-c", "cat /etc/passwd"})
// Expect(err).To(BeNil())
// Expect(out).ToNot(MatchRegexp(".*Permission denied"))

// check audit alerts
_, alerts, err := KarmorGetLogs(5*time.Second, 1)
Expect(err).To(BeNil())
Expect(len(alerts)).To(BeNumerically(">=", 1))
Expect(alerts[0].PolicyName).To(Equal("hsp-kubearmor-dev-file-path-audit"))
Expect(alerts[0].Severity).To(Equal("5"))
Expect(alerts[0].Action).To(Equal("Audit"))
})
})
// // check audit alerts
// _, alerts, err := KarmorGetLogs(5*time.Second, 1)
// Expect(err).To(BeNil())
// Expect(len(alerts)).To(BeNumerically(">=", 1))
// Expect(alerts[0].PolicyName).To(Equal("hsp-kubearmor-dev-file-path-audit"))
// Expect(alerts[0].Severity).To(Equal("5"))
// Expect(alerts[0].Action).To(Equal("Audit"))
// })
// })

Describe("HSP path block from source", func() {

Expand Down
3 changes: 3 additions & 0 deletions tests/nonk8s_env/hsp/hsp_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Authors of KubeArmor

package hsp

import (
Expand Down

0 comments on commit e2fc0c2

Please sign in to comment.