Skip to content

Commit 3347dc2

Browse files
Enable buildkite step for unit testing with GODEBUG=fips140=only (#7702)
Add a buildkite step to enable unit tests with GODEBUG=fips140=only set.
1 parent dda1064 commit 3347dc2

File tree

20 files changed

+110
-0
lines changed

20 files changed

+110
-0
lines changed

.buildkite/pipeline.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ steps:
5353
manual:
5454
allowed: true
5555

56+
- label: "Unit tests - fips140=only Ubuntu 22.04"
57+
key: "unit-tests-2204-fips140-only"
58+
command: ".buildkite/scripts/steps/unit-tests.sh"
59+
env:
60+
FIPS: "true"
61+
GODEBUG: "fips140=only"
62+
artifact_paths:
63+
- "build/TEST-*.html"
64+
- "build/TEST-*.xml"
65+
- "build/diagnostics/*"
66+
- "coverage-*.out"
67+
agents:
68+
provider: "gcp"
69+
image: "family/platform-ingest-elastic-agent-ubuntu-2204"
70+
retry:
71+
automatic:
72+
limit: 1
73+
manual:
74+
allowed: true
75+
5676
- label: "Unit tests - Ubuntu 22.04 ARM64"
5777
key: "unit-tests-2204-arm64"
5878
command: ".buildkite/scripts/steps/unit-tests.sh"

dev-tools/mage/gotest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func makeGoTestArgs(name string) GoTestArgs {
5454
OutputFile: fileName + ".out",
5555
JUnitReportFile: fileName + ".xml",
5656
Tags: testTagsFromEnv(),
57+
Env: make(map[string]string),
5758
}
5859
if TestCoverage {
5960
params.CoverageProfileFile = fileName + ".cov"

internal/pkg/agent/application/endpoint_component_modifier_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
2222
"github.com/elastic/elastic-agent-libs/testing/certutil"
2323
"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator"
24+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2425
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
2526

2627
"github.com/elastic/elastic-agent/pkg/component"
@@ -29,6 +30,7 @@ import (
2930
)
3031

3132
func TestEndpointComponentModifier(t *testing.T) {
33+
fipsutils.SkipIfFIPSOnly(t, "generating an encrypted private key for failure testing results in a MD5 violation.")
3234
log, obs := loggertest.New("TestEndpointSignedComponentModifier")
3335
defer func() {
3436
if !t.Failed() {

internal/pkg/agent/application/info/agent_id_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ import (
1919
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
2020
"github.com/elastic/elastic-agent/internal/pkg/agent/storage"
2121
"github.com/elastic/elastic-agent/internal/pkg/agent/vault"
22+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2223
)
2324

2425
func TestAgentIDStandaloneWorks(t *testing.T) {
2526
if runtime.GOOS == "darwin" {
2627
// vault requres extra perms on mac
2728
t.Skip()
2829
}
30+
fipsutils.SkipIfFIPSOnly(t, "secret storage does not use NewGCMWithRandomNonce.")
2931
// create a new encrypted disk store
3032
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
3133
defer cancel()

internal/pkg/agent/application/secret/secret_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/elastic/elastic-agent/internal/pkg/agent/vault"
1616
"github.com/elastic/elastic-agent/internal/pkg/agent/vault/aesgcm"
17+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
1718
)
1819

1920
func getTestVaultPath(t *testing.T) string {
@@ -29,6 +30,7 @@ func getTestOptions(t *testing.T) []vault.OptionFunc {
2930
}
3031

3132
func TestCreate(t *testing.T) {
33+
fipsutils.SkipIfFIPSOnly(t, "secret storage does not use NewGCMWithRandomNonce.")
3234
opts := getTestOptions(t)
3335

3436
ctx, cn := context.WithCancel(context.Background())

internal/pkg/agent/application/upgrade/artifact/download/fs/verifier_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
2222
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact/download"
2323
"github.com/elastic/elastic-agent/internal/pkg/release"
24+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2425
"github.com/elastic/elastic-agent/pkg/core/logger"
2526
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
2627
agtversion "github.com/elastic/elastic-agent/pkg/version"
@@ -36,6 +37,7 @@ var agentSpec = artifact.Artifact{
3637
}
3738

3839
func TestFetchVerify(t *testing.T) {
40+
fipsutils.SkipIfFIPSOnly(t, "verifier being tested uses an OpenPGP key which results in a SHA-1 violation.")
3941
// See docs/pgp-sign-verify-artifact.md for how to generate a key, export
4042
// the public key, sign a file and verify it.
4143

@@ -192,6 +194,7 @@ func prepareFetchVerifyTests(
192194
}
193195

194196
func TestVerify(t *testing.T) {
197+
fipsutils.SkipIfFIPSOnly(t, "verifier being tested uses an OpenPGP key which results in a SHA-1 violation.")
195198
tt := []struct {
196199
Name string
197200
RemotePGPUris []string

internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
2626
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"
27+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2728
"github.com/elastic/elastic-agent/pkg/core/logger"
2829
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
2930
agtversion "github.com/elastic/elastic-agent/pkg/version"
@@ -36,6 +37,7 @@ import (
3637
)
3738

3839
func TestDownload(t *testing.T) {
40+
fipsutils.SkipIfFIPSOnly(t, "elastic.co test server generates an OpenPGP key which results in a SHA-1 violation.")
3941
targetDir, err := os.MkdirTemp(os.TempDir(), "")
4042
if err != nil {
4143
t.Fatal(err)

internal/pkg/agent/application/upgrade/artifact/download/http/verifier_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ import (
2121
"github.com/elastic/elastic-agent-libs/transport/httpcommon"
2222
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
2323
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"
24+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2425
"github.com/elastic/elastic-agent/pkg/core/logger"
2526
"github.com/elastic/elastic-agent/testing/proxytest"
2627
)
2728

2829
func TestVerify(t *testing.T) {
30+
fipsutils.SkipIfFIPSOnly(t, "elastic.co test server generates an OpenPGP key which results in a SHA-1 violation.")
2931
targetDir := t.TempDir()
3032

3133
log, _ := logger.New("", false)

internal/pkg/agent/install/uninstall_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/elastic/elastic-agent/internal/pkg/agent/vault"
2929
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
3030
"github.com/elastic/elastic-agent/internal/pkg/remote"
31+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
3132
)
3233

3334
func Test_checkForUnprivilegedVault(t *testing.T) {
@@ -115,6 +116,7 @@ func Test_checkForUnprivilegedVault(t *testing.T) {
115116
}
116117

117118
func initFileVault(t *testing.T, ctx context.Context, testVaultPath string, keys map[string][]byte) {
119+
fipsutils.SkipIfFIPSOnly(t, "file vault does not use NewGCMWithRandomNonce.")
118120
opts, err := vault.ApplyOptions(vault.WithVaultPath(testVaultPath))
119121
require.NoError(t, err)
120122
newFileVault, err := vault.NewFileVault(ctx, opts)

internal/pkg/agent/migration/migrate_config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
2323
"github.com/elastic/elastic-agent/internal/pkg/agent/storage"
2424
"github.com/elastic/elastic-agent/internal/pkg/agent/vault"
25+
"github.com/elastic/elastic-agent/internal/pkg/testutils/fipsutils"
2526
)
2627

2728
type configfile struct {
@@ -105,6 +106,7 @@ func TestMigrateToEncryptedConfig(t *testing.T) {
105106

106107
for _, tc := range testcases {
107108
t.Run(tc.name, func(t *testing.T) {
109+
fipsutils.SkipIfFIPSOnly(t, "encrypted config does not use NewGCMWithRandomNonce.")
108110
//setup begin
109111
top := t.TempDir()
110112
paths.SetTop(top)
@@ -200,6 +202,7 @@ func TestErrorMigrateToEncryptedConfig(t *testing.T) {
200202
}
201203
for _, tc := range testcases {
202204
t.Run(tc.name, func(t *testing.T) {
205+
fipsutils.SkipIfFIPSOnly(t, "vault does not use NewGCMWithRandomNonce.")
203206
//setup begin
204207
top := t.TempDir()
205208
paths.SetTop(top)

0 commit comments

Comments
 (0)