Skip to content

Commit

Permalink
Remove experimental API security config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 committed Dec 5, 2023
1 parent ad219c7 commit 97aca8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
17 changes: 14 additions & 3 deletions appsec/src/extension/commands/client_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,21 @@ static dd_result _pack_command(
mpack_start_map(w, 2);

dd_mpack_write_lstr(w, "enabled");
mpack_write_bool(w, get_global_DD_EXPERIMENTAL_API_SECURITY_ENABLED());

dd_mpack_write_lstr(w, "sample_rate");
mpack_write(w, get_global_DD_API_SECURITY_REQUEST_SAMPLE_RATE());
#define MIN_SE_SAMPLE_RATE 0.0001

double se_sample_rate = get_global_DD_API_SECURITY_REQUEST_SAMPLE_RATE();
if (se_sample_rate >= MIN_SE_SAMPLE_RATE) {
mpack_write_bool(w, true);

dd_mpack_write_lstr(w, "sample_rate");
mpack_write(w, se_sample_rate);
} else {
mpack_write_bool(w, false);

dd_mpack_write_lstr(w, "sample_rate");
mpack_write(w, 0.0);
}

mpack_finish_map(w);

Expand Down
1 change: 0 additions & 1 deletion appsec/src/extension/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ extern bool runtime_config_first_init;
CONFIG(CUSTOM(STRING), DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING, "safe", .parser = dd_parse_automated_user_events_tracking) \
CONFIG(STRING, DD_APPSEC_HTTP_BLOCKED_TEMPLATE_HTML, "") \
CONFIG(STRING, DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON, "") \
CONFIG(BOOL, DD_EXPERIMENTAL_API_SECURITY_ENABLED, "false") \
CONFIG(DOUBLE, DD_API_SECURITY_REQUEST_SAMPLE_RATE, "0.1")
// clang-format on

Expand Down
3 changes: 0 additions & 3 deletions appsec/tests/extension/api_security_env_variables.phpt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
--TEST--
Set and test API security ini settings
--ENV--
DD_EXPERIMENTAL_API_SECURITY_ENABLED=1
DD_API_SECURITY_REQUEST_SAMPLE_RATE=0.8
--FILE--
<?php
var_dump(ini_get("datadog.experimental_api_security_enabled"));
var_dump(ini_get("datadog.api_security_request_sample_rate"));
?>
--EXPECTF--
string(1) "1"
string(3) "0.8"

0 comments on commit 97aca8b

Please sign in to comment.