Commit Graph

2071 Commits

Author SHA1 Message Date
Mark Stemm
dbd4ff08eb Rules changes (WIP)
Got as far as the two big rules (write below etc/write below
root). Still need to do the rest, and also k8s_audit.
2020-10-13 17:36:36 -07:00
Mark Stemm
9c70ae19be Squash w/ code commit: single field 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, ...)".
2020-10-13 11:20:32 -07:00
Mark Stemm
9cb25be5bd Squash w/ test commit. 2020-10-13 11:20:12 -07:00
Mark Stemm
1f533e5964 Bump falco engine version to 8 for exceptions.
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-12 15:46:54 -07:00
Mark Stemm
854318cacf Allow lists/list names to be exception values
Allow lists or list names to be exception values. The list is expanded
if directly included as a values item. If it's just a string, it's
assumed to be a list name. Parentheses are added if needed but otherwise
the list expansion is done when compiling the condition string.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-12 15:43:23 -07:00
Mark Stemm
0cc10b0fbe Tests for exceptions using lists.
Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-12 15:43:02 -07:00
Mark Stemm
e3f1ac1be3 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>
2020-10-09 13:27:53 -07:00
Mark Stemm
fb4e07e220 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>
2020-10-09 13:27:46 -07:00
Mark Stemm
9014153d7b 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, 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, quote it in the string

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-09 13:20:10 -07:00
Mark Stemm
0bb6addcc0 Update tests to add error counts
When validating, the output has a summary of error/warning counts, so
update tests appropriately.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-05 09:03:30 -07:00
Mark Stemm
3aa8ff6e84 Allow unknown top level obs 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>
2020-10-05 09:03:27 -07:00
Mark Stemm
a4b7d46717 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>
2020-10-05 09:03:23 -07:00
Leonardo Di Donato
0a449afc3e docs: fix release notes for 0.26.0 (previous)
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
0.26.1
2020-10-01 14:19:48 +02:00
Leonardo Di Donato
e06e89b3d0 docs: CHANGELOG for 0.26.1
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-10-01 14:19:48 +02:00
Leo Di Donato
1500e74844 docs: release candency
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
2020-10-01 13:41:55 +02:00
Leonardo Di Donato
db9fe762a4 docs: notify the community the Falco releases happen every two months starting from today
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-10-01 13:41:55 +02:00
Leo Di Donato
2fd9ad1433 docs: add download/images table to release corpus template
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-10-01 13:41:55 +02:00
Mark Stemm
879bf37ffd rule(Write below root): require proc.name
Like other rules that rely on a process name for exceptions, don't
trigger an event if the process name is missing e.g. "<NA>".

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-01 11:33:45 +02:00
Mark Stemm
fc4355dd15 rule(Delete....shell history): Skip docker progs
Also ignore docker programs which would prevent cases where the path is
expressed within the container filesystem (/.bash_history) vs host
filesystem (/var/lib/docker/overlay/.../.bash_history).

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-01 11:33:45 +02:00
Mark Stemm
1c7fca95e4 rule(Delete or rename shell history):fix warning
Move the "and not" checks to the end of the rule so all event type
checks are at the front.

Also break into 3 macros to make the rule easier to read.

This fixes https://github.com/falcosecurity/falco/issues/1418.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-10-01 11:33:45 +02:00
Radu Andries
bc1aeaceb2 feat(falco): Provide a parameter for loading lua files from an alternate path
This will be used by the static build to load lua files from
alternate directories that are not tied to the compile flags

Signed-off-by: Radu Andries <radu.andries@sysdig.com>
2020-09-29 18:05:10 +02:00
Lorenzo Fontana
6bcc11aa47 build: standalone static analysis step
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
2020-09-29 14:44:28 +02:00
Lorenzo Fontana
bbf044060a build: quality, install ca-certificates and attach only after that
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
2020-09-29 14:44:28 +02:00
Lorenzo Fontana
4f86e3e68b build: static code analysis CI reports
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
2020-09-29 14:44:28 +02:00
Lorenzo Fontana
a51c4fc903 build: static code analysis structure and cppcheck
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
2020-09-29 14:44:28 +02:00
Leo Di Donato
271e23ce97 docs(brand): documenting Falco color scheme
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-28 15:15:36 +02:00
Kris Nóva
404762bd34 feat(release): Updating notes according to PR
Signed-off-by: Kris Nóva <kris@nivenly.com>
0.26.0
2020-09-25 08:18:48 -07:00
Kris Nóva
20f5e5d35a feat(release): Release 0.26
Cutting release for 0.26.0 and starting 0.27.0

Signed-off-by: Kris Nóva <kris@nivenly.com>
2020-09-25 08:18:48 -07:00
Mark Stemm
33793d233b Rule(Disallowed K8s User): quote colons
It turns out if you read this rules file with falco versions 0.24.0 and
earlier, it can't parse the bare string containing colons:

(Ignore the misleading error context, that's a different problem):

```
Thu Sep 10 10:31:23 2020: Falco initialized with configuration file
/etc/falco/falco.yaml
Thu Sep 10 10:31:23 2020: Loading rules from file
/tmp/k8s_audit_rules.yaml:
Thu Sep 10 10:31:23 2020: Runtime error: found unexpected ':'
---
  source: k8s_audit
    tags: [k8s]
    # In a local/user rules file, you could override this macro to
```

I think the change in 0.25.0 to use a bundled libyaml fixed the problem,
as it also upgraded libyaml to a version that fixed
https://github.com/yaml/libyaml/pull/104.

Work around the problem with earlier falco releases by quoting the colon.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-23 17:48:36 +02:00
Mark Stemm
331b2971be rule(Delete or rename shell history):skip dockerfs
In some cases, when removing a container, dockerd will itself remove the
entire overlay filesystem, including a shell history file:

---
Shell history had been deleted or renamed (user=root type=unlinkat
command=dockerd -H fd://
... name=/var/lib/docker/overlay2/.../root/.bash_history ..
---

To avoid these FPs, skip paths starting with /var/lib/docker.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-23 17:48:36 +02:00
Leonardo Grasso
558b18ea67 build: update the driver version to 2aa88dc
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-09-18 17:27:45 +02:00
Leonardo Grasso
bbfb27777b build: remove macrodefs about time (musl build)
See https://github.com/draios/sysdig/pull/1684

Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-09-18 17:27:45 +02:00
Hiroki Suezawa
5b926386a8 rule(macro consider_packet_socket_communication): change a value to always_true
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2020-09-18 09:47:10 +02:00
Lorenzo Fontana
1efa4d3af0 update(scripts): driver loader cycle available gcc versions
The falco-driver-loader script calls dkms to compile the kernel
module using the default gcc.
In some systems, and in the falcosecurity/falco container image,
the defult gcc is not the right one to compile it.

The script will try to compile the module by cycling trough all the available GCCs
starting from the default one until the module is compiled the first
time.

The default gcc is the highest priority while trying.
Newer GCCs have the priority over older GCCs.

Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <fontanalorenz@gmail.com>
2020-09-16 18:09:09 +02:00
Leonardo Di Donato
8611af4373 chore(.circleci): re-enable cleanup of falco development packages only when on the master branch
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-14 11:09:09 +02:00
Leonardo Di Donato
b6fd43f4db update(.circleci): update CI references to cleanup script
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-14 11:09:09 +02:00
Leonardo Di Donato
2971d0de7f fix(scripts): move cleanup (falco development packages) into scripts dir
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-14 11:09:09 +02:00
Leonardo Grasso
d2dbe64723 update: bump Falco engine version to 7
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-09-13 22:54:00 +02:00
Leonardo Grasso
66309e3a1f build(.circleci): fix static build path
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-09-11 14:52:30 +02:00
bgeesaman
cb2439d757 Append Slash to Sensitive Mount Path startswith
Make L#1932 equivalent to L#1898

Signed-off-by: Brad Geesaman <bradgeesaman+github@gmail.com>
2020-09-11 14:50:28 +02:00
Leonardo Di Donato
f02a998526 build: update the driver version to 73554b9
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
d1ee7d3d79 chore(.circleci): re-enable the usual falco-tester docker image for CI
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
0586a7d33c update(docker/no-driver): use the statically linked falco tarball
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
e0f0db96d3 build(rules): fix rules etc dir
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
045cb4a45d build(.circleci): specify falco etc directory for musl build
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
4319f16fa6 build: publish musl artifacts
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
c2603c0130 new(.circleci): test the minimal build
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
5316e39379 chore(cmake/modules): correct logging for string-view-lite (always) bundled header dependency
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
9a29203a4d build: engine fields checksum only when not building the minimal Falco
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Leonardo Di Donato
7e28e305a6 deps: update driver version
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00