Skip to content

Commit

Permalink
chore: apply feedbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Rulleau <[email protected]>
  • Loading branch information
Leiyks committed Feb 19, 2025
1 parent 1bec590 commit 69e8880
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 46 deletions.
2 changes: 0 additions & 2 deletions appsec/src/extension/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef DD_ATTRIBUTES_H
#define DD_ATTRIBUTES_H

#include "configuration.h"

#ifndef __has_feature
# define __has_feature(x) 0
#endif
Expand Down
10 changes: 5 additions & 5 deletions appsec/src/extension/commands_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,14 @@ static void dd_command_process_settings(mpack_node_t root)
mpack_node_t value = mpack_node_map_value_at(root, i);

if (mpack_node_type(key) != mpack_type_str) {
mlog(dd_log_warning, "Failed to process user collection setting: "
mlog(dd_log_warning, "Failed to process unknown setting: "
"invalid type for key");
return;
continue;
}
if (mpack_node_type(value) != mpack_type_str) {
mlog(dd_log_warning, "Failed to process user collection setting: "
mlog(dd_log_warning, "Failed to process unknown setting: "
"invalid type for value");
return;
continue;
}

const char *key_str = mpack_node_str(key);
Expand All @@ -599,7 +599,7 @@ static void dd_command_process_settings(mpack_node_t root)
"unknown key %.*s",
(int)key_len, key_str);
}
return;
continue;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion appsec/src/extension/commands_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.
#pragma once

#include "attributes.h"
#include "commands_ctx.h"
#include "attributes.h"
#include "dddefs.h"
#include "network.h"
#include <mpack.h>
Expand Down
1 change: 1 addition & 0 deletions appsec/src/extension/user_tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.
#pragma once

#include "zai_string/string.h"
#include "attributes.h"
#include <zend.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ void asm_features_listener::init()
ruleset_ = rapidjson::Document(rapidjson::kObjectType);
aggregator_ = std::make_unique<asm_features_aggregator>();
aggregator_->init(&ruleset_.GetAllocator());
}

void asm_features_listener::on_unapply(const config & /*config*/)
{
service_config_->unset_asm();
service_config_->unset_auto_user_instrum();
}
Expand Down Expand Up @@ -103,4 +99,4 @@ void asm_features_listener::commit()
service_config_->set_auto_user_instrum(mode);
}

} // namespace dds::remote_config
} // namespace dds::remote_config
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class asm_features_listener : public listener_base {

void init() override;
void on_update(const config &config) override;
void on_unapply(const config &config) override;
void on_unapply(const config &config) override {}
void commit() override;

[[nodiscard]] std::unordered_set<product> get_supported_products() override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,36 +571,4 @@ TEST(RemoteConfigAsmFeaturesListener, ErrorConfigInvalidEnabledKey)
remote_config_service->get_auto_user_intrum_mode());
EXPECT_EQ(0, error_message.compare(expected_error_message));
}

TEST(RemoteConfigAsmFeaturesListener, UnapplyWithAsmEnabled)
{
auto remote_config_service = std::make_shared<service_config>();
remote_config::asm_features_listener listener(remote_config_service);
listener.init();

EXPECT_EQ(enable_asm_status::NOT_SET,
remote_config_service->get_asm_enabled_status());
EXPECT_EQ(auto_user_instrum_mode::UNDEFINED,
remote_config_service->get_auto_user_intrum_mode());

try {
listener.on_update(get_asm_enabled_config());
listener.on_update(get_auto_user_instrum_config());
listener.commit();
} catch (remote_config::error_applying_config &error) {
std::cout << error.what() << std::endl;
}

EXPECT_EQ(enable_asm_status::ENABLED,
remote_config_service->get_asm_enabled_status());
EXPECT_EQ(auto_user_instrum_mode::IDENTIFICATION,
remote_config_service->get_auto_user_intrum_mode());

listener.on_unapply(get_asm_enabled_config());

EXPECT_EQ(enable_asm_status::NOT_SET,
remote_config_service->get_asm_enabled_status());
EXPECT_EQ(auto_user_instrum_mode::UNDEFINED,
remote_config_service->get_auto_user_intrum_mode());
}
} // namespace dds

0 comments on commit 69e8880

Please sign in to comment.