Commit Graph

4026 Commits

Author SHA1 Message Date
Jason Dellaluce
f7b662f936 update(cmake): bump libs and driver version to 6599e2efebce30a95f27739d655d53f0d5f686e4
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-25 16:32:15 +02:00
Jason Dellaluce
45bf4db077 fix(cmake/libs): enforce using bundled re2
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-25 16:32:15 +02:00
Jason Dellaluce
a8353307c7 update(cmake): bump libs and driver version to 2433c822e1c3ed55f6528c18a27373a677ce76af
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-25 16:32:15 +02:00
Jason Dellaluce
6db7353264 update(tests/engine): sync ast structs to new libs definitions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-25 16:32:15 +02:00
Jason Dellaluce
d35dba30ed update(userspace/engine): sync ast structs to new libs definitions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-25 16:32:15 +02:00
Ian Robertson
8872f256f6 Support multiple URLs for DRIVERS_REPO environment variable (comma separated)
Signed-off-by: Ian Robertson <ian.robertson@wpengine.com>
2022-08-24 18:25:10 +02:00
Ian Robertson
c40a216434 Identify DRIVER_VERSION and ARCH by storing in their proper directories
Signed-off-by: Ian Robertson <ian.robertson@wpengine.com>
2022-08-24 18:25:10 +02:00
Andrea Terzolo
3e3a380702 update(CI): do not check hidden files with codespell
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2022-08-23 16:29:05 +02:00
Andrea Terzolo
5e65e195ae fix(CI): codespell should ignore ro word
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-23 16:29:05 +02:00
Andrea Terzolo
02fce93d02 update(CI): remove release branches from the push event
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:55:05 +02:00
Andrea Terzolo
6051f2de81 update(CI): build Falco to run CodeQL Analysis
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-23 15:55:05 +02:00
Andrea Terzolo
9359db904b update(CI): remove python from languages
we use python only in out tests

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-23 15:55:05 +02:00
Andrea Terzolo
4c3b797003 update(CI): remove codeQL schedule option
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-23 15:55:05 +02:00
Andrea Terzolo
8259a2cd5f new(CI): add CodeQL security scanning to Falco.
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Co-authored-by: Chris Aniszczyk <caniszczyk@gmail.com>
2022-08-23 15:55:05 +02:00
Jason Dellaluce
e7502431a2 update(userspace/falco): move rate limiter out of falco outputs framework
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Jason Dellaluce
bec103de1a docs(falco.yaml): improve rate limiter config docs
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Jason Dellaluce
6c74aa1a29 update(userspace/falco): enable per-event-source rate limiter
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Jason Dellaluce
af0b624a3a fix(userspace/falco): set alert throttling config defaults
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Jason Dellaluce
8760f04bf2 refactor(userspace/falco): make output framework explicitly thread-safe
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Jason Dellaluce
88494d1412 update(falco.yaml): disable alert throttling by default
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-23 15:52:05 +02:00
Mark Stemm
8e61e46016 Add an "Ok, with warnings" overall status.
In outputs it could be confusing to see a line:

<filename>: Ok

followed by a set of warnings.

To differentiate this, add a top level status "Ok, with warnings" when
rule loading was successful but had warnings.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-19 11:55:43 +02:00
Mark Stemm
3c7b6e037a Falco engine changes to support multiple files in rule load results
The methods that throw exceptions from stringified results need to
additionally pass a rules_contents_t struct. This also meant that they
need to call the filename + content version of load_rules.

To avoid some duplicate code between the two load_rules_file methods,
move the work of opening the file into a private method
read_file(). It can throw an exception, which is passed through for
the void return method and caught + converted into a load_result error
for the method that returns a load_result.

Also, to avoid duplicate code between the void load_rules and
load_rules_file methods, add a private method interpret_load_result()
which throws an exception if the result has an error and prints
warnings otherwise if verbose is true.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-19 11:55:43 +02:00
Mark Stemm
49b7f0474f Falco application changes to support multiple files in rules results
Application changes to support multiple files when stringifying rules
results:

- In both validate_rules_files and load_rules_files, instead of
  loading each file individually and then calling load_rules(), add a
  separate step that loads all the files at once. The actual rules
  content strings are held in a vector. The map from filename to
  content (reference) points to entries in that vector.

- Both actions do the same work for this step, so put the
  implementation in a shared application template method read_files
  that works on iterators. It uses itertors because the load filenames
  are a list and the validate filenames are a vector.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-19 11:55:43 +02:00
Mark Stemm
98c1e3d3f1 Restructure rules result to properly support multiple files
The old version of rules_result assumed that all errors/warnings were
related to a single file. That was generally correct for errors, as
rules parsing always stopped at the first error, so there is only one
relevant file.

However, for warnings that was not the case. When reading multiple
files A and B, you might get a warning from file A *only* after
reading file B. For example, B might redefine a rule in such a way
that you could get unused list/macro warnings from file A.

To properly address this, make some changes to how contexts are
managed:

- Instead of creating snippets at the time the error/warning was
  generated, create snippets at the time the error/warning is
  converted into a string. This requires passing all rules contents to
  as_string()/as_json(), so define a
  falco::load_result::rules_contents_t map from filename to rules
  content (reference) and pass it in as_string/as_json(). Snippets are
  now generated from the rules content matching the filename in the
  context.
- When creating warnings/errors, there's no need to pass along the
  rules content. This is only used when converting an error into a
  string/json.

Also change snippet() to handle potentially very long lines. Instead
of always printing the entire line matching a location, print up to
snippet_width(param, with default 160 chars)/2 characters surrounding
the column from the location.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-19 11:55:43 +02:00
Melissa Kilby
0828296abc cleanup(rules): cleanup rules disabled by default - 2
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2022-08-17 10:55:14 +02:00
Andrea Terzolo
6971ed2dce update(PR-template): restore release-note
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2022-08-11 10:32:21 +02:00
Andrea Terzolo
be10b1f8cb update(PR-template): add some area/kind to the template
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-11 10:32:21 +02:00
Andrea Terzolo
1efea20f57 update(PR-template): set NONE as default release-note
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-11 10:32:21 +02:00
Mark Stemm
fefd23f2f1 fix: print full rule load errors without verbose/-v
The latest released falco always prints full details on errors when
used with -r (read rules)/-V (validate rules). However #2098 changed
this to only print full details when verbose is true.

Fix the regression by always printing errors when loading
rules. Warnings will be printed only with -v.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-10 14:39:17 +02:00
Andrea Terzolo
2a640daf13 update(docs): changelog for version 0.32.2
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-09 12:13:11 +02:00
Melissa Kilby
0ab66c6fb5 update(userspace/falco): rename some buffer kernel side event drop metrics, add comments
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2022-08-08 10:28:42 +02:00
Melissa Kilby
1588f37788 update(userspace/falco): extend buffer kernel side event drop metrics
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2022-08-08 10:28:42 +02:00
incertum
66af8ad52b new(userspace/falco): extend ebpf buffer kernel side event drop metrics
Signed-off-by: incertum <melissa.kilby.oss@gmail.com>
2022-08-08 10:28:42 +02:00
Andrea Terzolo
ff247f922d chore(test/utils): remove unused script
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-05 17:56:28 +02:00
Melissa Kilby
e9ba5d751f cleanup(rules): cleanup rules disabled by default
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
2022-08-05 14:50:28 +02:00
Andrea Terzolo
c81f3fc87e docs(falco-driver-loader): add some comments in falco-driver-loader
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-05 11:36:28 +02:00
Mark Stemm
a37e2252b2 Update tests to use result struct + json-based validation
Update tests that validated rules files (typically looking for
errors/warnings) to use the new result struct + json based validation:

- When validating rules files, always use json output.

- In test cases, instead of parsing stderr/stdout, use new test
  properties "validate_ok", "validate_errors",
  "validate_warnings". These parse the json output and look for
  specific tuples of (error code, error message, item type, item name)
  in the output.

- There were a few tests that were actually validation tests but using
  the -r argument to load rules. Convert them to validation tests. In
  one case, split the test into two separate tests--one for
  validation, one ensuring that the rule doesn't match anything.

- There were a couple of tests that were duplicates of existing
  validation tests, just checking for the error in a different
  way. Remove them.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
550cdbd176 Falco application changes to support rule loading result struct
Update the load_rules_files and validate_rules_files actions to use
the new falco_engine methods that return a rules result struct. The
app action interface is the same, returning ::fatal on error,
ok()/exit() otherwise. The difference is how any warnings/errors are
obtained--from the struct instead of an exception.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
f7f6d72ac0 Rule loader changes to support result objects
Changes to the rule loader to support result objects:

- Instead of throwing falco_exception on internal error, throw a
  rule_load_exception instead, which contains distinct
  error/message/context information.

- A context object contains a chain of location structs chaining from
  the document root to the object where the error occurred. Each
  location has a file position (as a YAML::Mark), an item
  type (e.g. "rule", "list", "exception"), and an item name (e.g. "Write
  Below Etc"). This will allow showing the exact location of an
  error (e.g. list item/exception field) while also remembering the item
  that contained it.

- All the _info structs now contain a context so errors that occur
  after yaml parsing can still point to the original location in the
  yaml file.

- rule_loader::result is an implementation of the abstract class
  defined in falco_load_result. The implementation keeps track of a
  list of errors/warnigns that used to be in the configuration object,

- Clean up compile_ methods to just throw rule_load_exceptions or
  return nothing, and ensure that all rule_load_exceptions are caught in
  compile(). When caught, errors are added to the result object.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
cbe7cceb87 Modify rule reader to use a result struct
Modify rule reader to use a result struct for errors and warnings:

- Instead of throwing a falco_exception to pass back errors, use a
  rule_load_exception, which contains distinct error codes, messages,
  and a context that points to the location of the error.

- The static method context_yaml_get_context() has moved to a method
  of the rule_loader context object + the result as_string() method.

- As objects are parsed, create relevant context objects as reading
  drills down into the contents of a rule/list/exception. This will
  enable for specific errors in, say, the middle of an exception/list
  while remembering the object that contains it.

- Modify decode_val()/decode_seq() to always return errors as
  exceptions. Previously, it was a mix of a bool return + some
  exceptions.

- decode_val()/decode_seq() are now more consistent about returning
  distinct errors for the property not existing, the property existing
  but not being a scalar/sequence value, and not being convertable to
  the templated value.

- Combine the two nearly identical decode_seq() functions into a
  single one that uses a lambda to perform the final step of adding to
  the vector/set.

- There are some item-specific decode_xxx functions for specific
  item properties like tags, exceptions fields/comps/values, etc.
  that call the above functions.

These changes simplify the calls to decode_seq()/decode_val() as they
don't need to add their own errors when returning false. Also some
calls weren't checking the return value.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
bb44d992ab Change filter_warning_resolver to use warning codes
Now that we have a result struct and set of warning codes, change the
filter_warning_resolver to use them. This involves populating a set of
warning codes instead of strings.

Also, the methods to format warnings into human-readable strings is
now in the falco_load_result static methods, so move the text there
and remove the methods here.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
0066ba49ea Falco engine changes to support load_rules result class
Add new load_rules methods that return a result object instead of
throwing exceptions on error. The existing load_rules methods call the
new methods internally and continue to throw exceptions on
error/return individual values on success.

The result is returned as a unique_ptr so it can be populated while
loading rules (as a part of the configuration object) and then move()d
to the return value.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Mark Stemm
8497f25a43 Add a load result interface for use in new load_rules methods
Define a falco_load_result abstract class for use in new load_rules
methods. It's abstract so the implementation details in
rule_loader/rule_reader can be hidden from someone who wants to use
the API to load rules and work with a result.

The class defines a set of error codes/warning codes and has static
methods to get a short and long description of each error/warning.

There are virtual methods to access the important parts of a result:
 - successful or not
 - a string representation of the result, suitable for display to
   users. Takes a verbose argument. When verbose is true, the string is
   multi-line and has full details, including locations, item names,
   etc. When verbose is false, the string is single-line and just
   returns error codes.
 - a json representation of the result, suitable for automated
   parsing/interpretation later.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-08-04 14:49:23 +02:00
Andrea Terzolo
6b7be38e41 test: update a comment
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-04 11:47:22 +02:00
Andrea Terzolo
9d443685ea new(userspace): support SCAP_FILTERED_EVENT return code
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
2022-08-04 11:47:22 +02:00
Jason Dellaluce
928d3225b9 fix(cmake): force using bundled valijson
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-03 15:58:21 +02:00
Jason Dellaluce
a531e8b3ed fix(test): use old event versions in trace tests
Co-authored-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-03 15:58:21 +02:00
Jason Dellaluce
07fde46e7c fix(test): sync plugin tests to new plugin loader errors
Co-authored-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-03 15:58:21 +02:00
Jason Dellaluce
136b528849 fix(tests): index old version of events in rulesets
Co-authored-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-03 15:58:21 +02:00
Jason Dellaluce
a46cbcffe8 fix(engine): index old version of events in rulesets
Co-authored-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-08-03 15:58:21 +02:00