-
Notifications
You must be signed in to change notification settings - Fork 392
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
tracing-policies: support tags to categorize events #2008
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
a2c59ff
to
9c2e50b
Compare
@jrfastab the namespace I added is "observability", doing "tracing" is an alternative, strictly speaking they are flexible. But I prefer to have it "observability.tracing" for things bpf, kprobes, etc instead or even later "integrity.tracing" things that modify the kernel or memory... be more into users/tools that will consume Tetragon events and filter those events by tags, compared to doing the developer way of "tracing.filesystem" or "tracing.x" which will still stay a bit low level and hard to consume from a higher perspective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks that's a good addition! I just have some remarks on the Go code that could be simplified I think to be easier to read.
I'm not fan of the naming observability.privilege
though I don't think very talkative while privilege_escalation or whatever is from MITRE or other standards is more explicit.
pkg/sensors/tracing/tags.go
Outdated
func escapeTag(tag string) (string, error) { | ||
l := len(tag) | ||
if l < TpMinTagLen { | ||
return "", ErrTagSyntaxShort | ||
} else if l > TpMaxTagLen { | ||
l = TpMaxTagLen | ||
} | ||
|
||
t := fmt.Sprintf("%q", tag[:l]) | ||
newLen := len(t) | ||
if newLen <= l || t[0] != '"' || t[newLen-1] != '"' { | ||
return "", ErrTagSyntaxEscape | ||
} | ||
|
||
// Remove double quoted string so we pretty print it later in the events | ||
return t[1 : newLen-1], nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it a bit hard to read and I would simplify it like this:
func escapeTag(tag string) (string, error) { | |
l := len(tag) | |
if l < TpMinTagLen { | |
return "", ErrTagSyntaxShort | |
} else if l > TpMaxTagLen { | |
l = TpMaxTagLen | |
} | |
t := fmt.Sprintf("%q", tag[:l]) | |
newLen := len(t) | |
if newLen <= l || t[0] != '"' || t[newLen-1] != '"' { | |
return "", ErrTagSyntaxEscape | |
} | |
// Remove double quoted string so we pretty print it later in the events | |
return t[1 : newLen-1], nil | |
} | |
func escapeTag(tag string) (string, error) { | |
if len(tag) < TpMinTagLen { | |
return "", ErrTagSyntaxShort | |
} else if len(tag) > TpMaxTagLen { | |
tag = tag[:TpMaxTagLen] | |
} | |
escapedTag := strconv.Quote(tag) | |
return escapedTag[1:len(escapedTag)-1], nil | |
} |
len(s) is just accessing a field in the string struct, also I don't think strconv.Quote (called by fmt.Sprintf with the %q word) can ever fail? Did you have something specific in mind that could make this function not work? I think we can rely on it or we can report a bug to the stdlib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't bother check, just quickly ensuring that we escape and stay in boundary, will see, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @mtardy thanks I checked it and you are right fmt.Sprintf %q just ends up calling appendQuotedWith() which is basically the core of all these handling with the right parameters and we are sure to always have double quotes. Much appreciated ;-) , changed.
privilege_escalation seems what other tools are using, it is explicit, with the right filters we can surely use it, let's see what other think |
|
||
## User defined Tags | ||
|
||
Users can define their own tags inside Tracing Policies. The official supported tags are documented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this "official" supported tags. Tags can be anything I don't understand why we "support" a specific set of tags. I would just leave this as example tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as we agreed some official tags are only in the doc to help keep things consistent, but I removed all the rest from the code, updated comment.
overall I agree tag fields are useful way for user to get a field they can use for DB or whatever event monitoring system for filtering, categorizing, etc. But, I'm against embedding specific tags in Tetragon. Why do we care? |
Could you also add an export filter for tags? I think that would be useful to enable/disable certain types of events posting to JSON logs. |
@jrfastab so we care:
So yeh I'm anticipating a bit, ok I will remove the default namespaces for now, let's get this merged first, then I think we will shortly have to update the policylibrary with default tags... in other words tell our users look for those tags and you get the corresponding events. I let you sleep on it... :-)
Ok will see how to add the export filter, fix and repush. |
@tixxdz I'm all for groupings by tags and a default set of tags for different groups of observability and enforcement. I still don't follow why that needs to be embedded in the codebase. I'm happy with a dir in policylibrary for each taggroup though. |
5ead851
to
400895e
Compare
Thanks @mtardy for the review, and I changed it to |
So summary:
|
400895e
to
ac3b1fc
Compare
Go ahead and merge after rebase to avoid future conflicts. Also I'll watch it today so when its green I can merge it as well if I see it. |
In the process of producing user friendly events, we have added in 1842f69 "message" field so user can understand why this event was produced instead of cryptic message generated from code. Now to categorize events we need a "tags" field that is a list of tags. The Sigma Tags Specification is a good starting point: https://github.com/SigmaHQ/sigma-specification/blob/main/Tags_specification.md From that we can have namespaces for events, and we start with the "observability" namespace, that is the ability to collect and export data about the internal system state. - "observability.filesystem": this event is about filesystem operations. - "observability.privilege": this event is about the rights and permissions granted to a process or a user. - "observability.process": this event is about an instance of a Linux program that is being executed. Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Tags are optional and are used to categorize generated events. * "observability.filesystem": the event is about file system operations. * "observability.privilege_escalation": the event is about raising permissions of a user or a process. * "observability.process": the event is about an instance of a Linux program being executed. Users can provide their own tags too. Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
ac3b1fc
to
014c671
Compare
To categorize events we need a "tags" field that is a list of tags.
The Sigma Tags Specification is a good starting point:
https://github.com/SigmaHQ/sigma-specification/blob/main/Tags_specification.md
We first define namespaces for events, and we start with the
"observability" namespace.
observability: is the ability to collect and export data about the internal system state.
granted to a process or a user.
that is being executed.