Commit Graph

2762 Commits

Author SHA1 Message Date
Jason Dellaluce
b5870a8656 new(userspace/engine): add a resolver class to search evttypes from filters and event names
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
f638706ba3 chore(userspace/engine): renamings and code polishing in rule_loader and rule_reader
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-15 10:54:58 +02:00
Jason Dellaluce
e1a5427874 update(userspace): add method to clear rule loader state
Once all rule files have been loaded, and all the rules have been compiled into filters and inserted in the engine rulesets, the loader definitions are maintained in memory without really being used. This commit adds a convenience method to clear the loader state and free-up some memory when engine consumers do not require such information in memory anymore.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-15 10:54:58 +02:00
Jason Dellaluce
30fb58ed48 refactor(userspace/engine): update falco_engine to use new rule_reader
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-15 10:54:58 +02:00
Jason Dellaluce
2c0e6d3b88 update(userspace/engine): introduce new rule_reader class
The rule_reader class is responsible of parsing the YAML ruleset text and of using the rule_loader
to store the new definition in the internal state. This is a first step towards separating the YAML
reading logic from the rule parsing one. Potentially, this will allow us to read rulesets from another
YAML library or from something different than YAML files too.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-15 10:54:58 +02:00
Jason Dellaluce
9ed7d57838 refactor(userspace/engine): reduce responsibilities of rule_loader
The rule_loader is now simply responsible of collecting list/macro/rule definitions and then compiling them as falco_rules. The ruleset file reading code will be moved to another class

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-15 10:54:58 +02:00
Clemence Saussez
af96a930eb rules(allowed_kube_namespace_image_list): add container threat detection image
Signed-off-by: Clemence Saussez <clemence@zen.ly>
2022-04-15 10:52:58 +02:00
Clemence Saussez
5d65671d3a rules(falco_privileged_images): add container threat detection image
Signed-off-by: Clemence Saussez <clemence@zen.ly>
2022-04-15 10:52:58 +02:00
Stefano
d3383b4b23 Fixed ouput Rules K8s Serviceaccount Created/Deleted
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
Co-authored-by: AlbertoPellitteri <alberto.pellitteri@sysdig.com>
2022-04-15 10:49:58 +02:00
Stefano
65435d4418 Removed use cases not triggering
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
Co-authored-by: Brucedh <alessandro.brucato@sysdig.com>
Co-authored-by: AlbertoPellitteri <alberto.pellitteri@sysdig.com>
2022-04-13 10:03:25 +02:00
Jason Dellaluce
06b6565fa6 refactor(userspace): sync falco codebase to new falco_common definitions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 22:21:20 +02:00
Jason Dellaluce
55ec8c0e1b refactor(userspace/engine): polish falco_common and improve priority parsing/formatting
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 22:21:20 +02:00
Lorenzo Susini
4343fe8a8b new(rules/k8s_audit): add rules to detect pods sharing host pid and IPC namespaces
Signed-off-by: Lorenzo Susini <susinilorenzo1@gmail.com>
2022-04-11 18:29:19 +02:00
Jason Dellaluce
2934ef29b9 chore(userspace/engine): fix indentations and use improve indexed_vector
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
47426fbe0d update(userspace/engine): minor improvements and bug fixes on engine and rule loader
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
e50d22f013 fix(userspace/engine): solve integration test errors
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
c0f8171d89 test: adapt integration tests to new rule loader error messages
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
43020d8a7d refactor(userspace/engine): re-implement the rule loader in C++
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
d483b897e7 new(userspace/engine): create stats_manager inside falco engine
This is a porting of what we had inside the Lua codebase. This now handles the single responsibility
of gathering stats about rule-event matching, and of formatting them to print them to the user.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
9e93b7cd52 new(userspace/engine): add falco_rule struct to represent rule definitions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
6c9e6c5918 new(userspace/engine): add new indexed_vector class to achieve string-based O(1) access in vectors
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
c2cac5af92 refactor(userspace/engine): add run() overload in filter_macro_resolver to support shared_ptrs
This change allows working with safety with AST nodes wrapped into shared pointers.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
cf83a91d4e refactor(userspace/engine): re-implement wrap_text() function in falco_utils
The function implementation was removed, however it was still defined in the .h header. Moreover,
this will now be required in order to replace its lua equivalent.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
3201479392 refactor(userspace/engine): turn falco_common into a namespace containing common static utilities
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
b74dcbd851 cleanup(userspace/engine): remove lua files and lua-related code sections
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Jason Dellaluce
7db9dd66ff refactor(build): drop dependencies to chisels, luajit, lyaml, and libyaml
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-11 12:22:18 +02:00
Angelo Puglisi
e8cb96a57b perf: change falco_engine::process_event to lookup sources by index
falco_engine::process_event gets called for every inspector event.
Profiling showed that std::map::find takes about 10% of
falco_engine::process_event, and that can easily improved by accessing
the source by index.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2022-04-06 14:46:31 +02:00
Mateusz Gozdek
cb4cec6f57 Fix typos
Found by running the following command:
codespell -f -H -L aks,creat,chage -S .git

Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
2022-04-06 14:40:31 +02:00
Stefano
36bd07d82d Fix spaces
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
2022-04-01 19:38:40 +02:00
Stefano
bcff88922a Added eks_allowed_k8s_users list to whitelist EKS users
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
Co-authored-by: Alberto Pellitteri <alberto.pellitteri@sysdig.com>
2022-04-01 19:38:40 +02:00
Stefano
1988f3b0be Disabled by default noisy rules
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
2022-03-29 17:39:25 +02:00
schie
64f0cefab0 Update rules/okta_rules.yaml
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
Co-authored-by: Thomas Labarussias <issif+github@gadz.org>
2022-03-29 17:39:25 +02:00
schie
48041a517b Update rules/okta_rules.yaml
Signed-off-by: darryk10 <stefano.chierici@sysdig.com>
Co-authored-by: Thomas Labarussias <issif+github@gadz.org>
2022-03-29 17:39:25 +02:00
Stefano
6a1492a828 Added okta_rules.yaml
Signed-off-by: darryk10<stefano.chierici@sysdig.com>
2022-03-29 17:39:25 +02:00
Leonardo Grasso
5023851000 chore(rules): remove leftover
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-03-25 13:02:28 +01:00
Jason Dellaluce
ecf13762b8 test(userspace/engine): add unit test cases for filter_macro_resolver
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
a0a87e443f update(userspace/engine): support undefining macros
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
20c59970f5 update(engine): rename and improve sinsp filter macro resolvers
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
c801c09e7d update(test): adapt integration test error messages to comply to new parser errors
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
b7db0f9b14 refactor(engine/lua): update lua rule loader to use new sinsp parser
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
2ee95122df refactor(engine): remove unused lua modules
Both the parser.lua and compiler.lua modules are not necessary anymore, because all the logic related
to filter parsing and compilation is handled inside libsinsp now. Accordingly, they have been removed from
the lua-to-cpp.sh scripts. README.md and parse-smoke.sh have been removed since they are not needed anymore:
lpeg is not used by the project, and the smoke tests are implemented in libsisnsp unit test suite.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
911bd16556 update(engine): create a lua helper for rule filter manipulation
The lua_filter_helper class is a simple Lua wrapper that can be used in the Lua rule loader to
parse/compile rule filters, and manipulate them to resolve/replace list and macro references.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
3879a283bf refactor(engine): remove dependency from lua parser
The Lua parser grabbed from libs chisels is not used anymore, as the compilation logic happen inside the new
filter parser of libsinsp.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
c5818e6273 new(engine): add rule filter macro-resolver
This is a first step towards porting the rule filter building logic that is currently implemented in Lua.
filter_macro_resolver uses the newly introduced AST constructs from libsinsp, and
allow manipulating filter ASTs to resolve/replace macro references. This is meant to be used
at boot time by the rule loader (which we still want to maintain implemented in Lua for now).

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Jason Dellaluce
0a132f453a update(cmake): remove lpeg dependency
The Lua PEG parser is not longer needed, since we now use the new filter parser implemented
in libsinsp.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-03-23 18:31:43 +01:00
Frederico Araujo
26a3b7a01e refator(image): commented and moved symlinks inside SKIP_DRIVER_LOADER check
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
2022-03-23 15:39:03 +01:00
Frederico Araujo
55700f80e4 refactor(image): remove -x flag in ubi docker entrypoint
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
2022-03-23 15:39:03 +01:00
Frederico Araujo
54a817bf3c feat(image): set default value for UBI_VERSION build arg
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
2022-03-23 15:39:03 +01:00
Frederico Araujo
04cadee6fa fix(image): update package cache cleanup command
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
2022-03-23 15:39:03 +01:00
Frederico Araujo
4f5fb12a13 docs(docker/readme): updated table to include experimental UBI-based image for Falco
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
2022-03-23 15:39:03 +01:00