Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ The install script allows installation of different flavors of the Agent binarie
|`DD_APM_INSTRUMENTATION_LIBRARIES`|Specify the APM library to be installed. Possible values are `all`, `java`, `js`, `python`, `dotnet` and `ruby`. Does not run the APM injection script, which is triggered by `DD_APM_INSTRUMENTATION_ENABLED` or `DD_APM_INSTRUMENTATION_STRICT`.|
|`DD_APM_ERROR_TRACKING_STANDALONE`|Enable Error Tracking standalone for backend services.|
|`DD_SYSTEM_PROBE_ENSURE_CONFIG`|Create the system probe configuration file from a template if it does not already exist.|
|`DD_RUNTIME_SECURITY_CONFIG_ENABLED`|If set to `true`, ensure creation of security Agent and system probe configuration file (if they don't already exist), and enable Cloud Workload Security (CWS).|
|`DD_COMPLIANCE_CONFIG_ENABLED`|If set to `true`, ensures the creation of a security Agent configuration file if one doesn't already exist, and enables Cloud Security Posture Management (CSPM).|
|`DD_NO_SECURITY_AGENT_INSTALL`|Set to any value to run Cloud Workload Security (CWS) and Cloud Security Posture Management (CSPM) in the system probe instead of the security Agent. With `DD_RUNTIME_SECURITY_CONFIG_ENABLED=true`, CWS is enabled in the system probe configuration file, which also sends the events directly. With `DD_COMPLIANCE_CONFIG_ENABLED=true`, CSPM is enabled in the Agent configuration file and runs in the system probe. The security Agent configuration file is never created, but if it already exists it is updated to tell the security Agent that CWS and CSPM run in the system probe, so that it stops. These settings are applied even when the configuration files are kept from a previous installation.|
|`DD_RUNTIME_SECURITY_CONFIG_ENABLED`|If set to `true`, ensure creation of security Agent and system probe configuration file (if they don't already exist), and enable Cloud Workload Security (CWS). The security Agent configuration file is not created when CWS runs in the system probe, see `DD_NO_SECURITY_AGENT_INSTALL`.|
|`DD_COMPLIANCE_CONFIG_ENABLED`|If set to `true`, ensures the creation of a security Agent configuration file if one doesn't already exist, and enables Cloud Security Posture Management (CSPM). The security Agent configuration file is not created when CSPM runs in the system probe, see `DD_NO_SECURITY_AGENT_INSTALL`.|
|`DD_NO_SECURITY_AGENT_INSTALL`|Run Cloud Workload Security (CWS) and Cloud Security Posture Management (CSPM) in the system probe instead of the security Agent. Enabled by default when installing Agent 7.77.0 or later (including the latest version). Set to `false` to keep running CWS and CSPM in the security Agent, or to any other value to force it for older versions. With `DD_RUNTIME_SECURITY_CONFIG_ENABLED=true`, CWS is enabled in the system probe configuration file, which also sends the events directly. With `DD_COMPLIANCE_CONFIG_ENABLED=true`, CSPM is enabled in the Agent configuration file and runs in the system probe. The security Agent configuration file is never created, but if it already exists it is updated to tell the security Agent that CWS and CSPM run in the system probe, so that it stops. These settings are applied even when the configuration files are kept from a previous installation.|
|`DD_DISCOVERY_ENABLED`|If set to `true`, and a system probe configuration file does not already exist, creates a system probe configuration file and enables Service Discovery.
|`DD_PRIVILEGED_LOGS_ENABLED`|If set to `true`, and a system probe configuration file does not already exist, creates a system probe configuration file and enables Privileged Logs.
|`DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED`|If set to `true`, and a system probe configuration file does not already exist, creates a system probe configuration file and enables Universal Service Monitoring (USM).
Expand Down
47 changes: 41 additions & 6 deletions install_script.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,6 @@ if [ -n "$DD_NO_AGENT_INSTALL" ]; then
no_agent=true
fi

no_security_agent=
if [ -n "$DD_NO_SECURITY_AGENT_INSTALL" ]; then
no_security_agent=true
fi

infrastructure_mode=
if [ -n "$DD_INFRASTRUCTURE_MODE" ]; then
infrastructure_mode=$DD_INFRASTRUCTURE_MODE
Expand Down Expand Up @@ -2382,12 +2377,47 @@ EOF
printf "\033[34m\n* Setting $section.$option to $value in $config_file\n\033[0m\n"
$sudo_cmd sh -c "sed -i '0,/^$section:/s//$section:\n${indent:- }$option: $value/' $config_file"
}
function is_config_option_true(){
local sudo_cmd="$1"
local config_file="$2"
local section="$3"
local option="$4"
$sudo_cmd test -e "$config_file" || return 1
# Only consider the keys at the first indentation level of the section, see set_config_option
local section_content indent
section_content=$($sudo_cmd sed -n "/^$section:/,/^[^[:space:]#]/p" "$config_file")
indent=$(echo "$section_content" | grep -E "^[[:space:]]+[^[:space:]#]" | head -n 1 | sed -E "s/^([[:space:]]+).*/\1/")
[ -n "$indent" ] && echo "$section_content" | grep -qiE "^${indent}${option}:[[:space:]]*true[[:space:]]*(#.*)?$"
}
function resolve_no_security_agent(){
local no_security_agent_install="$1"
local agent_major_version="$2"
local agent_minor_version="$3"
# Explicitly set: "false" keeps the security Agent, any other value runs CWS and CSPM in system-probe
if [ "$no_security_agent_install" == "false" ]; then
return
elif [ -n "$no_security_agent_install" ]; then
echo "true"
return
fi
# By default, CWS and CSPM run in system-probe when the Agent supports it, starting with 7.77.0
local minor_without_patch="${agent_minor_version%%.*}"
if [ "$agent_major_version" == "7" ] && { [ -z "$minor_without_patch" ] || [ "$minor_without_patch" -ge 77 ] 2>/dev/null; }; then
echo "true"
Comment thread
lebauce marked this conversation as resolved.
Resolved
fi
}
function run_security_in_system_probe(){
local sudo_cmd="$1"
local core_config_file="$2"
local security_config_file="$3"
local probe_config_file="$4"
local enable_compliance="$5"
# CSPM enabled by a previous installation is usually only configured in the security Agent
# configuration file, which stops running it below, so it has to be enabled in the Agent
# configuration file for system-probe to run it
if is_config_option_true "$sudo_cmd" "$security_config_file" "compliance_config" "enabled"; then
enable_compliance="true"
fi
# The security Agent service starts as soon as its configuration file exists, so it needs to
# know that both CWS and CSPM run in system-probe to stop right away. The file is only updated
# when it already exists, it must never be created.
Expand Down Expand Up @@ -2496,6 +2526,11 @@ function manage_otel_config(){
$sudo_cmd sh -c "sed -i -e 's/\${env:DD_API_KEY}/$apikey/' -e 's/\${env:DD_SITE}/$site/' $otel_config_file"
fi
}
# Run CWS and CSPM in system-probe instead of the security Agent, unless
# DD_NO_SECURITY_AGENT_INSTALL=false or the installed Agent doesn't support it.
# Resolved here because the minor version may be lowered on old distributions.
no_security_agent=$(resolve_no_security_agent "$DD_NO_SECURITY_AGENT_INSTALL" "$agent_major_version" "$clean_agent_minor_version")

# "Main" configuration update
if [ -e "$config_file" ] && [ -z "$upgrade" ]; then
printf "\033[34m\n* Keeping old $config_file configuration file\n\033[0m\n"
Expand Down Expand Up @@ -2565,7 +2600,7 @@ if [ -n "$system_probe_ensure_config" ]; then
ensure_config_file_exists "$sudo_cmd" "$system_probe_config_file" "root"
fi

# Make sure the security Agent doesn't run when DD_NO_SECURITY_AGENT_INSTALL is set, even when
# Make sure the security Agent doesn't run when CWS and CSPM run in system-probe, even when
# the configuration files were kept from a previous installation
if [ -n "$no_security_agent" ]; then
run_security_in_system_probe "$sudo_cmd" "$config_file" "$security_agent_config_file" "$system_probe_config_file" "$DD_COMPLIANCE_CONFIG_ENABLED"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/install_compliance_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestInstallComplianceAgentSuite(t *testing.T) {
}

func (s *installComplianceAgentTestSuite) TestInstallComplianceAgent() {
s.InstallAgent(7, "DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7")
s.InstallAgent(7, "DD_NO_SECURITY_AGENT_INSTALL=false DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7")

s.assertInstallScript()

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/install_maximal_and_replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func TestInstallMaximalAndRetrySuite(t *testing.T) {
}

func (s *installMaximalAndRetryTestSuite) TestInstallMaximalAndReplayScript() {
output := s.InstallAgent(7, "DD_TAGS=\"foo:bar,baz:toto\" DD_ENV=kiki DD_HOSTNAME=totoro DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"mysite.com\" DD_URL=myintake.com", "install agent 7 with maximal environment variables")
output := s.InstallAgent(7, "DD_TAGS=\"foo:bar,baz:toto\" DD_ENV=kiki DD_HOSTNAME=totoro DD_NO_SECURITY_AGENT_INSTALL=false DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"mysite.com\" DD_URL=myintake.com", "install agent 7 with maximal environment variables")

s.assertInstallMaximal(output)

s.addExtraIntegration()

output = s.InstallAgent(7, "DD_TAGS=\"john:doe,john:lennon\" DD_ENV=totoro DD_HOSTNAME=kiki DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=darthmaul.com DD_URL=otherintake.com", "install Agent 7 RC again with new environment variables")
output = s.InstallAgent(7, "DD_TAGS=\"john:doe,john:lennon\" DD_ENV=totoro DD_HOSTNAME=kiki DD_NO_SECURITY_AGENT_INSTALL=false DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=darthmaul.com DD_URL=otherintake.com", "install Agent 7 RC again with new environment variables")

s.assertRetryInstall(output)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/install_no_security_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestInstallNoSecurityAgentSuite(t *testing.T) {
}

func (s *installNoSecurityAgentTestSuite) TestInstallNoSecurityAgent() {
s.InstallAgent(7, "DD_NO_SECURITY_AGENT_INSTALL=true DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7 without the security agent")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to change it to DD_NO_SECURITY_AGENT_INSTALL=false instead of removing it? This makes the test dependent upon the default behavior, which is a bit fragile, and the test name doesn't indicate that this is meant to test default behavior.

s.InstallAgent(7, "DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_COMPLIANCE_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7, without the security agent by default")

s.assertInstallScript()

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/install_security_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestInstallSecurityAgentSuite(t *testing.T) {
}

func (s *installSecurityAgentTestSuite) TestInstallSecurityAgent() {
s.InstallAgent(7, "DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7 ")
s.InstallAgent(7, "DD_NO_SECURITY_AGENT_INSTALL=false DD_RUNTIME_SECURITY_CONFIG_ENABLED=true DD_SITE=\"datadoghq.com\"", "Install latest Agent 7 ")

s.assertInstallScript()

Expand Down
2 changes: 1 addition & 1 deletion test/localtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi

# Override curl to capture trace payloads (only if SHOW_TRACE is enabled)
if [[ "${SHOW_TRACE}" == "1" ]]; then
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
curl() {
if [[ "$*" == *"instrumentation-telemetry-intake"* ]]; then
echo "[TRACE CAPTURE] Intercepting telemetry submission" >&2
Expand Down
41 changes: 41 additions & 0 deletions unit_tests/test_install_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,26 @@ testSystemProbeConfigNetworkAlreadyConfigured(){
}

### DD_NO_SECURITY_AGENT_INSTALL
testResolveNoSecurityAgentDefault(){
assertEquals "true" "$(resolve_no_security_agent "" 7 "")"
assertEquals "true" "$(resolve_no_security_agent "" 7 "77")"
assertEquals "true" "$(resolve_no_security_agent "" 7 "77.0")"
assertEquals "true" "$(resolve_no_security_agent "" 7 "78.1")"
assertEquals "true" "$(resolve_no_security_agent "" 7 "100.0")"
}
testResolveNoSecurityAgentDefaultUnsupportedVersion(){
assertEquals "" "$(resolve_no_security_agent "" 7 "76.3")"
assertEquals "" "$(resolve_no_security_agent "" 7 "51")"
assertEquals "" "$(resolve_no_security_agent "" 6 "")"
assertEquals "" "$(resolve_no_security_agent "" 6 "77.0")"
}
testResolveNoSecurityAgentExplicit(){
assertEquals "" "$(resolve_no_security_agent "false" 7 "")"
assertEquals "" "$(resolve_no_security_agent "false" 7 "78.0")"
assertEquals "true" "$(resolve_no_security_agent "true" 7 "")"
assertEquals "true" "$(resolve_no_security_agent "1" 7 "76.0")"
assertEquals "true" "$(resolve_no_security_agent "true" 6 "")"
}
testNoSecurityAgentDoesNotCreateSecurityAgentConfig(){
sudo rm $security_agent_config_file 2> /dev/null
manage_security_config "sudo" $security_agent_config_file true true true
Expand Down Expand Up @@ -403,6 +423,27 @@ testRunSecurityInSystemProbeExistingSecurityAgentConfig(){
# CSPM is not enabled, the Agent configuration file must not be updated
assertEquals "$(sudo yq eval '.compliance_config' $config_file)" "null"
}
testRunSecurityInSystemProbeKeptSecurityAgentCompliance(){
# CSPM enabled by a previous installation only in the security Agent configuration file must
# be enabled in the Agent configuration file, even without DD_COMPLIANCE_CONFIG_ENABLED
sudo cp ${config_file}.example $config_file
sudo rm $system_probe_config_file 2> /dev/null
printf 'compliance_config:\n enabled: true\n' | sudo tee $security_agent_config_file > /dev/null
run_security_in_system_probe "sudo" $config_file $security_agent_config_file $system_probe_config_file ""
yamllint -c "$yaml_config" --no-warnings $config_file
assertEquals 0 $?
assertEquals "$(sudo yq eval '.compliance_config.enabled' $config_file)" "true"
assertEquals "$(sudo yq eval '.compliance_config.run_in_system_probe' $config_file)" "true"
assertEquals "$(sudo yq eval '.compliance_config.run_in_system_probe' $security_agent_config_file)" "true"
}
testRunSecurityInSystemProbeKeptSecurityAgentComplianceDisabled(){
# CSPM disabled, or only enabled in a nested section, must not be enabled
sudo cp ${config_file}.example $config_file
sudo rm $system_probe_config_file 2> /dev/null
printf 'compliance_config:\n enabled: false\n database_benchmarks:\n enabled: true\n' | sudo tee $security_agent_config_file > /dev/null
run_security_in_system_probe "sudo" $config_file $security_agent_config_file $system_probe_config_file ""
assertEquals "$(sudo yq eval '.compliance_config' $config_file)" "null"
}
testRunSecurityInSystemProbeKeptConfiguration(){
# CWS and CSPM enabled by a previous installation must now run in system-probe
printf 'apm_config:\n enabled: true\n' | sudo tee $config_file > /dev/null
Expand Down
Loading