Commit Graph

2663 Commits

Author SHA1 Message Date
Mark Stemm
3e0be46ede squash w Move falco_init() code to individual app actions 2022-03-04 13:45:03 -08:00
Mark Stemm
07fe221abf Squash w Falco main changes for app actions 2022-03-04 12:53:13 -08:00
Mark Stemm
cec0f8c6cc Squash w Move falco_init() code to individual app actions 2022-03-04 12:52:59 -08:00
Mark Stemm
4e5f6c0517 Squash w WIP on app actions 2022-03-04 12:52:21 -08:00
Mark Stemm
2585462f81 Squash w Falco main changes for app actions 2022-03-04 12:16:38 -08:00
Mark Stemm
fbabe9efab Squash w Application changes to support actions 2022-03-04 12:16:17 -08:00
Mark Stemm
a2fb776e66 Squash w Initial action manager object 2022-03-04 12:15:48 -08:00
Mark Stemm
80078cb641 Squash w Move falco_init() code to individual app actions 2022-03-04 12:15:24 -08:00
Mark Stemm
9109fe6913 Squash w Falco main changes for app actions 2022-03-03 18:05:06 -08:00
Mark Stemm
5554294bc7 Squash w Application changes to support actions 2022-03-03 18:04:50 -08:00
Mark Stemm
ebef16f28f Squash w Move falco_init() code to individual app actions 2022-03-03 18:04:23 -08:00
Mark Stemm
b5878010ed Squash w WIP: Initial skeleton of "action" object. 2022-03-03 17:46:45 -08:00
Mark Stemm
59f78696cf Squash w Application changes to support actions 2022-03-03 17:46:26 -08:00
Mark Stemm
529b9d9724 Squash w Initial action manager object 2022-03-03 17:45:59 -08:00
Mark Stemm
4adf4e9603 Squash w Initial framework for unit tests of action manager. 2022-03-03 17:45:32 -08:00
Mark Stemm
b00bf53d88 squash w Move falco_init() code to individual app actions 2022-03-03 17:44:57 -08:00
Mark Stemm
066f799227 Squash w Falco main changes for app actions 2022-03-03 16:17:31 -08:00
Mark Stemm
867a10bb76 Squash w Application changes to support actions 2022-03-03 16:17:12 -08:00
Mark Stemm
572e4af528 Squash w WIP on app actions 2022-03-03 16:16:45 -08:00
Mark Stemm
7b45b2c354 Squash w Move falco_init() code to individual app actions 2022-03-03 16:16:15 -08:00
Mark Stemm
fcd67307f6 Squash w Move falco_init() code to individual app actions 2022-03-03 16:15:15 -08:00
Mark Stemm
63123c405f Squash w Move falco_init() code to individual app actions 2022-03-03 12:34:33 -08:00
Mark Stemm
f635e93910 Squash w Initial action manager object 2022-03-03 12:33:30 -08:00
Mark Stemm
642399fa7a Squash w WIP on app actions 2022-03-03 12:31:58 -08:00
Mark Stemm
0dfd9147e3 Squash w Initial framework for unit tests of action manager. 2022-03-03 12:31:21 -08:00
Mark Stemm
e0feeeaa40 Squash w Application changes to support actions 2022-03-02 17:42:45 -08:00
Mark Stemm
2c1c23830a Squash w Falco main changes for app actions 2022-03-02 17:42:23 -08:00
Mark Stemm
f92abafb46 Squash w Move falco_init() code to individual app actions 2022-03-02 17:41:45 -08:00
Mark Stemm
8d258b11f8 Squash w Move falco_init() code to individual app actions 2022-03-02 17:41:20 -08:00
Mark Stemm
6524dcf5f5 Squash w Move falco_init() code to individual app actions 2022-03-02 17:40:38 -08:00
Mark Stemm
5d5c7d324a Squash w Initial action manager object 2022-03-02 17:40:12 -08:00
Mark Stemm
990ce338ce Squash w WIP on app actions 2022-03-02 17:39:35 -08:00
Mark Stemm
c569ff5604 Convert direct pointer refs to shared_ptr
Convert use of raw pointers (originally passed from falco_init or
functions it called) with shared_ptr, as they are now held in actions
state.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-03-02 17:38:22 -08:00
Mark Stemm
36a95398dd Add actions to replace falco_init
Convert hunks of code from falco_init to actions. Hunks were generally
copied as-is, replacing references to local variables to state
instance variables when shared across actions.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-03-02 17:36:15 -08:00
Mark Stemm
e9d15a7500 WIP on app actions 2022-03-01 10:00:35 -08:00
Mark Stemm
dd1119374b Application changes to support actions
Changes to the falco::app::application object to support actions:

- State that needs to be shared between applications is in a
  falco::app::application::action_state object, accessible via the
  method state().
- The application now has an action manager which adds all the action
  objects defined in defined_app_actions.h.
- application now has a run() method which simply uses the action
  manager to run all the actions.
- In a few rare cases (signal handlers, etc.) it wasn't possible to
  pass around an application reference, so create a singleton
  accessible via application::get().
2022-02-28 17:17:25 -08:00
Mark Stemm
7b20367ae9 Move falco_init() code to individual app actions
Move the bulk of the code from falco_init() to individual app action
objects. Any state that needs to be shared betweeen actions resides in
app::state(), so the moved code stays pretty much as-is, other than
replacing stack variables with member variables in app_state.
2022-02-28 17:15:05 -08:00
Mark Stemm
40e018a531 Falco main changes for app actions
This involves moving the code in falco_init() into individual app
actions. falco_init() simply calls app.run() now.
2022-02-28 17:12:22 -08:00
Mark Stemm
5c104d3f90 Initial framework for unit tests of action manager.
Has a set of test actions that simply record when they were run, and a
set of tests that run them in known orders and compare the expected
run order to the actual run order.
2022-02-25 16:08:14 -08:00
Mark Stemm
64722728dd Initial action manager object
Add an action manager object, that ensures that actions run, honoring
prerequsite order and run_result.

Uses a heap to order actions by prerequsites, and then runs them in
order, stopping at the first proceed == false.
2022-02-25 16:07:51 -08:00
Mark Stemm
16703be1f9 WIP: Initial skeleton of "action" object.
This will help distribute all the many things falco does in falco_init
into smaller components, while retaining a notion of dependencies and
order.
2022-02-25 16:06:51 -08:00
Federico Di Pierro
f78c816abd update(build): updated libs to latest master.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2022-02-25 09:31:19 +01:00
Federico Di Pierro
1d76df3831 new(userspace/falco): allow to pass multiple --cri options.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2022-02-25 09:31:19 +01:00
Jason Dellaluce
335d79e79c chore(userspace/engine): remove unused lua functions and state vars
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-02-24 18:24:19 +01:00
Jason Dellaluce
ef6888181d fix(userspace/falco): correct plugins init config conversion from YAML to JSON
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
2022-02-24 18:23:14 +01:00
Andrea Bonanno
d3083cde92 chore(userspace/falco): fixes truncated -b option description.
Signed-off-by: Andrea Bonanno <andrea@bonanno.cloud>
2022-02-24 16:14:27 +01:00
Mark Stemm
83353985f7 Update falco main to use falco application + cmdline_opts
Update falco's main falco_init() to use a falco::app::application and
falco::app::cmdline_opts object instead of storing all its command
line state in stack variables.

The bulk of the removed code is in usage() (not needed as cxxopt's
help() is self-documenting.) and getopt_long() which is replaced by
app.init(argc, argv).

For the most part, this is simply replacing references to local
variables (e.g. "all_events") to the bound variable inside the
cmdline_opts object (e.g. app.copts().all_events).

There are a few cases where more complex logic was used (output
formats, initializing k8s/mesos with string pointers), and those
changes are still in falco_init().

For the most part, the monolithic parts of falco_init that involve
reading config files, creating the inspector, loading rules, etc are
still present. Those will be addressed in later changes.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-02-24 10:40:16 +01:00
Mark Stemm
83b036bc0e Small changes to falco engine/config wrt new cmdline option parsing
For the most part, replacing getopt() with cxxopts + falco application
had no effect on falco engine/config interfaces. However, there were a
few places where it was wasier to change the interface than add
middleware code that transformed from, for example, vectors to lists.

This commit has those changes.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-02-24 10:40:16 +01:00
Mark Stemm
216f56b73b Initial falco::app::cmdline_options class
Fill in an initial falco::app::cmdline_options class using cxxopts
library to hold options:

- falco::app::cmdline_options contains a cxxopts::Options object to
  parse options and a cxxopts::ParseResult to hold the result.
- The only meaningful public method is parse() which parses argc/argv
  and returns true/false + error.
- The parsed options are all public instance variables of the object
  and generally use the same names of the corresponding variables in
  the old falco_init(). These variables are all bound to the
  corresponding command line option and are updated in parse().
- In a few cases, the command line option does not directly map to a
  bound variable (e.g. -b to set buffer format, -p/-pk/-pc to set
  extra formatting options, etc.) In these cases the option values are
  read after parsing and update the public instance variable.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-02-24 10:40:16 +01:00
Mark Stemm
17d8eea3bc Add notion of falco application object/cmdline opts skeleton
Add a notion of a falco application object. Eventually this will
replace the bulk of falco_init and contain methods to:

- Parse/validate command line options
- Parse/validate falco config
- Initialize prerequsites (inspector, falco engine, webserver, etc)
- Load plugins
- Load/validate rules
- Command/subcommand execution (e.g. --list/--list-fields, or
  nothing specified to run "main" loop)

For now, it is only responsible for command line options handling,
which is stubbed out.

Currently, the only public methods are init() to initialize everything
and copts() to access command line options.

Command line options are held in a different class
falco::app::cmdline_opts. application::copts() returns a reference to
that object, which allows access to parsed command line options bound
to various public instance variables.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2022-02-24 10:40:16 +01:00