Commit Graph

2552 Commits

Author SHA1 Message Date
Jason Dellaluce
7fb61ba4a3 refactor(engine): access config fields with new key syntax
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-12-06 19:04:15 +01:00
Jason Dellaluce
9ab810f431 update(engine): support accessing nested config fields
Since now, the maximum depth supported to access config fields is two.
This adds support for accessing fields of arbitrary nesting depth.
A formal grammar has been explicited for the regular language representing
the field keys. The accessor methods have been updated accordingly.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-12-06 19:04:15 +01:00
Jason Dellaluce
7781385769 refactor(engine): support string config loading and add ad-hoc methods
This is a change of direction from the current design, that imposes loading
the configuration from file only, and in the object constructor. Instead,
yaml_configuration objects can now be reused ad can load the YAML config
from either file or string. This also makes it easier to unit test this class.

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-12-06 19:04:15 +01:00
Erick Cheng
205a8fd23b Move wget and curl to own rule
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
bdba37a790 Fix remove scp and add curl
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
19fb3458ef Add wget and curl to remote_file_copy_binaries
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
b0565794f5 Move user_known_ingress_remote_file_copy_activities to outside condition
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
66df790b9d Fix syntax error
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
749d4b4512 Add more curl download checks
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
851033c5f4 Add curl macro
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
af6f3bfeab Move wget and curl to own rule
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
c4d25b1d24 Fix remove scp and add curl
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Erick Cheng
d434853d5f Add wget and curl to remote_file_copy_binaries
Signed-off-by: Erick Cheng <19863605+ec4n6@users.noreply.github.com>
2021-11-29 17:42:40 +01:00
Jason Dellaluce
4c8e369691 update(build): bump fakeit version
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-22 18:25:44 +01:00
Jason Dellaluce
b15a0458b7 update(build): allow using local libs source dir
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-18 16:26:18 +01:00
Jason Dellaluce
d6cb8bc4bd refactor(build): setting variable defaults according to newest libs version
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-18 16:26:18 +01:00
Jason Dellaluce
2cc7fd9072 update(build): bump libs version
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-18 16:26:18 +01:00
Jason Dellaluce
589829ae2f update(build): remove libscap patch
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-18 16:26:18 +01:00
Jason Dellaluce
85db078dc4 chore: renaming comment references
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-18 16:26:18 +01:00
sai-arigeli
23706da75e Allow append of new exceptions to rules
Signed-off-by: Sai Arigeli <saiharisharigeli@gmail.com>

Return warnings after validation of rule exceptions

Signed-off-by: Sai Arigeli <saiharisharigeli@gmail.com>

Update FALCO_ENGINE_VERSION

Signed-off-by: Sai Arigeli <saiharisharigeli@gmail.com>
2021-11-18 09:11:20 +01:00
Federico Di Pierro
35302f6f09 update(build): update libs to falcosecurity/libs master.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 17:25:24 +01:00
Federico Di Pierro
375a6f66c5 update(build): force using libs-bundled luajit.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-17 17:25:24 +01:00
Federico Di Pierro
e8a243d6ea wip: point to my own library for CI purposes.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 17:25:24 +01:00
Federico Di Pierro
7927f45d9f update(build): dropped Falco local luajit module, use the one provided by libs (upgraded) instead.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-17 17:25:24 +01:00
Federico Di Pierro
d9aff8d564 update(build): switched back to falcosecurity libs on master.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
40e3fdd09c update(build): updated libs.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
ba2323046a fix(build): properly use correct lib/lib64 folder for CIVETWEB_LIB variables.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
5e6f30109e update(build): dropped civetweb patch. Use different ExternalProject_Add when building with bundled openssl or not, to avoid depending on an unexhistent target.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
f3c3de7e05 fix(build): properly share OPENSSL_INCLUDE_DIR and OPENSSL_LIBRARIES vars to civetweb cmake.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
ca61f87682 update(build): civetweb depends on openssl.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
113bb5cdd6 update(build): update falcosecurity libs to use my own libs repo and version to be able to test the build against FedeDP:fix_ssl_1_1_get_all_data branch (not yet merged).
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
8a603c3c5d update(build): latest libs correctly set OPENSSL_LIBRARIES for us.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
0539e948c8 update(build): moved civetweb to its own cmake module. Moved its patch too.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
5f1d04ec82 fix(build): build civetweb using cmake and linking to static openssl built by us.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-17 16:18:23 +01:00
Federico Di Pierro
9d8fc4c8d2 update(build): updated civetweb to version 1.15 to correctly support openssl1.1.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2021-11-17 16:18:23 +01:00
Luca Guerra
09799e125d chore(build): update libs version to 7906f7ec416a8b67b82d92d37b25f28d545bcb8f
Signed-off-by: Luca Guerra <luca@guerra.sh>
2021-11-16 19:02:21 +01:00
Jason Dellaluce
446c65007d test(userspace/engine): add integration test for rules enabled with enabled flag only
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-16 16:37:45 +01:00
Jason Dellaluce
df3728ec3f test(userspace/engine): add integration test for rules disabled with enabled flag only
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-16 16:37:45 +01:00
Jason Dellaluce
a66dda3daa test(userspace/engine): update integration tests to support enabled-only rules
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-16 16:37:45 +01:00
Jason Dellaluce
eec2f5062f update(userspace/engine): allow overwriting rules with enabled flag only
This allows defining rules that simply enable/disable already defined rules, like the following:
- rule: A rule enabled by default
  enabled: false
- rule: A rule disabled by default
  enabled: true

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2021-11-16 16:37:45 +01:00
Federico Di Pierro
7dcf8f4bf7 update(userspace/engine): use s_ prefix for static var.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-16 15:34:12 +01:00
Federico Di Pierro
bea91ca844 fix(userspace/engine): properly constify m_default_ruleset.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-16 15:34:12 +01:00
Federico Di Pierro
ea2ca56d5b style(userspace/engine): avoid creating multiple versions of methods only to assume default ruleset. Use a default argument instead.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-11-16 15:34:12 +01:00
Mark Stemm
cb51522423 Skip plugins list/load/tests for MUSL_OPTIMIZED_BUILD
When MUSL_OPTIMIZED_BUILD is specified, falco is statically linked under
musl, and can't dlopen() files: see
https://inbox.vuxu.org/musl/20200423162406.GV11469@brightrain.aerifal.cx/T/

So skip listing/loading/testing plugins when MUSL_OPTIMIZED_BUILD is specified.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
9f53089bcb Detect strlcpy on the fly (musl libc)
Detect strlcpy on the fly, as was done in https://github.com/falcosecurity/libs/pull/110.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
2a4e4d555d Add automated tests for plugins
Test infrastructure and sample confs/rules/traces for plugins
automated tests:

New test cases are in falco_tests_plugins.yaml and cover:
- Listing plugins and fields when plugins are loaded.
- Basic cloudtrail + json plugin on a fake cloudtrail json file and a
  sample rule that uses both plugins.
- Conflicts between source/extractor plugins
- Incompatible plugin api
- Wrong plugin path
- Checking for warnings when reading rules with unnown sources (e.g. when plugins are not loaded)

Some test-only plugins written in C are in test/plugins and built on
the fly. (They aren't included in packages of course).

The test framework needed some small changes to handle these tests:
- Add a mode to not check detection counts at all (for --list/--list-plugins)
- addl_cmdline_opts to allow specifying --list/--list-plugins
- Using DOTALL when matching stderr/stdout (allows multi-line matches more easily)

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
6a1f4f7374 Plugins support in falco executable
Update the falco binary to add support for plugins.

- Keep track of an "event source", which is initially "syscall" but
  changes to the input plugin's source if an source plugin ends up being
  loaded.

- New argument --list-plugins will return info on any loaded plugins,
  using sinsp_plugin::plugin_infos.

- Create filter/formatter factories for plugins. This ensures that
  filterchecks for syscalls are not used for plugins and vice versa.

- Use sinsp_plugin::register_plugin() to load each plugin found in
  config. The first source plugin found (if any) calls
  engine->add_source withthe source plugin's event source.

- If a second source plugin is found, exit with an error.

- Extractor plugins must be compatible with the event source (usually
  the plugin event source, but could be "syscall"). If not, exit with
  an error.

- Multiple Extractor plugins are allowed, but they can not have
  overlapping compatible event sources. This is mostly to avoid
  confusion, but we might change this later.

- After loading plugins, use engine is_plugin_compatible to ensure
  that the plugin is compatible with any required_plugin_version blocks
  in falco rules.

- Normally falco would log warnings if too many SCAP_TIMEOUT results
  were received. These are more expected when using plugins, so only
  log these warnings when using syscalls.

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Loris Degioanni <loris@sysdig.com>
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
98599d5e25 Plugins support (outputs)
The generic events support already handled most of this, with a
dedicated formatter factory for plugin sources. Just one missing
header include and change the logic slightly for json parsing.

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Loris Degioanni <loris@sysdig.com>
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
e7d41f8166 Rules loading changes for plugins
Rules loading changes for plugins:

 - parse required_engine_versions from yaml and pass up to rules
   loader as a lua table as an additional return value from load_rules().
 - c++ rules loader converts to map: plugin -> list of required plugin
   versions
 - support is_source_valid callback from lua, calls engine method. If
   a source is not valid, skip any rules for that source and add a warning.

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Loris Degioanni <loris@sysdig.com>
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00
Mark Stemm
9075eea62f Falco engine support for plugins
Mostly plugins are just handled as a new filter/formatter factory with
a new source based on the loaded input plugin, but there are a few
changes at the engine level:

- is_source_valid returns whether a filter/formatter factory exists
  for a given source. Will be used by rules loaded to skip rules for
  an unknown source.

- the falco engine now holds the required_plugin_version predicates
  found in rules files and a method is_plugin_compatible returns whether
  a plugin semver is compatible with the predicates in the rules

- Update the falco engine version and fields checksum for plugins

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Loris Degioanni <loris@sysdig.com>
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-11-12 18:27:59 +01:00