Skip to content

Commit 543b55c

Browse files
michel-latermanmergify[bot]
authored andcommitted
Enable unit tests with -tags=requirefips (#43611)
Enable unit tests with -tags=requirefips for auditbeat, filebeat, metricbeat, and libbeat. (cherry picked from commit 01ae298)
1 parent 014abe2 commit 543b55c

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
@@ -97,6 +97,33 @@ steps:
9797
- github_commit_status:
9898
context: "auditbeat: Ubuntu x86_64 Unit Tests"
9999

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

.buildkite/filebeat/filebeat-pipeline.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,32 @@ steps:
9595
- github_commit_status:
9696
context: "filebeat: Ubuntu x86_64 Unit Tests"
9797

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

.buildkite/libbeat/pipeline.libbeat.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,34 @@ steps:
8181
- github_commit_status:
8282
context: "libbeat: Ubuntu x86_64 Unit Tests"
8383

84+
- label: ":ubuntu: Libbeat: Ubuntu x86_64 Unit Tests FIPS"
85+
key: "mandatory-linux-unit-test-fips"
86+
command: |
87+
set -euo pipefail
88+
cd libbeat
89+
mage unitTest
90+
retry:
91+
automatic:
92+
- limit: 1
93+
agents:
94+
provider: "gcp"
95+
image: "${IMAGE_UBUNTU_X86_64}"
96+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
97+
env:
98+
FIPS: "true"
99+
artifact_paths:
100+
- "libbeat/build/*.xml"
101+
- "libbeat/build/*.json"
102+
plugins:
103+
- test-collector#v1.10.2:
104+
files: "libbeat/build/TEST-*-unit.xml"
105+
format: "junit"
106+
branches: "main"
107+
debug: true
108+
notify:
109+
- github_commit_status:
110+
context: "libbeat: Ubuntu x86_64 Unit Tests FIPS"
111+
84112
- label: ":ubuntu: Libbeat: Go Integration Tests"
85113
key: "mandatory-int-test"
86114
command: |
@@ -99,7 +127,7 @@ steps:
99127
- "libbeat/build/*.json"
100128
notify:
101129
- github_commit_status:
102-
context: "libbeat: Go Integration Tests"
130+
context: "libbeat: Go Integration Tests FIPS"
103131

104132
- label: ":ubuntu: Libbeat: Python Integration Tests"
105133
key: "mandatory-python-int-test"

.buildkite/metricbeat/pipeline.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: "metricbeat: Ubuntu x86_64 Unit Tests"
101101

102+
- label: ":ubuntu: Metricbeat: Ubuntu x86_64 Unit Tests FIPS"
103+
key: "mandatory-linux-unit-test-fips"
104+
command: |
105+
cd 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+
- "metricbeat/build/*.xml"
118+
- "metricbeat/build/*.json"
119+
plugins:
120+
- test-collector#v1.10.2:
121+
files: "metricbeat/build/TEST-*.xml"
122+
format: "junit"
123+
branches: "main"
124+
debug: true
125+
notify:
126+
- github_commit_status:
127+
context: "metricbeat: Ubuntu x86_64 Unit Tests FIPS"
128+
102129
- label: ":ubuntu: Metricbeat: Go Integration Tests (Module)"
103130
key: "mandatory-int-test"
104131
command: |

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

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

103+
- label: ":ubuntu: x-pack/auditbeat: Ubuntu Unit Tests FIPS"
104+
key: "mandatory-linux-unit-test-fips"
105+
command: |
106+
cd x-pack/auditbeat
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+
- "x-pack/auditbeat/build/*.xml"
119+
- "x-pack/auditbeat/build/*.json"
120+
plugins:
121+
- test-collector#v1.10.2:
122+
files: "x-pack/auditbeat/build/TEST-*.xml"
123+
format: "junit"
124+
branches: "main"
125+
debug: true
126+
notify:
127+
- github_commit_status:
128+
context: "x-pack/auditbeat: Ubuntu Unit Tests FIPS"
129+
103130
- label: ":rhel: x-pack/auditbeat: RHEL9 Unit Tests"
104131
key: "mandatory-rhel9-unit-test"
105132
command: |

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ steps:
9797
- github_commit_status:
9898
context: "x-pack/filebeat: Ubuntu x86_64 Unit Tests"
9999

100+
- label: ":ubuntu: x-pack/filebeat: Ubuntu x86_64 Unit Tests FIPS"
101+
key: "x-pack-filebeat-mandatory-linux-unit-test-FIPS"
102+
command: |
103+
cd x-pack/filebeat
104+
mage unitTest
105+
retry:
106+
automatic:
107+
- limit: 1
108+
agents:
109+
provider: "gcp"
110+
image: "${IMAGE_UBUNTU_X86_64}"
111+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
112+
env:
113+
FIPS: "true"
114+
artifact_paths:
115+
- "x-pack/filebeat/build/*.xml"
116+
- "x-pack/filebeat/build/*.json"
117+
plugins:
118+
- test-collector#v1.10.2:
119+
files: "x-pack/filebeat/build/TEST-*.xml"
120+
format: "junit"
121+
branches: "main"
122+
debug: true
123+
notify:
124+
- github_commit_status:
125+
context: "x-pack/filebeat: Ubuntu x86_64 Unit Tests FIPS"
126+
100127
- label: ":ubuntu: x-pack/filebeat: Go Integration Tests"
101128
key: "x-pack-filebeat-mandatory-int-test"
102129
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
@@ -93,6 +93,33 @@ steps:
9393
- github_commit_status:
9494
context: "x-pack/metricbeat: Ubuntu x86_64 Unit Tests"
9595

96+
- label: ":ubuntu: x-pack/metricbeat: Ubuntu x86_64 Unit Tests FIPS"
97+
key: "mandatory-linux-unit-test-fips"
98+
command: |
99+
cd x-pack/metricbeat
100+
mage unitTest
101+
retry:
102+
automatic:
103+
- limit: 1
104+
agents:
105+
provider: "gcp"
106+
image: "${IMAGE_UBUNTU_X86_64}"
107+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
108+
env:
109+
FIPS: "true"
110+
artifact_paths:
111+
- "x-pack/metricbeat/build/*.xml"
112+
- "x-pack/metricbeat/build/*.json"
113+
plugins:
114+
- test-collector#v1.10.2:
115+
files: "x-pack/metricbeat/build/TEST-*.xml"
116+
format: "junit"
117+
branches: "main"
118+
debug: true
119+
notify:
120+
- github_commit_status:
121+
context: "x-pack/metricbeat: Ubuntu x86_64 Unit Tests FIPS"
122+
96123
- label: ":ubuntu: x-pack/metricbeat: Go Integration Tests (Module)"
97124
key: "mandatory-int-test"
98125
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)