-
Notifications
You must be signed in to change notification settings - Fork 11
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
Test For command falco -i (ignore default events) #8
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae3b1da
Added test to print ignored events
Rohith-Raju d465af0
Made changes as per review requests
Rohith-Raju 4cae337
doc changes
Rohith-Raju 506f3dd
use embed to read the output file
Rohith-Raju 3813047
made changes to syscall events
Rohith-Raju 5fce27d
made changes to regex
Rohith-Raju 0dfb739
made changes to events
Rohith-Raju b3bd0f6
final changes
Rohith-Raju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package outputs | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/falcosecurity/testing/pkg/run" | ||
) | ||
|
||
type Data struct { | ||
Events []string `json:"events"` | ||
} | ||
|
||
func deserialize() string { | ||
_, file, _, ok := runtime.Caller(1) | ||
if !ok { | ||
panic("not able to extract runtime caller info") | ||
} | ||
dir, err := filepath.Abs(filepath.Dir(file)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
filePath := filepath.Join(dir, "events.json") | ||
evntfile, err := os.Open(filePath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer evntfile.Close() | ||
|
||
var events Data | ||
err = json.NewDecoder(evntfile).Decode(&events) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return strings.Join(events.Events, ",") | ||
} | ||
|
||
var EventData = run.NewStringFileAccessor("eventData", deserialize()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
{ | ||
"events": [ | ||
"getdents64", | ||
"getdents", | ||
"getresgid", | ||
"getresuid", | ||
"getegid", | ||
"geteuid", | ||
"munmap", | ||
"sendmmsg", | ||
"splice", | ||
"getpeername", | ||
"write", | ||
"stat", | ||
"getsockname", | ||
"access", | ||
"nanosleep", | ||
"setsockopt", | ||
"read", | ||
"futex", | ||
"semget", | ||
"getgid", | ||
"page_fault", | ||
"brk", | ||
"readahead", | ||
"set_mempolicy_home_node", | ||
"io_pgetevents", | ||
"setreuid", | ||
"rt_sigtimedwait", | ||
"process_madvise", | ||
"vmsplice", | ||
"lstat", | ||
"preadv2", | ||
"io_uring_register", | ||
"rt_sigreturn", | ||
"sched_get_priority_min", | ||
"pread", | ||
"sched_setscheduler", | ||
"sched_getparam", | ||
"init_module", | ||
"sched_setparam", | ||
"rt_sigpending", | ||
"rt_sigsuspend", | ||
"getpgid", | ||
"delete_module", | ||
"fremovexattr", | ||
"msgsnd", | ||
"uname", | ||
"syslog", | ||
"ioperm", | ||
"fstatfs", | ||
"getpgrp", | ||
"sched_getscheduler", | ||
"setpriority", | ||
"open_tree", | ||
"kcmp", | ||
"getuid", | ||
"prctl", | ||
"llistxattr", | ||
"waitid", | ||
"arch_prctl", | ||
"getpriority", | ||
"send", | ||
"ftruncate", | ||
"truncate", | ||
"mremap", | ||
"reboot", | ||
"settimeofday", | ||
"pidfd_get_fd", | ||
"readlink", | ||
"gettimeofday", | ||
"clock_gettime", | ||
"getrusage", | ||
"sethostname", | ||
"timer_settime", | ||
"mmap2", | ||
"sysinfo", | ||
"setdomainname", | ||
"io_setup", | ||
"inotify_add_watch", | ||
"recvmmsg", | ||
"pidfd_send_signal", | ||
"getxattr", | ||
"ppoll", | ||
"move_mount", | ||
"getpid", | ||
"utime", | ||
"mknod", | ||
"semop", | ||
"getppid", | ||
"exit", | ||
"recv", | ||
"munlockall", | ||
"sched_get_priority_max", | ||
"sched_yield", | ||
"mmap", | ||
"restart_syscall", | ||
"fchownat", | ||
"getrlimit", | ||
"fstat64", | ||
"pkey_free", | ||
"copy_file_range", | ||
"fdatasync", | ||
"clock_settime", | ||
"get_mempolicy", | ||
"pwritev", | ||
"iopl", | ||
"getsid", | ||
"msgrcv", | ||
"semctl", | ||
"finit_module", | ||
"writev", | ||
"statx", | ||
"lchown", | ||
"set_mempolicy", | ||
"listxattr", | ||
"shmdt", | ||
"sched_rr_get_interval", | ||
"fsync", | ||
"lgetxattr", | ||
"getitimer", | ||
"timerfd_settime", | ||
"memfd_secret", | ||
"mknodat", | ||
"mlock2", | ||
"pause", | ||
"llseek", | ||
"syncfs", | ||
"uselib", | ||
"keyctl", | ||
"swapoff", | ||
"umask", | ||
"readv", | ||
"add_key", | ||
"select", | ||
"getcwd", | ||
"alarm", | ||
"rt_sigprocmask", | ||
"name_to_handle_at", | ||
"lseek", | ||
"poll", | ||
"rt_tgsigqueueinfo", | ||
"_sysctl", | ||
"vhangup", | ||
"timerfd_gettime", | ||
"io_uring_enter", | ||
"mlock", | ||
"lstat64", | ||
"futex_waitv", | ||
"move_pages", | ||
"clock_getres", | ||
"munlock", | ||
"query_module", | ||
"adjtimex", | ||
"swapon", | ||
"mq_unlink", | ||
"pidfd_open", | ||
"capget", | ||
"set_thread_area", | ||
"faccessat", | ||
"newfstatat", | ||
"timer_delete", | ||
"fspick", | ||
"io_getevents", | ||
"sysfs", | ||
"get_kernel_syms", | ||
"epoll_pwait", | ||
"acct", | ||
"preadv", | ||
"epoll_wait", | ||
"times", | ||
"ioprio_set", | ||
"pwrite", | ||
"setxattr", | ||
"mq_timedsend", | ||
"personality", | ||
"rt_sigaction", | ||
"wait4", | ||
"fstat", | ||
"setgroups", | ||
"flistxattr", | ||
"sync", | ||
"pluginevent", | ||
"clock_adjtime", | ||
"mprotect", | ||
"timer_getoverrun", | ||
"statfs", | ||
"sched_getaffinity", | ||
"utimensat", | ||
"mq_timedreceive", | ||
"switch", | ||
"landlock_add_rule", | ||
"setregid", | ||
"inotify_rm_watch", | ||
"tee", | ||
"epoll_wait_old", | ||
"ustat", | ||
"fchown", | ||
"remap_file_pages", | ||
"chown", | ||
"setfsuid", | ||
"setfsgid", | ||
"pivot_root", | ||
"mincore", | ||
"madvise", | ||
"timer_create", | ||
"gettid", | ||
"lsetxattr", | ||
"shmat", | ||
"fsetxattr", | ||
"quotactl_fd", | ||
"lookup_dcookie", | ||
"fgetxattr", | ||
"lremovexattr", | ||
"landlock_create_ruleset", | ||
"sched_setaffinity", | ||
"setitimer", | ||
"io_submit", | ||
"fsconfig", | ||
"request_key", | ||
"fanotify_init", | ||
"fsopen", | ||
"perf_event_open", | ||
"epoll_pwait2", | ||
"sched_setattr", | ||
"get_thread_area", | ||
"io_destroy", | ||
"exit_group", | ||
"fsmount", | ||
"epoll_ctl", | ||
"signaldeliver", | ||
"set_tid_address", | ||
"get_robust_list", | ||
"timer_gettime", | ||
"clock_nanosleep", | ||
"pkey_mprotect", | ||
"utimes", | ||
"mq_open", | ||
"mq_notify", | ||
"pwritev2", | ||
"mq_getsetattr", | ||
"kexec_load", | ||
"io_cancel", | ||
"ioprio_get", | ||
"futimesat", | ||
"mount_setattr", | ||
"readlinkat", | ||
"stat64", | ||
"shmget", | ||
"pselect6", | ||
"set_robust_list", | ||
"time", | ||
"shmctl", | ||
"getcpu", | ||
"msgctl", | ||
"fallocate", | ||
"process_vm_readv", | ||
"getgroups", | ||
"removexattr", | ||
"process_vm_writev", | ||
"sigaltstack", | ||
"getrandom", | ||
"fadvise64", | ||
"rt_sigqueueinfo", | ||
"memfd_create", | ||
"mlockall", | ||
"kexec_file_load", | ||
"pkey_alloc", | ||
"msgget", | ||
"landlock_restrict_self", | ||
"msync", | ||
"modify_ldt", | ||
"migrate_pages", | ||
"sendfile", | ||
"mbind", | ||
"epoll_ctl_old" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since we have a fairly recent version of Go, let me suggest considering go:embed https://pkg.go.dev/embed. I think it's a better approach than going through
runtime.Caller
and reinvent the wheel in this case! What do you think?Plus, if the only point of having a JSON file is to deserialize it and encode the inner list with comma-separated concatenation, why not just encoding all strings as comma-separated in a text file right away? This would also save you the trouble of defining a
Data
struct. I see the attempt of making something reusable, but I would suggest to 1) tackle reusability later when needed and keep the scope of this PR smaller, and 2) the JSON encoding is arbitrary, so it would be less intuitive for future contributors to reproduce.TL;DR: Great work! My last suggestions are:
NewStringFileAccessor
construct like you already do.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.
Oh, wow I didn't know something like this existed 😮 . Yes, this is great.
Will do!!