Question: How to load custom rego rules into Kubernetes Daemonset? #2402
Replies: 4 comments 10 replies
-
@abhaybhargav Hey, sorry for the delay. Unfortunately, the experience to do it now isn't the best one, I'll create a task to make sure we improve it. So, what I did quickly here to make it work: 1 - created a configmap with my rule content
2 - changed tracee daemonset to mount the configmap as a volume
3 - changed tracee daemonset to pass the path where the rules were mounted as an argument
There are probably different ways of doing it, but this should be fixed on the tracee side for a simpler experience. Like the trivy-operator does for defsec policies. |
Beta Was this translation helpful? Give feedback.
-
@josedonizetti I tried this, but it doesnt seem to work. I am not sure if the rule is at fault here. I removed the helper functions so I dont have to load the configmap with that apiVersion: v1
kind: ConfigMap
metadata:
name: tracee-config
data:
write_app.rego: |
package tracee.TRC_301
# import tracee.data.helpers
__rego_metadoc__ := {
"id": "TRC-301",
"version": "0.1.0",
"name": "Write to Python App Directory",
"description": "Write to Python App Directory",
"tags": ["linux", "container", "app", "python"],
"properties": {
"Severity": 2,
"MITRE ATT&CK": "Loading files into protected File System",
},
}
eventSelectors = [
{
"source": "tracee",
"name": "vfs_write"
},
{
"source": "tracee",
"name": "vfs_writev"
},
{
"source": "tracee",
"name": "write"
}
]
trace_selected_events[eventSelector] {
eventSelector := eventSelectors[_]
}
tracee_match {
input.eventName == "write"
arg := input.args[_]
arg.name == "pathname"
startswith(pathname, "/app/")
}
tracee_match {
input.eventName == "vfs_write"
arg := input.args[_]
arg.name == "pathname"
startswith(pathname, "/app/")
}
tracee_match {
input.eventName == "vfs_writev"
arg := input.args[_]
arg.name == "pathname"
startswith(pathname, "/app/")
} |
Beta Was this translation helpful? Give feedback.
-
@josedonizetti I dont think this is anything to do with the rule. I used a rule from your own docs (https://aquasecurity.github.io/tracee/dev/docs/detecting/rego/) and tried loading it in Kubernetes as a configmap. The rule was loaded but the logs for the event dont appear in the logs This was the configmap by the way. As I mentioned, the rule loaded successfully. I suspect there's some issue with the parsing of the rules, etc. apiVersion: v1
kind: ConfigMap
metadata:
name: tracee-config
data:
my-new-rule.rego: |
package tracee.TRC_808
__rego_metadoc__ := {
"id": "TRC-808",
"version": "0.1.0",
"name": "Read etcpasswd",
"description": "Read etcpasswd",
"tags": ["linux"],
"properties": {
"Severity": 2,
"MITRE ATT&CK": "Reading sensitive files",
},
}
eventSelectors := [
{
"source": "tracee",
"name": "openat",
},
{
"source": "tracee",
"name": "execve",
},
]
tracee_selected_events[eventSelector] {
eventSelector := eventSelectors[_]
}
tracee_match {
input.eventName == "openat"
arg_value = get_tracee_argument("pathname")
startswith(arg_value, "/etc/passwd")
}
tracee_match {
input.eventName == "execve"
arg_value = get_tracee_argument("pathname")
startswith(arg_value, "/etc/passwd")
}
get_tracee_argument(arg_name) = res {
arg := input.args[_]
arg.name == arg_name
res := arg.value
} |
Beta Was this translation helpful? Give feedback.
-
Hi, the solution mentioned appears to be docker specific - I'm unable to get custom rego signatures working in kubernetes (minikube) using helm as documented. What needs to change in the charts to apply a custome rego file - I'm just trying to use the example given here https://aquasecurity.github.io/tracee/latest/docs/events/custom/rego/ to monitor a file |
Beta Was this translation helpful? Give feedback.
-
I have a basic question. I have checked across the documentation and the source code, but I am not able to figure this out.
I have a few custom tracee rules (rego) that I'd like to load into my running kubernetes cluster. I have deployed tracee as a DaemonSet in my cluster. How do I load these custom rules into the tracee instance running on my Kubernetes cluster?
Any help would be greatly appreciated
Beta Was this translation helpful? Give feedback.
All reactions