sync code

This commit is contained in:
Ned Wright
2025-03-17 14:49:44 +00:00
parent df7be864e2
commit 0246b73bbd
20 changed files with 877 additions and 278 deletions

View File

@@ -30,6 +30,7 @@ class AgentDetailsReporter
Singleton::Consume<I_Messaging>,
Singleton::Consume<I_MainLoop>,
Singleton::Consume<I_Environment>,
Singleton::Consume<I_TimeGet>,
Singleton::Consume<I_RestApi>
{
public:

View File

@@ -53,6 +53,51 @@ private:
std::map<std::string, std::set<std::string>> set_string_attr;
};
class IpAddressRange
{
public:
IpAddressRange() = default;
IpAddressRange(const std::string &min, const std::string &max) : min(min), max(max) {}
bool operator==(const IpAddressRange &other) const { return min == other.min && max == other.max; }
const std::string getMin() const { return min; }
const std::string getMax() const { return max; }
template <class Archive>
void serialize(Archive &ar) {
ar(CEREAL_NVP(max), CEREAL_NVP(min));
}
private:
std::string min;
std::string max;
};
class IpAttributes
{
public:
IpAttributes() = default;
IpAttributes & addIpv4Addresses(const std::string &val);
IpAttributes & addIpv6Addresses(const std::string &val);
IpAttributes & addIpv4AddressRanges(const IpAddressRange &val);
IpAttributes & addIpv6AddressRanges(const IpAddressRange &val);
Maybe<std::vector<std::string>, void> getIpv4Addresses() const;
Maybe<std::vector<std::string>, void> getIpv6Addresses() const;
Maybe<std::vector<IpAddressRange>, void> getIpv4AddressRanges() const;
Maybe<std::vector<IpAddressRange>, void> getIpv6AddressRanges() const;
Maybe<std::string, void> genObject() const;
bool isEmpty() const;
bool matches(const IpAttributes &other) const;
void serialize(cereal::JSONInputArchive &ar);
void performOutputingSchema(std::ostream &, int);
private:
std::vector<std::string> ipv4_addresses;
std::vector<std::string> ipv6_addresses;
std::vector<IpAddressRange> ipv4_address_ranges;
std::vector<IpAddressRange> ipv6_address_ranges;
};
class Invalidation
{
public:
@@ -60,14 +105,14 @@ public:
Invalidation & setClassifier(ClassifierType type, const std::string &val);
Invalidation & addMainAttr(const StrAttributes &attr);
Invalidation & addAttr(const StrAttributes &attr);
Invalidation & addAttr(const IpAttributes &attr);
Invalidation & setSourceId(const std::string &id);
Invalidation & setObjectType(ObjectType type);
Invalidation & setInvalidationType(InvalidationType type);
std::string getClassifier(ClassifierType type) const { return classifiers[type]; }
std::vector<StrAttributes> getMainAttributes() const { return main_attributes; }
std::vector<StrAttributes> getAttributes() const { return attributes; }
std::vector<IpAttributes> getAttributes() const { return attributes; }
const Maybe<std::string, void> & getSourceId() const { return source_id; }
const Maybe<ObjectType, void> & getObjectType() const { return object_type; }
const Maybe<InvalidationType, void> & getInvalidationType() const { return invalidation_type; }
@@ -86,10 +131,11 @@ public:
private:
bool attr_matches(const std::vector<StrAttributes> &current, const std::vector<StrAttributes> &other) const;
bool attr_matches(const std::vector<IpAttributes> &current, const std::vector<IpAttributes> &other) const;
EnumArray<ClassifierType, std::string, 6> classifiers;
std::vector<StrAttributes> main_attributes;
std::vector<StrAttributes> attributes;
std::vector<IpAttributes> attributes;
Maybe<std::string, void> source_id;
Maybe<ObjectType, void> object_type;
Maybe<InvalidationType, void> invalidation_type;