Commit Graph

2992 Commits

Author SHA1 Message Date
Mark Stemm
ccbc8ec196 Copying falco.cpp to init_inspector.cpp to preserve history (step 2, restoring falco.cpp)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
344dc3930b Copying falco.cpp to init_inspector.cpp to preserve history (step 1, copying file)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
431b8885b4 Copying falco.cpp to init_falco_engine.cpp to preserve history (step 2, restoring falco.cpp)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
22674f6bf8 Copying falco.cpp to init_falco_engine.cpp to preserve history (step 1, copying file)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
ae7c8190d3 Copying falco.cpp to create_signal_handlers.cpp to preserve history (step 2, restoring falco.cpp)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
da7efbc96e Copying falco.cpp to create_signal_handlers.cpp to preserve history (step 1, copying file)
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
9de80b7b92 Application changes to support actions
Changes to the falco::app::application object to support actions:

- All of the code that was in falco_init is now in methods of
  application. (A later commit actually moves the code from falco_init
  and into the split-up methods, this commit just declares them).
- Methods return an application::run_result object, which is a tuple
  of success/errstr/proceed. proceed=false is used to short circuit
  calling methods (think --help, --list, --support, etc.)
- application now has a run() method which runs the methods in an order
  that honors any implicit dependencies (e.g. you have to init an
  inspector before you open it, you have to do almost everything else
  before processing events, etc.)
- There are a few methods devoted to teardown, they are always called
  after the group of run methods are called.
- State that needs to be saved between methods, or saved between the
  run and teardown functions, is in a
  falco::app::application::state object.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
0a51f4f1f1 Convert direct pointer refs to shared_ptr
Some objects used by falco (falco outputs, falco_formats, etc) were
using raw pointer references, which isn't great.

So convert use of raw pointers (originally passed from falco_init or
functions it called) with shared_ptr, as they are now held in
application state.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
531bc3eb5a Falco test changes (small output matches) for actions
With the split of falco_init into application:: methods, including a
notion of a success/error/proceed result, there is a
more concrete line between runtime errors (e.g. things that throw
exceptions) and errors returned by methods that run the application.

Some of the plugins tests were expecting errors to be returned by
exceptions (e.g. with a leading "Runtime error: and a trailing "
Exiting.").

Now, the errors are just returned directly in application::run(), so
drop the leading and trailing bits in expected test outputs.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Mark Stemm
62d4fffcb2 Add missing pragma
Without this, if webserver is included more than once you get
duplicate defined classes.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-04-22 13:27:52 +02:00
Leonardo Grasso
2c3c8b92e0 build: MUSL builds can't have plugins
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-22 09:41:56 +02:00
Leonardo Grasso
d443bcfe5f build: components opt-in mechanism for packages
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-22 09:41:56 +02:00
Leonardo Grasso
01b407a358 build: define "plugins" component
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-22 09:41:56 +02:00
Leonardo Grasso
b4d9261ce2 build: define "falco" component
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-22 09:41:56 +02:00
Leonardo Grasso
3300c72db0 build(cmake/modules): explicitly set libs package and driver component names
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-22 09:41:56 +02:00
Jason Dellaluce
0bf53f0f88 refactor(userspace/engine): restrict unsafe-na-check warning to k8s audit fields
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-21 18:50:58 +02:00
Jason Dellaluce
37d03cf7bc chore(userspace/engine): fix typo spotted with codespell
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-21 18:50:58 +02:00
Jason Dellaluce
71274b4369 test(userspace/engine): add unit tests for filter_warning_resolver
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-21 18:50:58 +02:00
Jason Dellaluce
95727b268f new(userspace/engine): add a resolver to generate warnings from a filter AST
The first warnings we support involve the unsafe comparisons with <NA>, which were present
in the legacy regression tests for PSPs.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-21 18:50:58 +02:00
Jason Dellaluce
391ab028fc refactor!: deprecate PSP regression tests
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-21 18:50:58 +02:00
Leonardo Grasso
8dd4beac73 build(cmake): upgrade catch2 to 2.13.9
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-04-21 16:17:59 +02:00
Mateusz Gozdek
b080d20525 Add codespell GitHub Action
Folllow up to #1961 to prevent common typos to be added to the repo.

Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
2022-04-20 12:21:27 +02:00
Mateusz Gozdek
1fdfbd3a3d Fix more typos
Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
2022-04-20 12:21:27 +02:00
Kevin Krakauer
53eb6112a6 add gVisor to ADOPTERS.md
Signed-off-by: Kevin Krakauer <krakauer@google.com>
2022-04-20 12:20:27 +02:00
Jason Dellaluce
13256fb7ef update(userspace/engine): bump engine version to 12
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
df6dced96b update(build): bump cloudtrail and json plugin versions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
d9d23cd31d update: bump libs version to b19f87e8aee663e4987a3db54570725e071ed105
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
b8a95d262f refactor(userspace/engine): polish evttype resolver and use it in rule loader
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
dd3d235d7f refactor(tests): adapting test_rulesets to new method signatures
At the same time, this also simplifies the unit test cases by using the SCENARIO construct of catch2,
which allows sharing a setup phases between different unit tests, and removes a bunch of repeated LOC in our case.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
Jason Dellaluce
71ca58cebd test(userspace/engine): port unit tests for evttypes resolver from linsinsp
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-19 16:29:40 +02:00
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