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

refactor(userspace/engine): drop macro source field in rules and rule loader #2094

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions test/falco_tests_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ trace_files: !mux
- Cloudtrail Create Instance
stderr_contains: "Rule Cloudtrail Create Instance: warning .unknown-source.: unknown source aws_cloudtrail, skipping"

no_plugins_unknown_source_macro:
detect: False
rules_file:
- rules/plugins/cloudtrail_macro.yaml
trace_file: trace_files/empty.scap
stderr_contains: "Macro Some Cloudtrail Macro: warning .unknown-source.: unknown source aws_cloudtrail, skipping"

no_plugins_unknown_source_rule_exception:
detect: False
rules_file:
Expand Down
4 changes: 0 additions & 4 deletions test/rules/plugins/cloudtrail_macro.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions userspace/engine/rule_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,6 @@ void rule_loader::append(configuration& cfg, list_info& info)

void rule_loader::define(configuration& cfg, macro_info& info)
{
if (!cfg.sources.at(info.source))
{
cfg.warnings.push_back("Macro " + info.name
+ ": warning (unknown-source): unknown source "
+ info.source + ", skipping");
return;
}

auto prev = m_macro_infos.at(info.name);
THROW(prev && prev->source != info.source,
"Macro " + info.name + " has been re-defined with a different source");

define_info(m_macro_infos, info, m_cur_index++);
}

Expand Down Expand Up @@ -566,7 +554,6 @@ void rule_loader::compile_macros_infos(
indexed_vector<list_info>& lists,
indexed_vector<macro_info>& out) const
{
set<string> used;
const context* info_ctx = NULL;
try
{
Expand Down
1 change: 0 additions & 1 deletion userspace/engine/rule_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class rule_loader
size_t visibility;
std::string name;
std::string cond;
std::string source;
std::shared_ptr<libsinsp::filter::ast::expr> cond_ast;
};

Expand Down
2 changes: 0 additions & 2 deletions userspace/engine/rule_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,10 @@ static void read_item(
rule_loader::macro_info v;
v.ctx = ctx;
bool append = false;
v.source = falco_common::syscall_source;
THROW(!decode_val(item["macro"], v.name) || v.name.empty(),
"Macro name is empty");
THROW(!decode_val(item["condition"], v.cond) || v.cond.empty(),
"Macro must have property condition");
decode_val(item["source"], v.source);
if(decode_val(item["append"], append) && append)
{
loader.append(cfg, v);
Expand Down