mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 11:16:30 +03:00
Mar 21st 2024 update
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <sys/types.h>
|
||||
@@ -132,6 +133,18 @@ operator<<(ostream &os, const pair<const First, Second> &printable_pair)
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename Printable>
|
||||
ostream &
|
||||
operator<<(ostream &os, const vector<Printable> &obj)
|
||||
{
|
||||
bool first = true;
|
||||
for (const auto &val : obj) {
|
||||
os << (first ? "" : ", ") << val;
|
||||
first = false;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // __COMMON_H__
|
||||
|
@@ -56,14 +56,16 @@ public:
|
||||
const std::string &uri,
|
||||
serializableObject &req_obj,
|
||||
const MessageCategory category = MessageCategory::GENERIC,
|
||||
MessageMetadata message_metadata = MessageMetadata());
|
||||
MessageMetadata message_metadata = MessageMetadata(),
|
||||
bool force_buffering = true);
|
||||
|
||||
virtual void sendAsyncMessage(
|
||||
const HTTPMethod method,
|
||||
const std::string &uri,
|
||||
const std::string &body,
|
||||
const MessageCategory category,
|
||||
MessageMetadata message_metadata
|
||||
const MessageMetadata &message_metadata = MessageMetadata(),
|
||||
bool force_buffering = true
|
||||
) = 0;
|
||||
|
||||
virtual Maybe<HTTPResponse, HTTPResponse> sendSyncMessage(
|
||||
|
@@ -28,6 +28,7 @@ AssetReply<UserSerializableReplyAttr>::load(cereal::JSONInputArchive &ar)
|
||||
SerializableMultiMap<std::string, std::vector<std::string>> tmp_multimap;
|
||||
ar(
|
||||
cereal::make_nvp("schemaVersion", asset_schema_version),
|
||||
cereal::make_nvp("assetType", asset_type),
|
||||
cereal::make_nvp("assetTypeSchemaVersion", asset_type_schema_version),
|
||||
cereal::make_nvp("class", asset_class),
|
||||
cereal::make_nvp("category", asset_category),
|
||||
@@ -65,7 +66,6 @@ AssetReply<UserSerializableReplyAttr>::load(cereal::JSONInputArchive &ar)
|
||||
} catch(...) {}
|
||||
|
||||
ar(cereal::make_nvp("sources", sources));
|
||||
ar(cereal::make_nvp("assetType", asset_type));
|
||||
}
|
||||
|
||||
template <typename UserSerializableReplyAttr>
|
||||
|
@@ -128,7 +128,8 @@ I_Messaging::sendAsyncMessage(
|
||||
const std::string &uri,
|
||||
serializableObject &req_obj,
|
||||
const MessageCategory category,
|
||||
MessageMetadata message_metadata)
|
||||
MessageMetadata message_metadata,
|
||||
bool force_buffering)
|
||||
{
|
||||
Maybe<std::string> req_body = req_obj.genJson();
|
||||
if (!req_body.ok()) {
|
||||
@@ -141,7 +142,8 @@ I_Messaging::sendAsyncMessage(
|
||||
uri,
|
||||
req_body.unpack(),
|
||||
category,
|
||||
message_metadata
|
||||
message_metadata,
|
||||
force_buffering
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -18,14 +18,15 @@ public:
|
||||
MessageMetadata
|
||||
)
|
||||
);
|
||||
MOCK_METHOD5(
|
||||
MOCK_METHOD6(
|
||||
sendAsyncMessage,
|
||||
void (
|
||||
HTTPMethod,
|
||||
const string &,
|
||||
const string &,
|
||||
MessageCategory,
|
||||
MessageMetadata
|
||||
const MessageMetadata &,
|
||||
bool
|
||||
)
|
||||
);
|
||||
|
||||
|
@@ -80,6 +80,7 @@ DEFINE_FLAG(D_COMPONENT, D_ALL)
|
||||
DEFINE_FLAG(D_WAAP_JSON, D_WAAP)
|
||||
DEFINE_FLAG(D_WAAP_BOT_PROTECTION, D_WAAP)
|
||||
DEFINE_FLAG(D_WAAP_STREAMING_PARSING, D_WAAP)
|
||||
DEFINE_FLAG(D_WAAP_HEADERS, D_WAAP)
|
||||
DEFINE_FLAG(D_WAAP_PARSER, D_WAAP)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_XML, D_WAAP_PARSER)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_HTML, D_WAAP_PARSER)
|
||||
@@ -96,6 +97,7 @@ DEFINE_FLAG(D_COMPONENT, D_ALL)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_PHPSERIALIZE, D_WAAP_PARSER)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_PERCENT, D_WAAP_PARSER)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_PAIRS, D_WAAP_PARSER)
|
||||
DEFINE_FLAG(D_WAAP_PARSER_PDF, D_WAAP_PARSER)
|
||||
DEFINE_FLAG(D_WAAP_OVERRIDE, D_WAAP)
|
||||
|
||||
DEFINE_FLAG(D_IPS, D_COMPONENT)
|
||||
|
@@ -58,7 +58,8 @@ public:
|
||||
const ReportIS::IssuingEngine &_issuing_engine,
|
||||
std::chrono::seconds _report_interval,
|
||||
bool _reset,
|
||||
ReportIS::Audience _audience = ReportIS::Audience::INTERNAL
|
||||
ReportIS::Audience _audience = ReportIS::Audience::INTERNAL,
|
||||
bool _force_buffering = false
|
||||
);
|
||||
|
||||
template <typename Value>
|
||||
@@ -107,6 +108,7 @@ private:
|
||||
std::chrono::seconds report_interval;
|
||||
std::vector<MetricCalc *> calcs;
|
||||
bool reset;
|
||||
bool force_buffering = false;
|
||||
Context ctx;
|
||||
};
|
||||
|
||||
|
@@ -29,6 +29,7 @@ namespace Intelligence
|
||||
|
||||
enum class ClassifierType { CLASS, CATEGORY, FAMILY, GROUP, ORDER, KIND };
|
||||
enum class ObjectType { ASSET, ZONE, POLICY_PACKAGE, CONFIGURATION, SESSION, SHORTLIVED };
|
||||
enum class InvalidationType { ADD, DELETE, UPDATE };
|
||||
|
||||
class Invalidation
|
||||
{
|
||||
@@ -36,16 +37,20 @@ public:
|
||||
Invalidation(const std::string &class_value);
|
||||
|
||||
Invalidation & setClassifier(ClassifierType type, const std::string &val);
|
||||
Invalidation & setStringAttr(const std::string &attr, const std::string &val);
|
||||
Invalidation & setStringSetAttr(const std::string &attr, const std::set<std::string> &val);
|
||||
Invalidation & setStringAttr(const std::string &attr, const std::string &val, bool is_main = true);
|
||||
Invalidation & setStringSetAttr(const std::string &attr, const std::set<std::string> &val, bool is_main = true);
|
||||
Invalidation & setSourceId(const std::string &id);
|
||||
Invalidation & setObjectType(ObjectType type);
|
||||
Invalidation & setInvalidationType(InvalidationType type);
|
||||
|
||||
std::string getClassifier(ClassifierType type) const { return classifiers[type]; }
|
||||
Maybe<std::string, void> getStringMainAttr(const std::string &attr) const;
|
||||
Maybe<std::set<std::string>, void> getStringSetMainAttr(const std::string &attr) const;
|
||||
Maybe<std::string, void> getStringAttr(const std::string &attr) const;
|
||||
Maybe<std::set<std::string>, void> getStringSetAttr(const std::string &attr) const;
|
||||
const Maybe<std::string, void> & getSourceId() const { return source_id; }
|
||||
const Maybe<ObjectType, void> & getObjectType() const { return object_type; }
|
||||
InvalidationType getInvalidationType() const { return invalidation_type; }
|
||||
|
||||
bool report(I_Intelligence_IS_V2 *interface) const;
|
||||
|
||||
@@ -59,13 +64,17 @@ public:
|
||||
bool matches(const Invalidation &other) const;
|
||||
|
||||
private:
|
||||
bool hasMainAttr(const std::string &key, const std::string &value) const;
|
||||
bool hasAttr(const std::string &key, const std::string &value) const;
|
||||
|
||||
EnumArray<ClassifierType, std::string, 6> classifiers;
|
||||
std::map<std::string, std::string> string_main_attr;
|
||||
std::map<std::string, std::set<std::string>> set_string_main_attr;
|
||||
std::map<std::string, std::string> string_attr;
|
||||
std::map<std::string, std::set<std::string>> set_string_attr;
|
||||
Maybe<std::string, void> source_id;
|
||||
Maybe<ObjectType, void> object_type;
|
||||
InvalidationType invalidation_type = InvalidationType::ADD;
|
||||
Maybe<uint, void> listening_id;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user