-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Set OpenSSL paths in registry #31960
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
Changes from all commits
2b69224
4a496d6
19319a4
863cff2
f5d9745
a1dba65
f1049a8
c69b880
363bf32
5514679
58ec243
9770351
8ac1377
e1acb4d
defe6bd
8ead899
4ba5bc3
2e5630c
35c7021
07113bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,16 +72,23 @@ def _get_vs_build_command(cmd, vstudio_root=None): | |
| return cmd | ||
|
|
||
|
|
||
| def _get_env(ctx, major_version='7', release_version='nightly'): | ||
| def _get_env(ctx, major_version='7', release_version='nightly-a7', flavor=None): | ||
| env = load_release_versions(ctx, release_version) | ||
|
|
||
| if flavor is None: | ||
| flavor = os.getenv("AGENT_FLAVOR", "") | ||
|
|
||
| env['PACKAGE_VERSION'] = get_version( | ||
| ctx, include_git=True, url_safe=True, major_version=major_version, include_pipeline_id=True | ||
| ) | ||
| env['AGENT_FLAVOR'] = os.getenv("AGENT_FLAVOR", "") | ||
| env['AGENT_FLAVOR'] = flavor | ||
| env['AGENT_INSTALLER_OUTPUT_DIR'] = BUILD_OUTPUT_DIR | ||
| env['NUGET_PACKAGES_DIR'] = NUGET_PACKAGES_DIR | ||
| env['AGENT_PRODUCT_NAME_SUFFIX'] = "" | ||
| # Used for installation directories registry keys | ||
| # https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#installation-directories | ||
| # TODO: How best to configure the OpenSSL version? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good question, because the version is spread among various files and can easily lead to version conflicts. Is there a ticket for tracking?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that if there is ever another SSL vulnerability like the Heartbleed bug, we need to act ASAP. |
||
| env['AGENT_OPENSSL_VERSION'] = "3.4" | ||
|
|
||
| return env | ||
|
|
||
|
|
@@ -281,12 +288,19 @@ def _msi_output_name(env): | |
|
|
||
| @task | ||
| def build( | ||
| ctx, vstudio_root=None, arch="x64", major_version='7', release_version='nightly', debug=False, build_upgrade=False | ||
| ctx, | ||
| vstudio_root=None, | ||
| arch="x64", | ||
| major_version='7', | ||
| release_version='nightly-a7', | ||
| flavor=None, | ||
| debug=False, | ||
| build_upgrade=False, | ||
| ): | ||
| """ | ||
| Build the MSI installer for the agent | ||
| """ | ||
| env = _get_env(ctx, major_version, release_version) | ||
| env = _get_env(ctx, major_version, release_version, flavor=flavor) | ||
| env['OMNIBUS_TARGET'] = 'main' | ||
| configuration = _msbuild_configuration(debug=debug) | ||
| build_outdir = build_out_dir(arch, configuration) | ||
|
|
@@ -385,7 +399,7 @@ def build_installer(ctx, vstudio_root=None, arch="x64", debug=False): | |
|
|
||
|
|
||
| @task | ||
| def test(ctx, vstudio_root=None, arch="x64", major_version='7', release_version='nightly', debug=False): | ||
| def test(ctx, vstudio_root=None, arch="x64", major_version='7', release_version='nightly-a7', debug=False): | ||
| """ | ||
| Run the unit test for the MSI installer for the agent | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| // 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 2024-present Datadog, Inc. | ||
|
|
||
| package fipscompliance | ||
|
|
||
| import ( | ||
| _ "embed" | ||
| "fmt" | ||
| "path/filepath" | ||
| "time" | ||
|
|
||
| "github.com/DataDog/test-infra-definitions/components/datadog/agentparams" | ||
|
|
||
| fakeintakeclient "github.com/DataDog/datadog-agent/test/fakeintake/client" | ||
| "github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" | ||
| "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" | ||
| awsHostWindows "github.com/DataDog/datadog-agent/test/new-e2e/pkg/provisioners/aws/host/windows" | ||
| "github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client" | ||
| windowsCommon "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/common" | ||
| windowsAgent "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/common/agent" | ||
| "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/components/fipsmode" | ||
|
|
||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| //go:embed fixtures/e2e_fips_test.py | ||
| var fipsTestCheck string | ||
|
|
||
| type windowsVMSuite struct { | ||
| e2e.BaseSuite[environments.WindowsHost] | ||
|
|
||
| installPath string | ||
| } | ||
|
|
||
| // TestWindowsVM tests that the FIPS Agent can report metrics to the fakeintake | ||
| func TestWindowsVM(t *testing.T) { | ||
| suiteParams := []e2e.SuiteOption{e2e.WithProvisioner(awsHostWindows.Provisioner( | ||
| // Enable FIPS mode on the host (done before Agent install) | ||
| awsHostWindows.WithFIPSModeOptions(fipsmode.WithFIPSModeEnabled()), | ||
| awsHostWindows.WithAgentOptions( | ||
| // Use FIPS Agent package | ||
| agentparams.WithFlavor(agentparams.FIPSFlavor), | ||
| // Install custom check that reports the FIPS mode of Python | ||
| // TODO ADXT-881: Need forward slashes to workaround test-infra bug | ||
| agentparams.WithFile( | ||
| `C:/ProgramData/Datadog/checks.d/e2e_fips_test.py`, | ||
| fipsTestCheck, | ||
| false, | ||
| ), | ||
| agentparams.WithFile( | ||
| `C:/ProgramData/Datadog/conf.d/e2e_fips_test.yaml`, | ||
| ` | ||
| init_config: | ||
| instances: [{}] | ||
| `, | ||
| false, | ||
| ), | ||
| ), | ||
| ))} | ||
|
|
||
| e2e.Run(t, &windowsVMSuite{}, suiteParams...) | ||
| } | ||
|
|
||
| func (s *windowsVMSuite) SetupSuite() { | ||
| s.BaseSuite.SetupSuite() | ||
| host := s.Env().RemoteHost | ||
| var err error | ||
|
|
||
| s.installPath, err = windowsAgent.GetInstallPathFromRegistry(host) | ||
| s.Require().NoError(err) | ||
| } | ||
|
|
||
| // TestVersionCommands tests that the version command for each of the Agent binaries | ||
| // works when FIPS mode is enabled and panics when GOFIPS=1 AND the system is not in FIPS mode. | ||
| func (s *windowsVMSuite) TestVersionCommands() { | ||
| host := s.Env().RemoteHost | ||
|
|
||
| windowsCommon.EnableFIPSMode(host) | ||
| s.Run("System FIPS Enabled", func() { | ||
| s.testAgentBinaries(func(executable string) { | ||
| var err error | ||
| _, err = s.execAgentCommandWithFIPS(executable, "version") | ||
| s.Assert().NoError(err) | ||
| _, err = s.execAgentCommand(executable, "version") | ||
| s.Assert().NoError(err) | ||
| }) | ||
| }) | ||
|
|
||
| windowsCommon.DisableFIPSMode(host) | ||
| s.Run("System FIPS Disabled", func() { | ||
| s.testAgentBinaries(func(executable string) { | ||
| var err error | ||
| _, err = s.execAgentCommandWithFIPS(executable, "version") | ||
| assertErrorContainsFIPSPanic(s.T(), err, "agent should panic when GOFIPS=1 but system FIPS is disabled") | ||
| _, err = s.execAgentCommand(executable, "version") | ||
| s.Assert().NoError(err) | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| // TestAgentStatusOutput tests that the Agent status command reports the correct FIPS mode status | ||
| func (s *windowsVMSuite) TestAgentStatusOutput() { | ||
| host := s.Env().RemoteHost | ||
|
|
||
| windowsCommon.EnableFIPSMode(host) | ||
| s.Run("status command", func() { | ||
| s.Run("gofips enabled", func() { | ||
| status, err := s.execAgentCommandWithFIPS("agent.exe", "status") | ||
| require.NoError(s.T(), err) | ||
| assert.Contains(s.T(), status, "FIPS Mode: enabled") | ||
| }) | ||
|
|
||
| s.Run("gofips disabled", func() { | ||
| status, err := s.execAgentCommand("agent.exe", "status") | ||
| require.NoError(s.T(), err) | ||
| assert.Contains(s.T(), status, "FIPS Mode: enabled", "FIPS Mode should not depend on GOFIPS") | ||
| }) | ||
| }) | ||
|
|
||
| windowsCommon.DisableFIPSMode(host) | ||
| s.Run("status command", func() { | ||
| s.Run("gofips disabled", func() { | ||
| status, err := s.execAgentCommand("agent.exe", "status") | ||
| require.NoError(s.T(), err) | ||
| assert.Contains(s.T(), status, "FIPS Mode: disabled") | ||
| }) | ||
| }) | ||
|
|
||
| } | ||
|
|
||
| // TestReportsFIPSStatusMetrics tests that the custom check from our fixtures | ||
| // is able to report metrics while in FIPS mode. These metric values are based | ||
| // on the status of Python's FIPS mode. | ||
| func (s *windowsVMSuite) TestReportsFIPSStatusMetrics() { | ||
| host := s.Env().RemoteHost | ||
| // Restart the Agent and reset the aggregator to ensure the metrics are fresh | ||
| // with FIPS mode enabled. | ||
| err := windowsCommon.StopService(host, "datadogagent") | ||
| require.NoError(s.T(), err) | ||
| err = s.Env().FakeIntake.Client().FlushServerAndResetAggregators() | ||
| require.NoError(s.T(), err) | ||
| err = windowsCommon.EnableFIPSMode(host) | ||
| require.NoError(s.T(), err) | ||
| err = windowsCommon.StartService(host, "datadogagent") | ||
| require.NoError(s.T(), err) | ||
|
|
||
| s.EventuallyWithT(func(c *assert.CollectT) { | ||
| metrics, err := s.Env().FakeIntake.Client().FilterMetrics("e2e.fips_mode", fakeintakeclient.WithMetricValueHigherThan(0)) | ||
| assert.NoError(c, err) | ||
| assert.Greater(c, len(metrics), 0, "no 'e2e.fips_mode' with value higher than 0 yet") | ||
|
|
||
| metrics, err = s.Env().FakeIntake.Client().FilterMetrics("e2e.fips_dll_loaded", fakeintakeclient.WithMetricValueHigherThan(0)) | ||
| assert.NoError(c, err) | ||
| assert.Greater(c, len(metrics), 0, "no 'e2e.fips_dll_loaded' with value higher than 0 yet") | ||
| }, 5*time.Minute, 10*time.Second) | ||
| } | ||
|
|
||
| // testAgentBinaries runs a subtest for each of the Agent binaries in the install path | ||
| func (s *windowsVMSuite) testAgentBinaries(subtest func(executable string)) { | ||
| executables := []string{"agent.exe", "agent/system-probe.exe", "agent/trace-agent.exe", | ||
| "agent/process-agent.exe", "agent/security-agent.exe"} | ||
| for _, executable := range executables { | ||
| s.Run(executable, func() { | ||
| subtest(executable) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func (s *windowsVMSuite) execAgentCommand(executable, command string, options ...client.ExecuteOption) (string, error) { | ||
| host := s.Env().RemoteHost | ||
| s.Require().NotEmpty(s.installPath) | ||
|
|
||
| agentPath := filepath.Join(s.installPath, "bin", executable) | ||
| cmd := fmt.Sprintf(`& "%s" %s`, agentPath, command) | ||
| return host.Execute(cmd, options...) | ||
| } | ||
|
|
||
| func (s *windowsVMSuite) execAgentCommandWithFIPS(executable, command string) (string, error) { | ||
| // There isn't support for appending env vars to client.ExecuteOption, so | ||
| // this function doesn't accept any other options. | ||
|
|
||
| // Setting GOFIPS=1 causes the Windows FIPS Agent to panic if the system is not in FIPS mode. | ||
| // This setting does NOT control whether the FIPS Agent uses FIPS-compliant crypto libraries, | ||
| // the System-level setting determines that. | ||
| // https://github.com/microsoft/go/tree/microsoft/main/eng/doc/fips#windows-fips-mode-cng | ||
| vars := client.EnvVar{ | ||
| "GOFIPS": "1", | ||
| } | ||
|
|
||
| return s.execAgentCommand(executable, command, client.WithEnvVariables(vars)) | ||
| } | ||
|
|
||
| func assertErrorContainsFIPSPanic(t *testing.T, err error, args ...interface{}) bool { | ||
| return assert.ErrorContains(t, err, "panic: cngcrypto: not in FIPS mode", args...) | ||
| } |
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.
Why WOW6432?