mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-09 02:29:36 +00:00
cleanup(outputs): adopt different style for outputs_queue params encodings
Co-authored-by: Leonardo Grasso <me@leonardograsso.com> Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
This commit is contained in:
@@ -27,10 +27,18 @@ static std::vector<std::string> priority_names = {
|
||||
"Debug"
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
static std::vector<std::string> rule_matching_names = {
|
||||
"first",
|
||||
"all"
|
||||
};
|
||||
=======
|
||||
static std::vector<std::string> outputs_recovery_names = {
|
||||
"continue",
|
||||
"exit",
|
||||
"empty",
|
||||
};
|
||||
>>>>>>> 92bd5767 (cleanup(outputs): adopt different style for outputs_queue params encodings)
|
||||
|
||||
bool falco_common::parse_priority(std::string v, priority_type& out)
|
||||
{
|
||||
@@ -59,6 +67,19 @@ falco_common::priority_type falco_common::parse_priority(std::string v)
|
||||
return out;
|
||||
}
|
||||
|
||||
bool falco_common::parse_recovery(std::string v, outputs_recovery_type& out)
|
||||
{
|
||||
for (size_t i = 0; i < outputs_recovery_names.size(); i++)
|
||||
{
|
||||
if (!strcasecmp(v.c_str(), outputs_recovery_names[i].c_str()))
|
||||
{
|
||||
out = (outputs_recovery_type) i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool falco_common::format_priority(priority_type v, std::string& out, bool shortfmt)
|
||||
{
|
||||
if ((size_t) v < priority_names.size())
|
||||
|
@@ -21,6 +21,8 @@ limitations under the License.
|
||||
#include <mutex>
|
||||
#include <sinsp.h>
|
||||
|
||||
#define DEFAULT_OUTPUTS_QUEUE_CAPACITY 0
|
||||
|
||||
//
|
||||
// Most falco_* classes can throw exceptions. Unless directly related
|
||||
// to low-level failures like inability to open file, etc, they will
|
||||
@@ -52,6 +54,13 @@ struct falco_exception : std::exception
|
||||
|
||||
namespace falco_common
|
||||
{
|
||||
|
||||
enum outputs_recovery_type {
|
||||
RECOVERY_CONTINUE = 0, /* queue_capacity_outputs recovery strategy of continuing on. */
|
||||
RECOVERY_EXIT = 1, /* queue_capacity_outputs recovery strategy of exiting, self OOM kill. */
|
||||
RECOVERY_EMPTY = 2, /* queue_capacity_outputs recovery strategy of emptying queue then continuing. */
|
||||
};
|
||||
|
||||
const std::string syscall_source = sinsp_syscall_event_source_name;
|
||||
|
||||
// Same as numbers/indices into the above vector
|
||||
@@ -69,6 +78,7 @@ namespace falco_common
|
||||
|
||||
bool parse_priority(std::string v, priority_type& out);
|
||||
priority_type parse_priority(std::string v);
|
||||
bool parse_recovery(std::string v, outputs_recovery_type& out);
|
||||
bool format_priority(priority_type v, std::string& out, bool shortfmt=false);
|
||||
std::string format_priority(priority_type v, bool shortfmt=false);
|
||||
|
||||
|
Reference in New Issue
Block a user