-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to utilize Go templates to add dynamic custom fields #329
Comments
Hello, I don't understand exactly what you're trying to do. In your example, is |
@Issif I'm trying to use the label from the Pod within the event occurred and if that is not defined use a default value. Then rename the field to something that's not {
"output": "14:12:32.215952832: <message> (<falco_fields>...) fizz=example",
"priority": "Warning",
"rule": "Read sensitive file trusted after startup",
"source": "syscall",
"tags": [
"filesystem",
"mitre_credential_access"
],
"time": "2022-06-14T14:12:32.215952832Z",
"output_fields": {
"container.id": "cd15541bbb03",
"container.image.repository": "docker.io/falcosecurity/event-generator",
"evt.time": 1655215952215952832,
"fd.name": "/etc/shadow",
"k8s.pod.label.foo": "example",
"proc.aname[2]": "<NA>",
"proc.cmdline": "httpd --loglevel info run ^syscall.ReadSensitiveFileUntrusted$ --sleep 6s",
"proc.pname": "httpd",
"user.loginuid": -1,
"user.name": "<NA>"
}
} Notice how the # Static custom fields
customfields:
custom_field_one: "static"
templatedfields:
templated_field_one: '{{ or (index . k8s.pod.label.foo) "bar" }}' So that the final fields forwarded along to the configured outputs of Falco Sidekick would look like the following {
"output": "14:12:32.215952832: <message> (<falco_fields>...) fizz=example",
"priority": "Warning",
"rule": "Read sensitive file trusted after startup",
"source": "syscall",
"tags": [
"filesystem",
"mitre_credential_access"
],
"time": "2022-06-14T14:12:32.215952832Z",
"output_fields": {
"container.id": "cd15541bbb03",
"container.image.repository": "docker.io/falcosecurity/event-generator",
"evt.time": 1655215952215952832,
"fd.name": "/etc/shadow",
"k8s.pod.label.foo": "example",
"proc.aname[2]": "<NA>",
"proc.cmdline": "httpd --loglevel info run ^syscall.ReadSensitiveFileUntrusted$ --sleep 6s",
"proc.pname": "httpd",
"user.loginuid": -1,
"user.name": "<NA>",
"custom_field_one": "static",
"templated_field_one": "example"
}
} Currently |
If |
Without digging too deep into the Falco code, I'm assuming that in the example I've shared that It makes sense that you don't want Falcosidekick to be aware of where it's running. A I don't believe that this feature request is a request to make Falcosidekick as part of this feature request is that Falcosidekick has the ability to ability to template new custom output fields with the existing JSON that Falco sends to it, similar to how there are output sources that can format a message given the existing JSON from Falco. |
Ok, now I see what you're talking about. I'll try to propose you something asap. |
Thank you @Issif |
Here's the current status of my tests. With these settings: templatedfields: # templated fields are added to falco events and metrics
Dkey: '{{ or (index . "k8s.ns.labels.foo") "bar" }}' A test
Gives this result:
Without the value in
The templated fields are executed in last, it means you can use also use the
Do you want to test an image? |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
Stale issues rot after 30d of inactivity. Mark the issue as fresh with Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle rotten |
Motivation
Currently we're using custom fields to add a static field to all of the Falco events being handled by sidekick. However, we'd like to utilize the Kubernetes labels on the Falco event to determine value for the field we're adding to Falco and fall back to a default if need be.
Feature
When declaring custom fields to add to Falco events flowing through sidekick, allow for the ability to add a custom field based on a Go template, similar to the message format Go templates; this may have to be in the configuration file only.
Alternatives
-p
on Falco to add the field, but it doesn't support the logic provided by Go templates. Can achieve something similar by using theprogram_output
syscall
events.Additional context
The text was updated successfully, but these errors were encountered: