mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-09 18:17:57 +00:00
update(userspace/engine): support undefining macros
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
20c59970f5
commit
a0a87e443f
@ -38,7 +38,6 @@ void filter_macro_resolver::set_macro(
|
||||
string name,
|
||||
shared_ptr<libsinsp::filter::ast::expr> macro)
|
||||
{
|
||||
auto it = m_macros.find(name);
|
||||
m_macros[name] = macro;
|
||||
}
|
||||
|
||||
@ -120,7 +119,7 @@ void filter_macro_resolver::visit(ast::value_expr* e)
|
||||
// of identier-only children from either a 'not',
|
||||
// an 'and' or an 'or'.
|
||||
auto macro = m_macros.find(e->value);
|
||||
if (macro != m_macros.end())
|
||||
if (macro != m_macros.end() && macro->second) // skip null-ptr macros
|
||||
{
|
||||
ast::expr* new_node = ast::clone(macro->second.get());
|
||||
new_node->accept(this); // this sets m_last_node
|
||||
|
@ -44,7 +44,8 @@ class filter_macro_resolver: private libsinsp::filter::ast::expr_visitor
|
||||
/*!
|
||||
\brief Defines a new macro to be substituted in filters. If called
|
||||
multiple times for the same macro name, the previous definition
|
||||
gets overridden.
|
||||
gets overridden. A macro can be undefined by setting a null
|
||||
AST pointer.
|
||||
\param name The name of the macro.
|
||||
\param macro The AST of the macro.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user