mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-30 12:30:56 +00:00
Add equality operators for indexed_vector/falco_{list,macro,rule}
Add an equality operator for indexed_vector. As indexed_vectors commonly hold falco lists/macros/rules, also add equality operators for those structs. For condition/sinsp_filter shared_ptrs, the operator checks that the shared_ptrs point to the same underlying memory. Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
parent
093d9234a5
commit
5f13a9be08
@ -35,6 +35,11 @@ struct falco_list {
|
||||
falco_list& operator=(const falco_list&) = default;
|
||||
~falco_list() = default;
|
||||
|
||||
bool operator==(const falco_list& rhs) const {
|
||||
return (this->used == rhs.used && this->id == rhs.id && this->name == rhs.name &&
|
||||
this->items == rhs.items);
|
||||
}
|
||||
|
||||
bool used;
|
||||
std::size_t id;
|
||||
std::string name;
|
||||
@ -53,6 +58,14 @@ struct falco_macro {
|
||||
falco_macro& operator=(const falco_macro&) = default;
|
||||
~falco_macro() = default;
|
||||
|
||||
bool operator==(const falco_macro& rhs) const {
|
||||
// Note this only ensures that the shared_ptrs are
|
||||
// pointing to the same underlying memory, not that
|
||||
// they are logically equal.
|
||||
return (this->used == rhs.used && this->id == rhs.id && this->name == rhs.name &&
|
||||
this->condition.get() == rhs.condition.get());
|
||||
}
|
||||
|
||||
bool used;
|
||||
std::size_t id;
|
||||
std::string name;
|
||||
@ -71,6 +84,17 @@ struct falco_rule {
|
||||
falco_rule& operator=(const falco_rule&) = default;
|
||||
~falco_rule() = default;
|
||||
|
||||
bool operator==(const falco_rule& rhs) const {
|
||||
// Note this only ensures that the shared_ptrs are
|
||||
// pointing to the same underlying memory, not that
|
||||
// they are logically equal.
|
||||
return (this->id == rhs.id && this->source == rhs.source && this->name == rhs.name &&
|
||||
this->description == rhs.description && this->output == rhs.output &&
|
||||
this->tags == rhs.tags && this->exception_fields == rhs.exception_fields &&
|
||||
this->priority == rhs.priority && this->condition.get() == rhs.condition.get() &&
|
||||
this->filter.get() == rhs.filter.get());
|
||||
}
|
||||
|
||||
std::size_t id;
|
||||
std::string source;
|
||||
std::string name;
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
indexed_vector& operator=(indexed_vector&&) = default;
|
||||
indexed_vector(const indexed_vector&) = default;
|
||||
indexed_vector& operator=(const indexed_vector&) = default;
|
||||
bool operator==(const indexed_vector& rhs) const {
|
||||
return (this->m_entries == rhs.m_entries && this->m_index == rhs.m_index);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the number of elements
|
||||
|
Loading…
Reference in New Issue
Block a user