Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Falco outputs refactoring #1412

Merged
merged 26 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d1cbd59
update(userspace/engine): refactor falco_formats to accept non-lua ca…
leogr Sep 21, 2020
1ec6a4e
chore(userspace/falco): remove lua code for outputs
leogr Sep 21, 2020
cf95260
chore(userspace/falco): clean up lua deps from logger
leogr Sep 21, 2020
ad5a7a1
new(userspace/falco): base class for Falco outputs
leogr Sep 21, 2020
11d4af4
chore(userspace/falco): refine falco_output interface
leogr Sep 22, 2020
bd1f4f3
new(userspace/falco): stdout output C++ impl
leogr Sep 22, 2020
5b42aa5
new(userspace/falco): file output C++ impl
leogr Sep 22, 2020
b38d5b2
new(userspace/falco): gRPC output C++ impl
leogr Sep 22, 2020
10ddbe7
new(userspace/falco): http output C++ impl
leogr Sep 22, 2020
d1417dc
new(userspace/falco): program output C++ impl
leogr Sep 22, 2020
37eace7
new(userspace/falco): syslog output C++ impl
leogr Sep 22, 2020
ecb070d
refactor(userspace/falco): falco_outputs
leogr Sep 22, 2020
7f3e7ee
chore(userspace/engine): clean up unused code
leogr Sep 22, 2020
e989d08
chore(userspace/falco): simplify files naming
leogr Sep 24, 2020
4ebd14e
chore(userspace/falco): move output config struct one level up
leogr Sep 24, 2020
9d55bc5
chore(userspace/falco): prefix abstract class with "abstract_"
leogr Sep 24, 2020
bef62e3
chore: clean up lua from dot files
leogr Sep 24, 2020
1aa3c63
build(userspace/falco): clean up residual lua references
leogr Sep 24, 2020
01dea70
update(userspace/falco): improve stdout buffering
leogr Sep 29, 2020
3e935b5
chore(userspace/falco): finalize program output impl
leogr Sep 29, 2020
48b4367
chore(userspace/falco): cleanup unnecessary flush
leogr Sep 29, 2020
21894a8
chore: lua dir is not needed anymore in falco_outputs
leogr Sep 29, 2020
b7b1604
chore: update comments to reflect the impl
leogr Sep 29, 2020
d588651
chore(userspace/engine): clean up leftover
leogr Oct 12, 2020
57eb2bb
fix(test): correct parent dir creation for strict tests
leogr Oct 12, 2020
8a1a45f
update(test): use to iso time
leogr Oct 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ test/.phoronix-test-suite
test/results*.json.*
test/build

userspace/falco/lua/re.lua
userspace/falco/lua/lpeg.so
userspace/engine/lua/lyaml
userspace/engine/lua/lyaml.lua

Expand Down
1 change: 0 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
std = "min"
cache = true
include_files = {
"userspace/falco/lua/*.lua",
"userspace/engine/lua/*.lua",
"userspace/engine/lua/lyaml/*.lua",
"*.luacheckrc"
Expand Down
15 changes: 8 additions & 7 deletions test/falco_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ def setUp(self):
output['actual'] = key
output['expected'] = value
output_strictly_contains.append(output)
# Clean up file from previous tests, if any
if not output['actual'] == 'stdout' and os.path.exists(output['actual']):
os.remove(output['actual'])
filedir = os.path.dirname(output['expected'])
# Create the parent directory for the file if it doesn't exist.
if not os.path.isdir(filedir):
os.makedirs(filedir)
if not output['actual'] == 'stdout':
# Clean up file from previous tests, if any
if os.path.exists(output['actual']):
os.remove(output['actual'])
# Create the parent directory for the file if it doesn't exist.
filedir = os.path.dirname(output['actual'])
if not os.path.isdir(filedir):
os.makedirs(filedir)
self.output_strictly_contains = output_strictly_contains

self.grpcurl_res = None
Expand Down
11 changes: 8 additions & 3 deletions test/falco_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ trace_files: !mux
- rules/single_rule.yaml
conf_file: confs/stdout_output.yaml
trace_file: trace_files/cat_write.scap
time_iso_8601: true
output_strictly_contains:
- stdout: output_files/single_rule_with_cat_write.txt

Expand All @@ -670,6 +671,7 @@ trace_files: !mux
- rules/single_rule.yaml
conf_file: confs/stdout_output.yaml
trace_file: trace_files/cat_write.scap
time_iso_8601: true
output_strictly_contains:
- stdout: output_files/single_rule_with_cat_write.json

Expand All @@ -680,6 +682,7 @@ trace_files: !mux
- rules/single_rule.yaml
conf_file: confs/file_output.yaml
trace_file: trace_files/cat_write.scap
time_iso_8601: true
output_strictly_contains:
- /tmp/falco_outputs/file_output.txt: output_files/single_rule_with_cat_write.txt

Expand All @@ -690,6 +693,7 @@ trace_files: !mux
- rules/single_rule.yaml
conf_file: confs/program_output.yaml
trace_file: trace_files/cat_write.scap
time_iso_8601: true
output_strictly_contains:
- /tmp/falco_outputs/program_output.txt: output_files/single_rule_with_cat_write.txt

Expand All @@ -701,6 +705,7 @@ trace_files: !mux
conf_file: confs/grpc_unix_socket.yaml
trace_file: trace_files/cat_write.scap
run_duration: 5
time_iso_8601: true
grpc:
address: unix:///tmp/falco/falco.sock
proto: outputs.proto
Expand All @@ -711,10 +716,10 @@ trace_files: !mux
- "seconds:1470327477 nanos:881781397"
- "priority: WARNING"
- "rule: \"open_from_cat\""
- "output: \"18:17:57.881781397: Warning An open was seen (command=cat /dev/null)\""
- "output: \"2016-08-04T16:17:57.881781397+0000: Warning An open was seen (command=cat /dev/null)\""
# output fields
- "key: \"evt.time\""
- "value: \"18:17:57.881781397\""
- "key: \"evt.time.iso8601\""
- "value: \"2016-08-04T16:17:57.881781397+0000\""
- "key: \"proc.cmdline\""
- "value: \"cat /dev/null\""
# For the hostname, since we don't know that beforehand,
Expand Down
16 changes: 8 additions & 8 deletions test/output_files/single_rule_with_cat_write.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"output":"18:17:57.881781397: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881781397Z", "output_fields": {"evt.time":1470327477881781397,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.881785348: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881785348Z", "output_fields": {"evt.time":1470327477881785348,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.881796705: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881796705Z", "output_fields": {"evt.time":1470327477881796705,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.881799840: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881799840Z", "output_fields": {"evt.time":1470327477881799840,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.882003104: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882003104Z", "output_fields": {"evt.time":1470327477882003104,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.882008208: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882008208Z", "output_fields": {"evt.time":1470327477882008208,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.882045694: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882045694Z", "output_fields": {"evt.time":1470327477882045694,"proc.cmdline":"cat /dev/null"}}
{"output":"18:17:57.882054739: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882054739Z", "output_fields": {"evt.time":1470327477882054739,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.881781397+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881781397Z", "output_fields": {"evt.time.iso8601":1470327477881781397,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.881785348+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881785348Z", "output_fields": {"evt.time.iso8601":1470327477881785348,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.881796705+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881796705Z", "output_fields": {"evt.time.iso8601":1470327477881796705,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.881799840+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.881799840Z", "output_fields": {"evt.time.iso8601":1470327477881799840,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.882003104+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882003104Z", "output_fields": {"evt.time.iso8601":1470327477882003104,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.882008208+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882008208Z", "output_fields": {"evt.time.iso8601":1470327477882008208,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.882045694+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882045694Z", "output_fields": {"evt.time.iso8601":1470327477882045694,"proc.cmdline":"cat /dev/null"}}
{"output":"2016-08-04T16:17:57.882054739+0000: Warning An open was seen (command=cat /dev/null)","priority":"Warning","rule":"open_from_cat","time":"2016-08-04T16:17:57.882054739Z", "output_fields": {"evt.time.iso8601":1470327477882054739,"proc.cmdline":"cat /dev/null"}}
16 changes: 8 additions & 8 deletions test/output_files/single_rule_with_cat_write.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
18:17:57.881781397: Warning An open was seen (command=cat /dev/null)
18:17:57.881785348: Warning An open was seen (command=cat /dev/null)
18:17:57.881796705: Warning An open was seen (command=cat /dev/null)
18:17:57.881799840: Warning An open was seen (command=cat /dev/null)
18:17:57.882003104: Warning An open was seen (command=cat /dev/null)
18:17:57.882008208: Warning An open was seen (command=cat /dev/null)
18:17:57.882045694: Warning An open was seen (command=cat /dev/null)
18:17:57.882054739: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.881781397+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.881785348+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.881796705+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.881799840+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.882003104+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.882008208+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.882045694+0000: Warning An open was seen (command=cat /dev/null)
2016-08-04T16:17:57.882054739+0000: Warning An open was seen (command=cat /dev/null)
5 changes: 2 additions & 3 deletions userspace/engine/falco_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ void falco_engine::load_rules(const string &rules_content, bool verbose, bool al
m_ls);
}

// Note that falco_formats is added to both the lua state used
// by the falco engine as well as the separate lua state used
// by falco outputs. Within the engine, only
// Note that falco_formats is added to the lua state used
// by the falco engine only. Within the engine, only
// formats.formatter is used, so we can unconditionally set
// json_output to false.
bool json_output = false;
Expand Down
Loading