Commit Graph

472 Commits

Author SHA1 Message Date
Leonardo Di Donato
7a99336b3b chore(userspace/falco): cleanup boot logic for grpc server
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
45df07bc1b update(userspace/falco): use concurrent output queue in grpc server
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
4f23b0bdfb update(userspace/falco): use concurrent output queue in grpc server impl
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
5f29d46cb3 update(userspace/falco/lua): separate events output from messages outputs using different lua functions
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
34a34cecb6 update(userspace/falco): remove format from grpc responses
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
4bdf8495de new(userspace/falco): introducing concurrent queue for falco outputs
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
23000528d4 update(userspace/falco): grab grpc output configuration
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
a53e22d2d5 chore(usperspace/falco): move grpc server impl
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
c3abccb27b build(userspace/falco): prepare grpc server implementation to be moved
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
0bec2607a5 new(userspace/falco): specify that we can have multiple client consuming mechanisms, only round robin fashion is implemented now
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
5abb26e764 new(userspace/falco): handle subscribe events as streams based on keepalive
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
fcc7fad0e7 new(userspace/falco): subscribe keepalive parameter
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
572a1e8381 update(userspace/falco): keep the stream open
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
356861be5f new(userspace/falco): initial grpc queuing logic
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
25f5fcacae new(userspace/falco): grpc server event bus queue
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
36fb0f6751 chore(userspace/falco): gRPC server send rule and source
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
87fed11f16 fix: grpc service must be registered and grpc context state must be handled for threads
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
6072b7a201 new(userspace/falco): falco outputs grpc server stop
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
fbe4e34a57 new(userspace/falco): request stream context process and end handling
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
13f5a76b97 new(usperspace/falco): request stream context specialization and process stream macro
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
2f917c578d new(userspace/falco): introduce request context base and request stream context classes
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
3bfaea5408 chore(userspace/falco): rename grpc server into falco grpc server
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
82a7becd9a chore(userspace/falco): grpc context format
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
60fac8d100 fix(userspace/falco): service name for the proto falco output svc
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
c2178ebc96 build(userspace/falco): add grpc context impl to cmake
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
9d9e2322a2 update(userspace/falco): change the way the grpc server is started
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
abfd6d8a1a update(userspace/falco): reorganize grpc server
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
5d0266a09e new(userspace/falco): grpc context and stream context
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
e394bcf119 update(userspace/falco): mvoing proto enum defs outside
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
89e23164fa new(userspace/falco): initial grpc server implementation
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
f3fcc8a974 new(userspace/falco): falco output protocol definition
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-09-25 16:43:32 +03:00
Lorenzo Fontana
19bc0149bd build: setup grpc and proto for falco outputs
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Co-Authored-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-25 16:43:32 +03:00
Leonardo Di Donato
a019b54fe6 docs: specify labels that apply to each area
If this work as intended PR will automatically get the area labels depending on the files he modified.
In case the user wants it can still apply other areas manually, by slash command, or editing the PR template during the opening of the PR.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-16 10:11:25 +02:00
Leonardo Di Donato
49c4ef5d8c feat(userspace): open the event source/s depending on the flags
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Co-authored-by: Lorenzo Fonanta <lo@linux.com>
2019-08-21 17:08:03 +02:00
Leonardo Di Donato
1eeb059e10 feat(userspace): can not disable both the event sources
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-08-21 17:08:03 +02:00
Leonardo Di Donato
870c17e31d feat: flag to disable sources (syscall, k8s_audit)
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-08-21 17:08:03 +02:00
Leonardo Di Donato
8c62ec5472 fix(usperspace): webserver must not fail with input that exceeds the expected ranges
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-08-13 15:48:06 +02:00
Leonardo Di Donato
c9cd6eebf7 update(userspace): falco webserver must catch json type errors (exceptions)
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-08-13 15:48:06 +02:00
Leonardo Di Donato
723bc1cabf fix(userspace): accessing a (json) object can throw exceptions because of wrong types
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-08-13 15:48:06 +02:00
Mark Stemm
76f64f5d79 Properly parse multi-document yaml files
Properly parse multi-document yaml files e.g. blocks separated by
---. This is easily handled by lyaml itself--you just need to pass the
option all = true to yaml.load, and each document will be provided as a table.

This does break the table iteration a bit, so some more refactoring:

 - Create a load_state table that holds context like the current
 - document index, the required_engine_version, etc.
 - Pull out the parts that parse a single document to load_rules_doc(),
   which is given the table for a single document + load_state.
 - Simplify get_orig_yaml_obj to just provide a single row index and
 - return all rows from that point to the next blank line or line
   starting with '-'

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-08-02 11:01:59 -07:00
Mark Stemm
1f0065e4b1 Further improvements when displaying contexts
Make additional improvements to display relevant context when validating
files. This handles cases where a macro/rule overwrites a prior rule.

 - Instead of saving the index into the array of lines for each rule,
   save the rule yaml itself, as a property 'context' for each object.

 - When appending rules, the context of the base macro/rule and the
   context of the appended rule/macro are concatenated.

 - New functions get_orig_yaml_obj, build_error, and
   build_error_with_context handle building the error string.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-31 11:22:38 +02:00
Mark Stemm
46b1a3c841 Fix bugs when verifying macro/rule objects.
Fix a couple of small bugs when verifying macro/rule objects:

1) Yaml can have document separators "---", and those were mistakenly
being considered array items.

2) When reading macros and rules and using array position to find the
right document offset, the overall object order should be
used (e.g. this is the 5th object from the file) and not the array
position (e.g. this is the 3rd rule from the file).

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-30 15:56:04 +02:00
Mark Stemm
3fedd00cfc Enable/disable rules using substrings not regexes
Given the compiler we currently use, you can't actually enable/disable
regexes in falco_engine::enable_rule using a regex pattern. The regex
either will fail to compile or will compile but not actually match
strings. This is noted on the c++11 compatibility notes for gcc 4.8.2:
https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/manual/manual/status.html#status.iso.2011.

The only use of using enable_rule was treating the regex pattern as a
substring match anyway, so we can change the engine to treat the pattern
as a substring.

So change the method/supporting sub-classes to note that the argument is
a substring match, and change falco itself to refer to substrings
instead of patterns.

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

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-29 23:24:13 +02:00
Leonardo Di Donato
44f0633f47 update: falco builder image has FALCO_VERSION build arg and env var again
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-26 03:23:01 +02:00
Leonardo Di Donato
0d4fc4bdad update: falco version from cmake variable
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-26 03:23:01 +02:00
Mark Stemm
40e3e21391 Allow all lowercase priorities
Just being tolerant given that the comparison used to be entirely
case-insensitive.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-24 13:05:17 +02:00
Lorenzo Fontana
4b2ea32eac fix: do the inspector after forking for daemon mode
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-07-23 01:13:05 +02:00
Mark Stemm
1711ed0a2e Pass back explicit errors in load_rules()
Instead of relying on lua errors to pass back parse errors, pass back an
explicit true + required engine version or false + error message.

Also clean up the error message to display info + context on the
error. When the error related to yaml parsing, use the row number passed
back in lyaml's error string to print the specific line with the error.

When parsing rules/macros/lists, print the object being parsed alongside
the error.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-11 11:24:22 -07:00
Mark Stemm
839d76a760 Send validate output to stdout
When parsing rules files with -V (validate), print info on the result of
loading the rules file to stdout. That way a caller can capture stdout
to pass along any rules parsing error.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-07-11 11:24:22 -07:00
Leonardo Di Donato
fdbd520cce fix: bump falco engine version
Co-Authored-By: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-09 11:45:38 +02:00