Commit Graph

2302 Commits

Author SHA1 Message Date
Lorenzo Fontana
abc79fb548 update(rules): revert exceptions in default ruleset
Exceptions have been introduced in commit 64a231b962
The feature itself is very useful for more complex environments where
the simple conditions are difficult to handle.
However, many users reported that they find them difficult to understand so
we are doing a rollback of them in the default ruleset in favor of the
syntax without exceptions.

Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-04-09 18:17:11 +02:00
Leonardo Grasso
b6fc44e304 build(.config): pin awscli version
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-09 14:29:24 +02:00
Mark Stemm
f14b37984c Add test for some containers being privileged
Add a test that verifies that a pod where one container has no security
context and the second container has a security context + privileged
properly matches the Create Privileged Pod falco rule.

There's a very similar test case already in
trace_files/k8s_audit/create_nginx_pod_privileged_2nd_container.json,
but in that case both containers have a securityContext property.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-04-09 10:34:48 +02:00
Mark Stemm
ecccb9f26c Extract array miss as "no value" vs failed extract
While testing, I found a case when creating a pod where:
1) the first container had no securityContext value
2) the second container had a security context with privileged=true

and this did not match the default rule Create Privileged Pod, when it
should match.

The rule Create Privileged Pod uses the field
ka.req.pod.containers.privileged, which in turn uses
json_event_filter_check::def_extract(). def_extract() iterates
over a set of json_pointers, potentially expanding arrays as they are
returned. Many k8s audit fields use this extract function.

For ka.req.pod.containers.privileged, the first json_pointer is
/requestObject/spec/containers to find the list of containers, and the
second is /securityContext/privileged to extract the privileged property
out of the securityContext object. What's returned is an array of
true/false noting if each container is privileged.

The problem is that def_extract() aborts when iterating over arrays if
extracting a pointer from an array can't be done.

In this case, the first pointer extracts the array of containers, and
then when iterating over the array of containers, the security context
pointer doesn't extract, causing the whole filter field to abort and
return ::no_value.

The fix is to not abort when iterating over arrays, but use ::no_value
for that array item's value instead. This allows def_extract() to
extract the privileged value out of the second container.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-04-09 10:34:48 +02:00
Lorenzo Fontana
f4ff2ed072 chore(test): replace bucket url with official distribution url
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-04-09 10:23:42 +02:00
Santi Friquet
23213ae148 adding asapp as an adopter
Signed-off-by: Santi Friquet <friquet@gmail.com>
2021-04-08 21:28:35 +02:00
Leonardo Di Donato
04110b0f4c chore(scripts): restore mount of debugfs (notes below)
This is needed in systems where raw tracepoints are not available.

Anyways, since this is needed when the inspector open (and actually
loads) the eBPF probe, ideally the mount should not be done by this
script but rather from Falco, or from Falco libs.

Otherwise, users building the eBPF probe theirseleves and not using this script (and having a kernel without raw
tracepoints) may need to mount this fs theirselves.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Leonardo Di Donato
17ee409ac6 chore(scripts): better default values in the help message of falco-driver-loader
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Leonardo Di Donato
71b2b5adde chore(scripts): remove banner about BPF JIT kernel config option
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Leonardo Di Donato
75261d4518 update(scripts): look for a prebuilt Falco eBPF probe before trying to compile one
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Leonardo Di Donato
2a7b32e279 update(scripts): look for a prebuilt Falco module before trying to compile it on-the-fly
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Leonardo Di Donato
4b0333cc08 update(docker/falco): SKIP_MODULE_LOAD not supported anymore - use SKIP_DRIVER_LOADER
When we started to implemented 20200506-artifacts-scope-part-2 proposal
, among a million other things, we renamed `SKIP_MODULE_LOAD` to
`SKIP_DRIVER_LOADER`. We reatained compatibility with `SKIP_MODULE_LOAD`
for a bunch of releases.

Now, after 9 months have passed I think it's time to completely
deprecate it.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-04-08 20:40:39 +02:00
Lorenzo Fontana
cdeafa6fdc docs(test): express that grpcurl and virtualenv are needed
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2021-04-08 17:32:02 +02:00
Leonardo Grasso
36378371ab update(test): update performance tests fixture URL
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-08 12:36:09 +02:00
Leonardo Grasso
aeca36bdaf update(test): update regression tests fixture URL
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-08 12:36:09 +02:00
Leonardo Grasso
7998560dcb chore(README): correct comments
Applying suggestions from https://github.com/falcosecurity/falco/pull/1577

Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-07 16:45:50 +02:00
Leonardo Grasso
c587fadbce chore(scripts): typos
Applying suggestions from
https://github.com/falcosecurity/falco/pull/1577

Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-07 16:45:50 +02:00
Leonardo Grasso
9e50e87ebc chore: remove "cleanup" script and job
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-04-07 16:45:50 +02:00
Mark Stemm
3da5dfa67b Properly parse numbers in condition fields
Falco won't properly parse a rule like this:

---
- rule: Some Rule
  desc: Some Desc
  condition: evt.type=execve and container.image.repository = 271931939120.dkr
  output: Some output
  priority: INFO
---

This is the error when validating the rules:

Tue Mar 30 12:00:40 2021: Validating rules file(s):
Tue Mar 30 12:00:40 2021:    /home/mstemm/test.yaml
1 errors:
Compilation error when compiling "evt.type=execve and container.image.repository = 271931939120.dkr": 63: syntax error, unexpected 'dkr', expecting 'or', 'and'

The parsing of the string on the right hand side stops at the period
before the dkr. The dkr then doesn't match the grammar, resulting in the
error.

Looking at the parser implementation more closely, the problem is in the
definition of "Number":

---
-   Number = C(V "Hex" + V "Float" + V "Int") / function(n)
          return tonumber(n)
       end,
---
Note that it stops after the number, but does not have any requirement
about what follows.

This changes the definition of number to require that what follows the
number is not an identifier character. With this change, values that are
only numbers are parsed as numbers, and values that start with numbers
don't match the Number definition and are parsed as BareStrings instead.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2021-04-07 16:43:44 +02:00
Leo Di Donato
8c9d4f49d5 fix(falco/test): bump pyyaml from 5.3.1 to 5.4
CVE-2020-14343 affects one of the dependencies the Falco (integration) test suite uses.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-30 14:47:01 +02:00
Leonardo Grasso
f2c12bbf9c fix(.circleci): tar must be present in the image
Since `amazon/aws-cli` does not include the tar util (which must be present in the image, as per CircleCI requirement) we are switching from `amazon/aws-cli` to `centos`.

See
https://app.circleci.com/pipelines/github/falcosecurity/falco/1391/workflows/c1e1bc39-f008-4644-b8bf-45d1105e1978/jobs/11263

Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-29 11:50:09 +02:00
Leonardo Grasso
0b69f210c4 fix(.circleci): correct job dependency
The `publish/packages-deb-dev` failed because it wrongly required `tests/integration-static` (that has `/build-static` and `/source-static`) instead of `tests/integration` which comes with both `/build` and `/source`.

Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 18:31:11 +01:00
Leonardo Grasso
002a2e34dd fix(.circleci): tar package is required by circleci
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 18:31:11 +01:00
Leonardo Grasso
ef75c63e63 chore(scripts): print versions at the beginning
Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 14:54:53 +01:00
Leonardo Grasso
fb126cb730 feat(scripts): --clean option for falco-driver-loader
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 14:54:53 +01:00
Leonardo Di Donato
645f51b296 new(scripts): falco-driver-loader know the Falco version it has been
built for

Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-26 14:54:53 +01:00
Leonardo Di Donato
d912cf0d94 docs(scripts): falco-driver-loader outputs the Falco version it has been built for, also the driver version in use
Both in the help/usage message and at running time.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-26 14:54:53 +01:00
Leonardo Di Donato
3f75f27410 docs(scripts): improve help of falco-driver-loader script
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-26 14:54:53 +01:00
Leonardo Di Donato
1504e77f4e update(scripts): falco-driver-loader can now start with a custom driver name
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-26 14:54:53 +01:00
Leonardo Grasso
40edfe66ba fix(docker/no-driver): handle urlencoding
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
f800d4a101 docs: update links and badges for download.falco.org
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
4f1a2418fe build(.circleci): publish packages to S3
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
442011d07e build(.circleci): publish dev packages to S3
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
70ee1093d8 build(docker): fetch packages from download.falco.org
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
3936740390 build(scripts): add cloudfront invalidation for publishing scripts
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
9bc04fd02d build(scripts): publishing script for DEBs
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
b6ac6de227 build(scripts): publishing script for RPMs
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
Leonardo Grasso
5ebb653977 build(scripts): publishing script for bin packages
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2021-03-26 12:55:11 +01:00
stevenshuang
167c5bc691 fix: update rule description
Signed-off-by: stevenshuang <stevenshuang521@gmail.com>
2021-03-24 18:47:55 +01:00
Leonardo Di Donato
1ded30f173 update(test): tighten the condition to test the drops thresholds
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
7edd965a08 fix(test/confs): drop log messages are debug, fix the test fixture accordingly
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
920ab6982a new(test): test cases about wrong threshold drop config value
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
3842e07422 update(userspace/falco): drop messages are DEBUG level
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
7bc5fcf047 fix(userspace/falco): validate the drop threshold config value
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
199a1c22c6 fix(userspace/falco): n_evts does not containd the dropped events count
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
5380fe5308 new(test): test case about illogical drop actions
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
e3f7cdab20 update(userspace/falco): pass to sdropmgr the threshold
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
1714926cc6 update(userspace/falco): reduce noisiness
The threshold governs the noisiness of the drops.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
4774e92bc2 refactor(userspace/falco): refactor the enum of drop actions into an enum class
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00
Leonardo Di Donato
a1b58d70a7 update(userspace/falco): grab the threshold configuration value + do not allow the ignore action to work with any other except the exit one
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2021-03-22 19:42:30 +01:00