Commit Graph

2363 Commits

Author SHA1 Message Date
Mark Stemm
49b8f87db4 Make the req. engine version 8 for k8s_audit rules
These define exceptions too.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
cd8234d8b3 Remove falco_tests.yaml from gitignore
It was renamed from falco_tests.yaml.in in
5bafa198c6.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
e6b0d2697f Use the right not equals operator.
Fix typo, "!" should be "!=".

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
987ececa54 Remove test case for unknown objects.
The rules loader now allows objects with unknown keys.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
7f4afffe3e Remove old unused macros/lists
Remove old macros/lists that aren't being used by any current rules.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
91bfa379ce Properly note lists in other lists as used
If a list:

- list: foo
  items: [a, b, c]

Was referenced in another list:

- list: bar
  items: [foo, d, e, f]

The first list would not be marked as used, when it should.

This avoids mistaken messages like "list xxx not refered to by any rule/macro/list"

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
64a231b962 Add exceptions fields/comps/values to rules files
Take advantage of the changes to support exceptions and refactor rules
to use them whenever feasible:

- Define exceptions for every rule. In cases where no practical
  exception exists e.g. "K8s <obj> Created/Deleted", define an empty
  exception property just to avoid warnings when loading rules.
- Go through all rules and convert macros-used-as-exceptions that
  matched against 2-3 filter fields into exceptions. In most cases,
  switching from equality (e.g proc.name=nginx) to in (e.g. proc.name
  in (nginx)) allowed for better groupings into a smaller set of
  exception items.
- In cases where the exception had complex combinations of fields, keep
  the macro as is.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
7b030727a2 Bump falco engine version to 8 for exceptions.
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
b2eb3ec345 Don't look for event counts with -V/validate
When running falco with -V/valdiate <rules file>, you won't get any
event counts. All prior tests didn't get this far as they also resulted
in rules parsing errors.

However, validating can now result in warnings only. This won't exit but
won't print event counts either.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
b4eb5b87b6 Automated tests for exceptions
Handle various positive and negative cases. Should handle every error
and warning path when reading exceptions objects or rule exception
fields, and various positive cases of using exceptions to prevent
alerts.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
a582599778 Support exceptions properties on rules
Support exceptions properties on rules as described in
https://github.com/falcosecurity/falco/pull/1376.

- When parsing rules, add an empty exceptions table if not specified.
- If exceptions are specified, they must contain names and lists of
  fields, and optionally can contain lists of comps and lists of lists of
  values.
- If comps are not specified, = is used.
- If a rule has exceptions and append:true, add values to the original rule's
  exception values with the matching name.
- It's a warning but not an error to have exception values with a name
  not matching any fields.

After loading all rules, build the exception condition string based on
any exceptions:

- If an exception has a single value for the "fields" property, values are
  combined into a single set to build a condition string like "field
  cmp (val1, val2, ...)".
- Otherwise, iterate through each rule's exception
  values, finding the matching field names (field1, field2, ...) and
  comp operators (cmp1, cmp2, ...), then
  iterating over the list of field values (val1a, val1b, ...), (val2a,
  val2b, ...), building up a string of the form:
    and not ((field1 cmp1 val1a and field2 cmp2 val1b and ...) or
              (field1 cmp1 val2a and field2 cmp2 val2b and ...)...
	     )"
- If a value is not already quoted and contains a space, quote it in the
  string.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
3fb1d207e2 Update tests expected outputs
The format of error responses has changed to include a summary of errors
and/or warnings. This changed many test cases that were looking for
specific outputs.

Update to add counts and other minor formatting changes.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
4f192e89fa Allow unknown top level objs as warnings
When parsing a rules file, if a top level object is not one of the known
types rule, macro, list, required_engine_version, instead of failing
parsing, add a warning instead.

This adds some forwards-compatibility to rules files.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Mark Stemm
07abb89f36 Pass back warnings when loading rules
Add the notion of warnings when loading rules, which are printed if
verbose is true:

 - load_rules now returns a tuple (success, required engine version,
   error array, warnings array) instead of (true, required engine
   version) or (false, error string)
 - build_error/build_error_with_context now returns an array instead of
   string value.
 - warnings are combined across calls to load_rules_doc
 - Current warnings include:
   - a rule that contains an unknown filter
   - a macro not referred to by any rule
   - a list not referred to by any rule/macro/list

Any errors/warnings are concatenated into the exception if success was
false. Any errors/warnings will be printed if verbose is true.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-19 10:37:55 +01:00
Lorenzo Fontana
7691dba3ff fix(userspace/falco): output needs to be initialized after fork
Co-Authored-By: Leonardo Grasso <me@leonardograsso.com>
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 16:56:13 +01:00
Lorenzo Fontana
c736689f6f docs(RELEASE.md): link the ecr images in releases
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 16:52:02 +01:00
Lorenzo Fontana
3bcd2ca70d update(.circleci): fix tag definition for ECR image push on releases
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 15:45:52 +01:00
Lorenzo Fontana
2e443e7660 build(.circleci): temporarly disable static analysis
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 13:15:25 +01:00
Lorenzo Fontana
bec5121fa4 docs(CHANGELOG.md): release notes for 0.27.0
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 13:15:25 +01:00
Lorenzo Fontana
ee0b7daba0 docs(RELEASE.md): remove url, it does not work anymore
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-01-18 13:15:25 +01:00
Leonardo Grasso
b2bbb265b4 chore(cmake): remove unnecessary whitespace patch
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-01-15 14:22:14 +01:00
Leo Di Donato
0d7068b048 docs(.circleci): adding Jonah to Falco CI maintainers
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-13 17:22:41 +01:00
James Barlow
7f33b08634 rule(Create Hidden Files or Directories): Exclude exe_running_docker_save
Signed-off-by: James Barlow <james.barlow@finbourne.com>
2021-01-08 19:21:42 +01:00
James Barlow
c2a05b3e64 rule(Mkdir binary dirs): Exclude exe_running_docker_save
Signed-off-by: James Barlow <james.barlow@finbourne.com>
2021-01-08 19:21:42 +01:00
Leonardo Grasso
581d67fa08 docs(proposals/20200828-structured-exception-handling): indentation
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-01-08 17:53:08 +01:00
Leonardo Grasso
b7bda6d892 docs(proposals/20200828-structured-exception-handling): highlight syntax
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-01-08 17:53:08 +01:00
Mark Stemm
5eec26976d Add notes on single-field exceptions
If an exception item has a single value for fields, all the values are
combined together into a single set to build an expression field
cmp (val1, val2, ...)

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-08 17:53:08 +01:00
Mark Stemm
1916314583 Use well-defined object keys
Instead of oveloading the exception item name as the key of the object,
just have a flat array of object with a name property.

A bit more verbose, but makes it easier to understand what the schema is.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-08 17:53:08 +01:00
Mark Stemm
8831c7f3c7 Add notion of exception operators
A rule exception can now have a comps property that allows fields to be
matched against items using an operator of =. If not defined, equality
is implied.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-08 17:53:08 +01:00
Mark Stemm
2cebe052a1 Address feedback
- Clean up npm examples so they are valid.
- Small punctuation changes.
- Emphasize that the strings related to field values are arbitrary.
- Emphasize that exceptions only use equality matching.
- Emphasize that you'll need to upgrade falco to use these new features.
- Capitalize Falco everywhere.
- Change language related to backwards compatibility.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-08 17:53:08 +01:00
Mark Stemm
05282f3976 Proposal on better exception handling
This proposes adding exceptions as a first class object to falco rules
files.

It adds a new key "exceptions" to rule objects that allows a rule
writer to define tuples of field names that comprise an exception, and a
new top level object "exception" that contains lists of tuples of field
values that define exceptions to rules.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-01-08 17:53:08 +01:00
Leo Di Donato
da4a5b1456 chore(.circleci): typos
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Leo Di Donato
36e9c2ba17 chore(.circleci): switch to falcosecurity slug for AWS ECR registry
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Leonardo Di Donato
0c8b4a2127 chore(.circleci): test out container image publish for a specific Falco development version
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Leonardo Di Donato
356b3e1451 new(.circleci): publish Falco development container images (from master) to AWS ECR Public
Co-authored-by: jonahjon <jonahjones094@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Leonardo Di Donato
9eb60f04ff chore: refinements
Co-authored-by: jonahjon <jonahjones094@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Leonardo Di Donato
ff29188cb2 ci: add job to publish container images to AWS ECR registry
Co-authored-by: jonahjon <jonahjones094@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-01-08 15:50:26 +01:00
Naoki Oketani
4fb7e99c68 docs: fix a broken link of README
Signed-off-by: Naoki Oketani <okepy.naoki@gmail.com>
2021-01-07 14:58:14 +01:00
Spencer Krum
d03a1f4a9b feature(grpc): Add engine version to version svc
Fixes #1269

Add two new fields in the version service for falco's engine version and
the checksum of all of the fields it understands.

This will require rebuilding/re-releasing all the clients.

Signed-off-by: Spencer Krum <nibz@spencerkrum.com>
2020-12-15 11:00:18 -05:00
Leonardo Grasso
574e7f433b docs(README.md): correct broken links
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-12-15 10:58:21 -05:00
Angelo Puglisi
f6fa18e7ec chore(cmake): mark some variables as advanced
Have some cmake variables (e.g. *_INCLUDE and *_LIB) marked as advanced,
in order to have a cleaner ccmake menu.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
2020-12-15 10:56:20 -05:00
kaizhe
6beb9838d6 rule(list user_known_change_thread_namespace_binaries): add crio and multus to the list
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-12-14 04:16:15 -05:00
Angelo Puglisi
9a175cb1db chore(cmake/modules): avoid useless rebuild
Because of https://gitlab.kitware.com/cmake/cmake/-/issues/16419, every
time one compiles, some external projects gets updated causing rebuild.

Have EP_UPDATE_DISCONNECTED option (default OFF) to be able to control
that behaviour.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-12-10 13:28:01 -05:00
Spencer Krum
32daac3e4d fix(config): Error out when no config file supplied
Fixes: #1406

Signed-off-by: Spencer Krum <nibz@spencerkrum.com>
2020-12-10 13:26:04 -05:00
kaizhe
0a901e4f52 add exception macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-12-04 06:21:34 -05:00
kaizhe
22732e9edb rule(Container Run as Root User): new rule created
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-12-04 06:21:34 -05:00
Leonardo Grasso
6a352338e3 update(userspace/falco): output worker should not throw exceptions
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-12-01 04:18:04 -05:00
Leonardo Grasso
f8b66d051b fix(userspace/falco) class naming convention
Co-authored-by: Lorenzo Fontana <fontanalorenz@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-12-01 04:18:04 -05:00
Leonardo Grasso
c237ddc738 chore(userspace/falco): apply suggestions from review
Co-authored-by: deepskyblue86 <angelopuglisi86@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-12-01 04:18:04 -05:00
Leonardo Grasso
9d31164a71 update(userspace/falco): clear output queue if still blocked during the shutdown
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-12-01 04:18:04 -05:00