-
Notifications
You must be signed in to change notification settings - Fork 3
288 lines (245 loc) · 8.23 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: CI
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '45 4 * * 3'
jobs:
test-linux:
name: Test ${{matrix.build}}
runs-on: ubuntu-22.04
env:
RUSTFLAGS: -Dwarnings
steps:
- name: Install openssl x86 and 32 support for gcc
if: ${{ matrix.build == 'linux32' }}
run: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libssl-dev:i386 gcc-multilib libc6:i386 libgcc-s1:i386
echo "OPENSSL_INCLUDE_DIR=/usr/include" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=/usr/lib/i386-linux-gnu" >> $GITHUB_ENV
echo "YARA_OPENSSL_INCLUDE_DIR=/usr/include" >> $GITHUB_ENV
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{matrix.target}}
- name: Build test helpers
run: |
cd boreal-test-helpers
cargo build --target=${{matrix.target}}
- name: Run tests
env:
YARA_CRYPTO_LIB: openssl
run: cargo test --target=${{matrix.target}}
- name: Run tests with Openssl
env:
YARA_CRYPTO_LIB: openssl
run: cargo test --features authenticode-verify --target=${{matrix.target}}
# Some tests need to be super user
- name: Run super user tests
env:
YARA_CRYPTO_LIB: openssl
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: "sudo -E"
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER: "sudo -E"
run: |
cargo test --target=${{matrix.target}} -- --test-threads=1 --ignored
- name: Run optional module tests
if: ${{ matrix.build == 'linux' }}
run: |
sudo apt install libjansson-dev
cargo test --features magic,cuckoo --target=${{matrix.target}}
strategy:
fail-fast: false
matrix:
build: [linux, linux32]
include:
- build: linux
target: x86_64-unknown-linux-gnu
- build: linux32
target: i686-unknown-linux-gnu
test-windows:
name: Test ${{matrix.build}}
runs-on: windows-2022
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/[email protected]
- name: Install OpenSSL on windows
uses: lukka/run-vcpkg@v10
id: runvcpkg
env:
VCPKG_DEFAULT_TRIPLET: ${{matrix.vcpkg_triplet}}
VCPKG_INSTALLED_DIR: '${{ runner.workspace }}/vcpkg/installed'
with:
appendedCacheKey: ${{matrix.vcpkg_triplet}}
vcpkgDirectory: '${{ runner.workspace }}/vcpkg'
vcpkgGitCommitId: '4cac260c4b7331538d31886f57739fea0bffa27e'
runVcpkgInstall: true
- name: Export VCPKGRS_TRIPLET and OPENSSL_DIR env var
shell: bash
run: |
echo "VCPKGRS_TRIPLET=${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
echo "OPENSSL_DIR=${{ runner.workspace }}\\vcpkg\\installed\\${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
echo "YARA_OPENSSL_DIR=${{ runner.workspace }}\\vcpkg\\installed\\${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
echo "YARA_CRYPTO_LIB=openssl" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{matrix.target}}
- name: Build test helpers
run: |
cd boreal-test-helpers
cargo build --target=${{matrix.target}}
- name: Run tests
env:
YARA_CRYPTO_LIB: openssl
run: cargo test --target=${{matrix.target}}
- name: Run tests with Openssl
env:
YARA_CRYPTO_LIB: openssl
run: cargo test --features authenticode-verify --target=${{matrix.target}}
strategy:
fail-fast: false
matrix:
build: [windows, windows32]
include:
- build: windows
vcpkg_triplet: x64-windows-static
target: x86_64-pc-windows-msvc
- build: windows32
vcpkg_triplet: x86-windows-static
target: i686-pc-windows-msvc
test-macos:
name: Test Macos 12
runs-on: macos-12
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
- name: Build test helpers
run: |
cd boreal-test-helpers
cargo build
- name: Run tests
env:
YARA_CRYPTO_LIB: openssl
run: cargo test
- name: Run tests with Openssl
env:
YARA_CRYPTO_LIB: openssl
run: cargo test --features authenticode-verify
# Some tests on macos need to be super user
- name: Run super user tests
env:
YARA_CRYPTO_LIB: openssl
# --test-threads=1 to avoid a bug that makes the vm_read_overwrite
# fail when multiple tests scanning processes are running in parallel.
# This is very suspect, and should be investigated and reported.
run: |
sudo cargo test -- --test-threads=1 --ignored
clippy:
name: Clippy
runs-on: ubuntu-22.04
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install dependencies
run: sudo apt install libjansson-dev
- run: cargo clippy --tests --all-features
rustmt:
name: Rustfmt
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all --check
deny:
name: Deny
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: EmbarkStudios/cargo-deny-action@v1
coverage:
name: Coverage
runs-on: ubuntu-22.04
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install dependencies
run: sudo apt install libjansson-dev
- name: Generate code coverage
run: |
# Export cargo llvm-cov env stuff so that we can run "cargo test"
# and have coverage
source <(cargo llvm-cov show-env --export-prefix)
cargo build -p boreal-test-helpers
# Run the normal tests
cargo test --features magic,authenticode-verify,cuckoo
# And run the super user tests
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="sudo -E" cargo \
test --features magic,authenticode-verify,cuckoo -- --ignored
# Finally, generate the report
cargo llvm-cov report --lcov --output-path lcov.info \
--ignore-filename-regex boreal-test-helpers/src/main.rs
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
msrv:
name: Rust 1.65.0
runs-on: ubuntu-22.04
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/[email protected]
- uses: dtolnay/[email protected]
# Only check boreal (and boreal-parser).
# boreal-cli is a useful tool, but MSRV on it is not really useful.
- run: |
cd boreal
cargo check --all-features
features-matrix:
name: Test features ${{matrix.features}}
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: sudo apt install libjansson-dev
- name: Build test helpers
run: |
cd boreal-test-helpers
cargo build
- name: Run tests
env:
YARA_CRYPTO_LIB: openssl
run: cargo test ${{matrix.features}}
strategy:
fail-fast: false
matrix:
features: [
"--no-default-features",
"--no-default-features --features=hash",
"--no-default-features --features=object",
"--no-default-features --features=process",
"--no-default-features --features=hash,object",
"--no-default-features --features=object,authenticode",
"--no-default-features --features=object,authenticode,authenticode-verify",
"--all-features"
]