mirror of
https://github.com/falcosecurity/falco.git
synced 2025-06-28 07:37:32 +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();
|
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(
|
void filter_macro_resolver::set_macro(
|
||||||
string name,
|
string name,
|
||||||
shared_ptr<libsinsp::filter::ast::expr> macro)
|
shared_ptr<libsinsp::filter::ast::expr> macro)
|
||||||
|
@ -40,6 +40,11 @@ class filter_macro_resolver: private libsinsp::filter::ast::expr_visitor
|
|||||||
\return true if at least one of the defined macros is resolved
|
\return true if at least one of the defined macros is resolved
|
||||||
*/
|
*/
|
||||||
bool run(libsinsp::filter::ast::expr*& filter);
|
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
|
\brief Defines a new macro to be substituted in filters. If called
|
||||||
|
Loading…
Reference in New Issue
Block a user