mirror of
https://github.com/falcosecurity/falco.git
synced 2025-06-27 15:17:50 +00:00
refactor(userspace/engine): add run() overload in filter_macro_resolver to support shared_ptrs
This change allows working with safety with AST nodes wrapped into shared pointers. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
cf83a91d4e
commit
c2cac5af92
@ -34,6 +34,20 @@ bool filter_macro_resolver::run(libsinsp::filter::ast::expr*& filter)
|
||||
return !m_resolved_macros.empty();
|
||||
}
|
||||
|
||||
bool filter_macro_resolver::run(std::shared_ptr<libsinsp::filter::ast::expr>& filter)
|
||||
{
|
||||
m_unknown_macros.clear();
|
||||
m_resolved_macros.clear();
|
||||
m_last_node_changed = false;
|
||||
m_last_node = filter.get();
|
||||
filter->accept(this);
|
||||
if (m_last_node_changed)
|
||||
{
|
||||
filter.reset(m_last_node);
|
||||
}
|
||||
return !m_resolved_macros.empty();
|
||||
}
|
||||
|
||||
void filter_macro_resolver::set_macro(
|
||||
string name,
|
||||
shared_ptr<libsinsp::filter::ast::expr> macro)
|
||||
|
@ -41,6 +41,11 @@ class filter_macro_resolver: private libsinsp::filter::ast::expr_visitor
|
||||
*/
|
||||
bool run(libsinsp::filter::ast::expr*& filter);
|
||||
|
||||
/*!
|
||||
\brief Version of run() that works with shared pointers
|
||||
*/
|
||||
bool run(std::shared_ptr<libsinsp::filter::ast::expr>& filter);
|
||||
|
||||
/*!
|
||||
\brief Defines a new macro to be substituted in filters. If called
|
||||
multiple times for the same macro name, the previous definition
|
||||
|
Loading…
Reference in New Issue
Block a user