Skip to content

Commit

Permalink
chore(helper): correct variable names
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Rulleau <[email protected]>
  • Loading branch information
Leiyks committed Nov 19, 2024
1 parent 5e0cb00 commit 7e3a0f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions appsec/src/helper/subscriber/waf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ void instance::listener::call(dds::parameter_view &data, event &event)
// NOLINTNEXTLINE
total_runtime_ += res.total_runtime / 1000.0;

const parameter_view schemas{res.derivatives};
for (const auto &schema : schemas) {
schemas_.emplace(schema.key(), std::move(parameter_to_json(schema)));
const parameter_view derivatives{res.derivatives};
for (const auto &derivative : derivatives) {
derivatives_.emplace(
derivative.key(), std::move(parameter_to_json(derivative)));
}

switch (code) {
Expand Down Expand Up @@ -264,19 +265,19 @@ void instance::listener::get_meta_and_metrics(
meta[std::string(tag::event_rules_version)] = ruleset_version_;
metrics[tag::waf_duration] = total_runtime_;

for (const auto &[key, value] : schemas_) {
std::string schema = value;
for (const auto &[key, value] : derivatives_) {
std::string derivative = value;
if (value.length() > max_plain_schema_allowed &&
key.starts_with("_dd.appsec.s")) {

auto encoded = compress(schema);
auto encoded = compress(derivative);
if (encoded) {
schema = base64_encode(encoded.value(), false);
derivative = base64_encode(encoded.value(), false);
}
}

if (schema.length() <= max_schema_size) {
meta.emplace(key, std::move(schema));
if (derivative.length() <= max_schema_size) {
meta.emplace(key, std::move(derivative));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion appsec/src/helper/subscriber/waf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class instance : public dds::subscriber {
std::chrono::microseconds waf_timeout_;
double total_runtime_{0.0};
std::string_view ruleset_version_;
std::map<std::string, std::string> schemas_;
std::map<std::string, std::string> derivatives_;
};

// NOLINTNEXTLINE(google-runtime-references)
Expand Down

0 comments on commit 7e3a0f8

Please sign in to comment.