Skip to content

Commit 01ae298

Browse files
Enable unit tests with -tags=requirefips (#43611)
Enable unit tests with -tags=requirefips for auditbeat, filebeat, metricbeat, and libbeat.
1 parent 0e4ca53 commit 01ae298

25 files changed

+775
-207
lines changed

.buildkite/auditbeat/auditbeat-pipeline.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,33 @@ steps:
103103
- github_commit_status:
104104
context: "auditbeat: Ubuntu x86_64 Unit Tests"
105105

106+
- label: ":ubuntu: Auditbeat: Ubuntu x86_64 Unit Tests FIPS"
107+
command: |
108+
set -euo pipefail
109+
cd auditbeat
110+
mage unitTest
111+
retry:
112+
automatic:
113+
- limit: 1
114+
agents:
115+
provider: "gcp"
116+
image: "${IMAGE_UBUNTU_2204_X86_64}"
117+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
118+
env:
119+
FIPS: "true"
120+
artifact_paths:
121+
- "auditbeat/build/*.xml"
122+
- "auditbeat/build/*.json"
123+
plugins:
124+
- test-collector#v1.10.2:
125+
files: "auditbeat/build/TEST-*.xml"
126+
format: "junit"
127+
branches: "main"
128+
debug: true
129+
notify:
130+
- github_commit_status:
131+
context: "auditbeat: Ubuntu x86_64 Unit Tests FIPS"
132+
106133
- label: ":rhel: Auditbeat: RHEL9 Unit Tests"
107134
command: |
108135
set -euo pipefail

.buildkite/filebeat/filebeat-pipeline.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ steps:
101101
- github_commit_status:
102102
context: "filebeat: Ubuntu x86_64 Unit Tests"
103103

104+
- label: ":ubuntu: Filebeat: Ubuntu x86_64 Unit Tests FIPS"
105+
command: |
106+
cd filebeat
107+
mage unitTest
108+
retry:
109+
automatic:
110+
- limit: 1
111+
agents:
112+
provider: "gcp"
113+
image: "${IMAGE_UBUNTU_X86_64}"
114+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
115+
env:
116+
FIPS: "true"
117+
artifact_paths:
118+
- "filebeat/build/*.xml"
119+
- "filebeat/build/*.json"
120+
plugins:
121+
- test-collector#v1.10.2:
122+
files: "filebeat/build/TEST-*.xml"
123+
format: "junit"
124+
branches: "main"
125+
debug: true
126+
notify:
127+
- github_commit_status:
128+
context: "filebeat: Ubuntu x86_64 Unit Tests FIPS"
129+
104130
- label: ":ubuntu: Filebeat: Go Integration Tests"
105131
command: |
106132
cd filebeat

.buildkite/libbeat/pipeline.libbeat.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ steps:
8787
- github_commit_status:
8888
context: "libbeat: Ubuntu x86_64 Unit Tests"
8989

90+
- label: ":ubuntu: Libbeat: Ubuntu x86_64 Unit Tests FIPS"
91+
key: "mandatory-linux-unit-test-fips"
92+
command: |
93+
set -euo pipefail
94+
cd libbeat
95+
mage unitTest
96+
retry:
97+
automatic:
98+
- limit: 1
99+
agents:
100+
provider: "gcp"
101+
image: "${IMAGE_UBUNTU_X86_64}"
102+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
103+
env:
104+
FIPS: "true"
105+
artifact_paths:
106+
- "libbeat/build/*.xml"
107+
- "libbeat/build/*.json"
108+
plugins:
109+
- test-collector#v1.10.2:
110+
files: "libbeat/build/TEST-*-unit.xml"
111+
format: "junit"
112+
branches: "main"
113+
debug: true
114+
notify:
115+
- github_commit_status:
116+
context: "libbeat: Ubuntu x86_64 Unit Tests FIPS"
117+
90118
- label: ":ubuntu: Libbeat: Go Integration Tests"
91119
key: "mandatory-int-test"
92120
command: |
@@ -111,7 +139,7 @@ steps:
111139
debug: true
112140
notify:
113141
- github_commit_status:
114-
context: "libbeat: Go Integration Tests"
142+
context: "libbeat: Go Integration Tests FIPS"
115143

116144
- label: ":ubuntu: Libbeat: Python Integration Tests"
117145
key: "mandatory-python-int-test"

.buildkite/metricbeat/pipeline.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,33 @@ steps:
105105
- github_commit_status:
106106
context: "metricbeat: Ubuntu x86_64 Unit Tests"
107107

108+
- label: ":ubuntu: Metricbeat: Ubuntu x86_64 Unit Tests FIPS"
109+
key: "mandatory-linux-unit-test-fips"
110+
command: |
111+
cd metricbeat
112+
mage unitTest
113+
retry:
114+
automatic:
115+
- limit: 1
116+
agents:
117+
provider: "gcp"
118+
image: "${IMAGE_UBUNTU_X86_64}"
119+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
120+
env:
121+
FIPS: "true"
122+
artifact_paths:
123+
- "metricbeat/build/*.xml"
124+
- "metricbeat/build/*.json"
125+
plugins:
126+
- test-collector#v1.10.2:
127+
files: "metricbeat/build/TEST-*.xml"
128+
format: "junit"
129+
branches: "main"
130+
debug: true
131+
notify:
132+
- github_commit_status:
133+
context: "metricbeat: Ubuntu x86_64 Unit Tests FIPS"
134+
108135
- label: ":ubuntu: Metricbeat: Go Integration Tests (Module)"
109136
key: "mandatory-int-test"
110137
command: |

.buildkite/x-pack/pipeline.xpack.auditbeat.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ steps:
106106
- github_commit_status:
107107
context: "x-pack/auditbeat: Build Tests (Module)"
108108

109+
- label: ":ubuntu: x-pack/auditbeat: Ubuntu Unit Tests FIPS"
110+
key: "mandatory-linux-unit-test-fips"
111+
command: |
112+
cd x-pack/auditbeat
113+
mage unitTest
114+
retry:
115+
automatic:
116+
- limit: 1
117+
agents:
118+
provider: "gcp"
119+
image: "${IMAGE_UBUNTU_X86_64}"
120+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
121+
env:
122+
FIPS: "true"
123+
artifact_paths:
124+
- "x-pack/auditbeat/build/*.xml"
125+
- "x-pack/auditbeat/build/*.json"
126+
plugins:
127+
- test-collector#v1.10.2:
128+
files: "x-pack/auditbeat/build/TEST-*.xml"
129+
format: "junit"
130+
branches: "main"
131+
debug: true
132+
notify:
133+
- github_commit_status:
134+
context: "x-pack/auditbeat: Ubuntu Unit Tests FIPS"
135+
109136
- label: ":rhel: x-pack/auditbeat: RHEL9 Unit Tests"
110137
key: "mandatory-rhel9-unit-test"
111138
command: |

.buildkite/x-pack/pipeline.xpack.filebeat.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,33 @@ steps:
103103
- github_commit_status:
104104
context: "x-pack/filebeat: Ubuntu x86_64 Unit Tests"
105105

106+
- label: ":ubuntu: x-pack/filebeat: Ubuntu x86_64 Unit Tests FIPS"
107+
key: "x-pack-filebeat-mandatory-linux-unit-test-FIPS"
108+
command: |
109+
cd x-pack/filebeat
110+
mage unitTest
111+
retry:
112+
automatic:
113+
- limit: 1
114+
agents:
115+
provider: "gcp"
116+
image: "${IMAGE_UBUNTU_X86_64}"
117+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
118+
env:
119+
FIPS: "true"
120+
artifact_paths:
121+
- "x-pack/filebeat/build/*.xml"
122+
- "x-pack/filebeat/build/*.json"
123+
plugins:
124+
- test-collector#v1.10.2:
125+
files: "x-pack/filebeat/build/TEST-*.xml"
126+
format: "junit"
127+
branches: "main"
128+
debug: true
129+
notify:
130+
- github_commit_status:
131+
context: "x-pack/filebeat: Ubuntu x86_64 Unit Tests FIPS"
132+
106133
- label: ":ubuntu: x-pack/filebeat: Go Integration Tests"
107134
key: "x-pack-filebeat-mandatory-int-test"
108135
command: |

.buildkite/x-pack/pipeline.xpack.libbeat.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ steps:
8686
- github_commit_status:
8787
context: "x-pack/libbeat: Ubuntu x86_64 Unit Tests"
8888

89+
- label: ":ubuntu: x-pack/libbeat: Ubuntu x86_64 Unit Tests FIPS"
90+
key: "mandatory-linux-unit-test-fips"
91+
command: |
92+
cd x-pack/libbeat
93+
mage unitTest
94+
retry:
95+
automatic:
96+
- limit: 1
97+
agents:
98+
provider: "gcp"
99+
image: "${IMAGE_UBUNTU_X86_64}"
100+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
101+
env:
102+
FIPS: "true"
103+
artifact_paths:
104+
- "x-pack/libbeat/build/*.xml"
105+
- "x-pack/libbeat/build/*.json"
106+
notify:
107+
- github_commit_status:
108+
context: "x-pack/libbeat: Ubuntu x86_64 Unit Tests FIPS"
109+
89110
- label: ":ubuntu: x-pack/libbeat: Go Integration Tests"
90111
key: "mandatory-int-test"
91112
command: |

.buildkite/x-pack/pipeline.xpack.metricbeat.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ steps:
9999
- github_commit_status:
100100
context: "x-pack/metricbeat: Ubuntu x86_64 Unit Tests"
101101

102+
- label: ":ubuntu: x-pack/metricbeat: Ubuntu x86_64 Unit Tests FIPS"
103+
key: "mandatory-linux-unit-test-fips"
104+
command: |
105+
cd x-pack/metricbeat
106+
mage unitTest
107+
retry:
108+
automatic:
109+
- limit: 1
110+
agents:
111+
provider: "gcp"
112+
image: "${IMAGE_UBUNTU_X86_64}"
113+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
114+
env:
115+
FIPS: "true"
116+
artifact_paths:
117+
- "x-pack/metricbeat/build/*.xml"
118+
- "x-pack/metricbeat/build/*.json"
119+
plugins:
120+
- test-collector#v1.10.2:
121+
files: "x-pack/metricbeat/build/TEST-*.xml"
122+
format: "junit"
123+
branches: "main"
124+
debug: true
125+
notify:
126+
- github_commit_status:
127+
context: "x-pack/metricbeat: Ubuntu x86_64 Unit Tests FIPS"
128+
102129
- label: ":ubuntu: x-pack/metricbeat: Go Integration Tests (Module)"
103130
key: "mandatory-int-test"
104131
env:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
//go:build requirefips
19+
20+
package file_integrity
21+
22+
import (
23+
"reflect"
24+
"testing"
25+
26+
"github.com/elastic/elastic-agent-libs/config"
27+
)
28+
29+
func TestFileParsers(t *testing.T) {
30+
cfg, err := config.NewConfigFrom(map[string]interface{}{
31+
"paths": []string{"/usr/bin"},
32+
"file_parsers": []string{"file.elf.sections", `/\.pe\./`},
33+
})
34+
if err != nil {
35+
t.Fatal(err)
36+
}
37+
38+
c := defaultConfig
39+
if err := cfg.Unpack(&c); err != nil {
40+
t.Fatal(err)
41+
}
42+
43+
wantParserNames := map[string]bool{
44+
"executable_object": true,
45+
}
46+
wantFields := map[string]bool{
47+
"file.elf.sections": true,
48+
"file.pe.sections": true,
49+
"file.pe.sections.name": true,
50+
"file.pe.sections.physical_size": true,
51+
"file.pe.sections.virtual_size": true,
52+
"file.pe.sections.entropy": true,
53+
"file.pe.sections.var_entropy": true,
54+
"file.pe.go_stripped": true,
55+
}
56+
57+
gotParserNames, gotFields := parserNamesAndFields(c)
58+
if !reflect.DeepEqual(gotParserNames, wantParserNames) {
59+
t.Errorf("unexpected parser name set: got:%v want:%v", gotParserNames, wantParserNames)
60+
}
61+
if !reflect.DeepEqual(gotFields, wantFields) {
62+
t.Errorf("unexpected fields set: got:%v want:%v", gotFields, wantFields)
63+
}
64+
}

auditbeat/module/file_integrity/file_parsers_test.go renamed to auditbeat/module/file_integrity/file_parsers_nofips_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
//go:build !requirefips
19+
1820
package file_integrity
1921

2022
import (

0 commit comments

Comments
 (0)