Commit Graph

22 Commits

Author SHA1 Message Date
Jason Dellaluce
5ddc8e20f4 test(userspace/engine): adapt test_rulesets to new definitions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-05-25 09:16:45 +02:00
Jason Dellaluce
a16eac221e refactor(userspace/engine): apply C++ best practices to newest engine classes
This include making a coherent use of const, remove private inheritance, and adding virtual destructors.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-04-27 16:22:59 +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
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
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
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
Leonardo Grasso
a4199814a0 fix(tests/engine): correct unit tests
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2022-01-28 15:33:22 +01:00
Jason Dellaluce
2ee0645f25 update(tests): remove token_bucket unit tests
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-01-04 16:41:18 +01:00
Mark Stemm
10d47cb1f5 Update automated tests to reflect evttypes behavior
With the changes in https://github.com/falcosecurity/libs/pull/74,
there isn't any need to warn about the order of operators and the
evt.type field--the set of event types for a filter should be exact
now regardless of the order of operators.

So update tests that were logging those warnings to note that the
warnings won't occur any more.

Also, some tests more accurately *do* note that they have an overly
permissive evttype (e.g. ones related to syscalls, which are uncommon
and are evaluated for all event types) to reflect the new behavior.

Finally, in unit tests create an actual sinsp filter instead of a
gen_event_filter, which is the base class and shouldn't be created
directly.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-10-12 17:59:38 +02:00
Mark Stemm
044a7c153e Don't track event "tags" i.e. event types in rulesets
Modify rulesets to not keep track of the event types for a given set
filter. Instead, using the changes in
https://github.com/falcosecurity/libs/pull/74 event types are returned
directly by the filter.

Within each ruleset, there's a vector that maps from event number to
set of filters that are related to that event number. There's also a
general set of filters for all event types.

run() both indexes into the per-event vector as well as iterate over
the all event types set.

Also, used shared_ptr instead of direct pointers, which matches the
updated interface used by lua_parser. This simplifies the bookkeeping
a bit (no more delete when removing rulesets).

Given these changes, there's no need for a separate
falco_sinsp_ruleset class any longer, so remove it.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-10-12 17:59:38 +02:00
Leonardo Di Donato
d808c0aeaf update(tests/engine): test is_unix_scheme
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-05-21 18:15:46 +02:00
Lorenzo Fontana
2680a459ec new(tests/engine): update socket path
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2020-05-21 18:15:46 +02:00
Lorenzo Fontana
05ce5b7f0b new(tests): cases for falco::utils::starts_with
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2020-05-21 18:15:46 +02:00
Mark Stemm
8adcc95bac Add unit tests for ruleset handling
A new unit test file test_rulesets adds tests for the following:

 - enabling/disabling rules based on substrings
 - enabling/disabling rules based on exact matches
 - enabling/disabling rules based on tags

There are variants that test for default and non-default rulesets.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-11 14:15:42 +02:00
Mark Stemm
176d6f2bfe Make token bucket unit test pass valgrind
Previously, valgrind was complaining about the leaked token bucket.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-11 14:15:42 +02:00
Lorenzo Fontana
c76518c681 update: license headers
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-10-08 16:02:26 +02:00
Lorenzo Fontana
b2ef08fd30 chore: clang format following the current style
Signed-off-by: Lorenzo Fontana <lo@linux.com>

Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-03 09:07:00 +02:00
Leonardo Di Donato
08454dfa53 new: test token bucket declaration triggers the default init
Co-Authored-By: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-02 17:52:29 +02:00
Leonardo Di Donato
71b2fe6e14 update: token bucket tests
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-02 17:52:29 +02:00
Leonardo Di Donato
815f5d8714 new: test token bucket
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-02 17:52:29 +02:00
Leonardo Di Donato
11838548df build: includes for tests
Co-Authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-02 17:52:29 +02:00