8000 Add rules to the pipeline by josedonizetti · Pull Request #2439 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add rules to the pipeline #2439

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

Merged

Conversation

josedonizetti
Copy link
Contributor
@josedonizetti josedonizetti commented Dec 6, 2022

Initial Checklist

This PRs adds the rule engine to the events pipeline.

Fixes: #2441

How Has This Been Tested?

# compiles
make

# test single rule event
./dist/tracee --trace event=anti_debugging
# test event with output json
./dist/tracee --trace event=anti_debugging --output format:json

# test single event with extra non rule event
./dist/tracee --trace event=anti_debugging,execve

# test single event with non rule dependency event
./dist/tracee --trace event=ptrace,anti_debugging

# test all events
./dist/tracee  --trace event=anti_debugging,aslr_inspection,cgroup_notify_on_release,cgroup_release_agent,core_pattern_modification,default_loader_mod,disk_mount,docker_abuse,dynamic_code_loading,fileless_execution,hidden_file_created,illegitimate_shell,k8s_api_connection,k8s_cert_theft,kernel_module_loading,ld_preload,process_vm_write_inject,proc_fops_hooking,proc_kcore_read,proc_mem_access,proc_mem_code_injection,ptrace_code_injection,rcd_modification,sched_debug_recon,scheduled_task_mod,stdio_over_socket,sudoers_modification,syscall_hooking,system_request_key_mod

# test rule event non exported, won't work because the event isn't exported
./dist/tracee --output format:json --trace event=dropped_executable
{"level":"fatal","ts":1670495492.8543997,"msg":"app","error":"invalid event to trace: dropped_executable"}

# list all events, including those that are rules
./dist/tracee --list

@josedonizetti josedonizetti force-pushed the add-rules-to-the-pipeline branch from b3ea657 to 0eb7c2e Compare December 6, 2022 22:45
@josedonizetti josedonizetti marked this pull request as ready for review December 6, 2022 23:21
@josedonizetti
Copy link
Contributor Author

@NDStrahilevitz I tried to address all your comments from the previous PR #2374, let me know if anything passed by.

Copy link
Member
@geyslan geyslan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review pass: put some comments.

@josedonizetti josedonizetti requested a review from geyslan December 8, 2022 10:10
Copy link
Member
@geyslan geyslan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and LGTM. Great work!

@rafaeldtinoco
Copy link
Contributor

image

You're missing alignment in the "list" command. Also, a line jump in between the last signature events and System Calls events.

Also: maybe you should change "Events" to "Signature Events" so they are not confused. At least for now?

Copy link
Contributor
@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments, doubts and nits for you. Nice work. Let's do another round after some answers and talks. Cheers!

for {
select {
case finding := <-engineOutput:
event, err := FindingToEvent(finding)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that eventually you will have to call:

if !t.shouldProcessEvent(event) {
    continue
}

in here before sending event to "out" channel. This will happen because the user might have choosen the event (Which is a signature) but they might be filtering the output of such event through args, for example. For now you're using the original event args, but eventually it will be the "finding data", right ? Then you might "filter" out detections as well, just like other events.

Copy link
Contributor Author
@josedonizetti josedonizetti Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaeldtinoco I hadn't considered having finding data as args, but I agree it is weird indeed to keep the original event data, need to think about it though. Do you think it is mandatory for this PR, or can be done in a follow-up for the next release?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the feature will be a "tech preview" I think it is fine do have an issue and mark it for the next release (considering we are out of time for this one).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be the default solution, for now, the only way to use it will be purposely choose it, also will make sure to note it as experimental on the release notes/docs.

Copy link
Collaborator
@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @josedonizetti!

Comment on lines 73 to 78
9E81
go func() {
defer close(done)

<-ctx.Done()
done <- true
}()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can pass ctx to the engine as well instead of having this new done channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I also want to do it, didn't do it here because I want to avoid changing tracee-rules. I'll create a follow-up task as a refactor. Ok?

@@ -54,6 +88,15 @@ func main() {
return err
}

// parse arguments must be enabled if the rule engine is part of the pipeline
runner.TraceeConfig.Output.ParseArguments = true
Copy link
Collaborator
@NDStrahilevitz NDStrahilevitz Dec 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we should eventually get rid of this (see #2177)

}
}

type fakeSignature struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a lot of duplicates of this mock signature, maybe we should export one at the signature package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIke the idea, will create a task as a follow-up refactor, ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@josedonizetti josedonizetti force-pushed the add-rules-to-the-pipeline branch from f5b0155 to ad929fe Compare December 12, 2022 08:59
Copy link
Contributor
@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good on my side. Will let you handle the rest of the comments with others, but +1'ing on my side.

Copy link
Collaborator
@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josedonizetti josedonizetti merged commit adb9952 into aquasecurity:main Dec 12, 2022
@josedonizetti josedonizetti deleted the add-rules-to-the-pipeline branch December 12, 2022 21:38
@josedonizetti josedonizetti mentioned this pull request Dec 15, 2022
21 tasks
@yanivagman yanivagman removed this from the v0.10.0 milestone Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] add rules to events pipeline
5 participants
0