Skip to content

Commit

Permalink
Adding test
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Schendel <[email protected]>
  • Loading branch information
amitschendel committed Nov 24, 2024
1 parent 67327b3 commit 4dd1789
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ nodeAgent:
alertManagerExporterUrls: [
"alertmanager-operated.monitoring.svc.cluster.local:9093"
]
stdoutExporter: false
stdoutExporter: true
syslogExporterURL: ""

serviceMonitor:
Expand Down
22 changes: 12 additions & 10 deletions tests/images/malicious-app/malicious.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,24 @@ func runAllMaliciousBehaviors() error {
}
fmt.Print(output)

// Trigger unexpected process launch (R0001)
// Trigger exec binary not in base image (R1001)
// Trigger unexpected service account use (R0006)
// Trigger kubernetes client executed in container (R0007)
// Run Kubectl get secrets by calling kubectl binary
fmt.Println("Running kubectl get secrets...")
output, err = runKubectl("./kubectl", "get", "secrets")
// Trigger unexpected Service Account Token Access (R0006)
// Open the service account token file
fmt.Println("Opening service account token file...")
file, err := os.Open("/run/secrets/kubernetes.io/serviceaccount/token")
if err != nil {
fmt.Printf("Failed to run kubectl: %v\n", err)
fmt.Printf("Failed to open service account token file: %v\n", err)
} else {
// Close the file
err = file.Close()
if err != nil {
fmt.Printf("Failed to close service account token file: %v\n", err)
}
}
fmt.Print(output)

// Trigger unexpected file access (R0002)
// Open a file for writing
fmt.Println("Opening malicious.txt for writing...")
file, err := os.OpenFile("malicious.txt", os.O_CREATE|os.O_WRONLY, 0644)
file, err = os.OpenFile("malicious.txt", os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Printf("Failed to open file: %v\n", err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/malicious-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
- name: WAIT_FOR_SIGTERM
value: "true"
- name: WAIT_BEFORE_START
value: "4m"
value: "3m"
volumeMounts:
- mountPath: /podmount
name: mount-for-alert
Expand Down

0 comments on commit 4dd1789

Please sign in to comment.