-
Notifications
You must be signed in to change notification settings - Fork 14
Add DD_NO_SECURITY_AGENT_INSTALL option #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lebauce
wants to merge
1
commit into
main
Choose a base branch
from
lebauce/no-security-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+257
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" | ||
| awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/provisioners/aws/host" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| type installNoSecurityAgentTestSuite struct { | ||
| linuxInstallerTestSuite | ||
| } | ||
|
|
||
| func TestInstallNoSecurityAgentSuite(t *testing.T) { | ||
| if flavor != agentFlavorDatadogAgent { | ||
| t.Skip("no security agent test supports only datadog-agent flavor") | ||
| } | ||
| stackName := fmt.Sprintf("install-no-security-agent-%s-%s-%s", flavor, platform, getenv("CI_PIPELINE_ID", "dev")) | ||
| t.Run(stackName, func(t *testing.T) { | ||
| t.Logf("We will install %s without the security agent with install script on %s", flavor, platform) | ||
| testSuite := &installNoSecurityAgentTestSuite{} | ||
| e2e.Run(t, | ||
| testSuite, | ||
| e2e.WithProvisioner(awshost.ProvisionerNoAgentNoFakeIntake(awshost.WithEC2InstanceOptions(getEC2Options(t)...))), | ||
| e2e.WithStackName(stackName), | ||
| ) | ||
| }) | ||
| } | ||
|
|
||
| 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") | ||
|
|
||
| s.assertInstallScript() | ||
|
|
||
| s.addExtraIntegration() | ||
|
|
||
| s.uninstall() | ||
|
|
||
| s.assertUninstall() | ||
|
|
||
| s.purge() | ||
|
|
||
| s.assertPurge() | ||
| } | ||
|
|
||
| func (s *installNoSecurityAgentTestSuite) assertInstallScript() { | ||
| s.linuxInstallerTestSuite.assertInstallScript(true) | ||
|
|
||
| t := s.T() | ||
| vm := s.Env().RemoteHost | ||
|
|
||
| t.Log("Assert system probe config is created and the security agent config is not") | ||
| assertFileExists(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, systemProbeConfigFileName)) | ||
| assertFileNotExists(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, securityAgentConfigFileName)) | ||
|
|
||
| t.Log("Assert runtime security is enabled in the system probe config and sent from system-probe") | ||
| systemProbeConfig := unmarshalConfigFile(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, systemProbeConfigFileName)) | ||
| runtimeSecurityConfig := systemProbeConfig["runtime_security_config"].(map[any]any) | ||
| assert.Equal(t, true, runtimeSecurityConfig["enabled"]) | ||
| assert.Equal(t, true, runtimeSecurityConfig["direct_send_from_system_probe"]) | ||
|
|
||
| t.Log("Assert compliance runs in system-probe") | ||
| agentConfig := unmarshalConfigFile(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, s.configFile)) | ||
| complianceConfig := agentConfig["compliance_config"].(map[any]any) | ||
| assert.Equal(t, true, complianceConfig["enabled"]) | ||
| assert.Equal(t, true, complianceConfig["run_in_system_probe"]) | ||
| } | ||
|
|
||
| func (s *installNoSecurityAgentTestSuite) assertUninstall() { | ||
| s.linuxInstallerTestSuite.assertUninstall() | ||
| t := s.T() | ||
| vm := s.Env().RemoteHost | ||
| t.Log("Assert system probe config is still there after uninstall") | ||
| assertFileExists(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, systemProbeConfigFileName)) | ||
| assertFileNotExists(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, securityAgentConfigFileName)) | ||
| } | ||
|
|
||
| func (s *installNoSecurityAgentTestSuite) assertPurge() { | ||
| if s.shouldSkipPurge() { | ||
| return | ||
| } | ||
| s.linuxInstallerTestSuite.assertPurge() | ||
| t := s.T() | ||
| vm := s.Env().RemoteHost | ||
| t.Log("Assert system probe config is removed after purge") | ||
| assertFileNotExists(t, vm, fmt.Sprintf("/etc/%s/%s", s.baseName, systemProbeConfigFileName)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a retained configuration already contains any of these keys with
false(for example,compliance_config.enabled: falseindatadog.yamlordirect_send_from_system_probe: falseinsystem-probe.yaml), this presence-only check skips the requested update. Consequently,DD_NO_SECURITY_AGENT_INSTALL=true DD_COMPLIANCE_CONFIG_ENABLED=truecan leave CSPM disabled or leave CWS sending through the security Agent, despite the migration option explicitly requesting that they run in system-probe. Update the existing value when it conflicts with the requiredtruevalue rather than treating every pre-existing key as idempotent success.Useful? React with 👍 / 👎.