-
Notifications
You must be signed in to change notification settings - Fork 255
413 lines (357 loc) · 11.7 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: ci
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
permissions:
actions: read
contents: read
security-events: write
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
init:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y\
build-essential flex bison libjson-c-dev liblzo2-dev \
libglib2.0-dev meson ninja-build lld llvm clang check
- name: Get submodule hashes version
id: get-hash
run: |
echo XEN_HASH=$(git submodule | grep xen | awk '{ print $1 }') >> $GITHUB_OUTPUT
echo LIBVMI_HASH=$(git submodule | grep libvmi | awk '{ print $1 }') >> $GITHUB_OUTPUT
- name: Cache Xen debball
id: cache-xen
uses: actions/cache@v4
with:
path: xen/dist
key: xen-${{ matrix.os }}-${{ steps.get-hash.outputs.XEN_HASH }}
- name: Create Xen debball
if: steps.cache-xen.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y \
wget git bcc bin86 gawk bridge-utils iproute2 libcurl4-openssl-dev \
bzip2 libpci-dev libc6-dev linux-libc-dev zlib1g-dev libncurses5-dev \
patch libvncserver-dev libssl-dev iasl libbz2-dev e2fslibs-dev git-core \
uuid-dev ocaml libx11-dev bison flex ocaml-findlib xz-utils gettext \
libyajl-dev libpixman-1-dev libaio-dev libfdt-dev cabextract libfuse-dev \
liblzma-dev kpartx python3-dev python3-pip golang libsystemd-dev ninja-build
rm -rfv xen
git submodule update --init xen
cd xen
./configure --enable-githttp --disable-pvshim --disable-stubdom --disable-docs
make -j2 debball
cd ..
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
sudo ldconfig
- name: Cache Libvmi files
id: cache-libvmi
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-${{ matrix.os }}-${{ steps.get-hash.outputs.LIBVMI_HASH }}
- name: Build LibVMI
if: steps.cache-libvmi.outputs.cache-hit != 'true'
run: |
rm -rfv libvmi
sudo apt-get install -y build-essential autoconf-archive automake libtool flex bison libjson-c-dev debhelper
git submodule update --init libvmi
cd libvmi
sed -i 's/--disable-kvm/--disable-kvm --disable-file --disable-bareflank --disable-examples --disable-vmifs/g' debian/rules
dpkg-buildpackage -B
mkdir dist
mv ../*.deb dist/
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
outputs:
XEN_HASH: ${{ steps.get-hash.outputs.XEN_HASH }}
LIBVMI_HASH: ${{ steps.get-hash.outputs.LIBVMI_HASH }}
compile:
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'pull_request' }}
needs:
- init
strategy:
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-24.04'
flags:
- ''
- '-Dbuildtype=debug -Db_lto=false'
- '-Dbuildtype=debug -Db_lto=false -Dplugin-syscalls=false'
- '-Dbuildtype=debug -Db_lto=false -Db_sanitize=address,undefined'
- '-Dbuildtype=debug -Db_lto=false -Drepl=true'
- '-Dbuildtype=debug -Db_lto=false -Dthreadsafety=true'
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y \
clang llvm lld build-essential flex bison \
libjson-c-dev liblzo2-dev libglib2.0-dev meson ninja-build check \
python3-ipython
- name: Setup python venv for REPL
run: |
python3 -m venv venv
source venv/bin/activate
pip3 install ctypesgen
- name: Cache Xen debball
uses: actions/cache@v4
with:
path: xen/dist
key: xen-${{ matrix.os }}-${{ needs.init.outputs.XEN_HASH }}
- name: Cache Libvmi files
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-${{ matrix.os }}-${{ needs.init.outputs.LIBVMI_HASH }}
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
- name: Compile ${{ matrix.flags }}
run: |
source venv/bin/activate
meson setup build --native-file llvm.ini ${{ matrix.flags }}
ninja -C build
- name: Run check ${{ matrix.flags }}
run: |
meson test -C build
tarbuild:
name: Build using autoconf tarball
runs-on: ${{ matrix.os }}
needs:
- init
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-24.04'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y \
clang autoconf-archive automake check \
libjson-c-dev liblzo2-dev libglib2.0-dev
- name: Cache Xen debball
uses: actions/cache@v4
with:
path: xen/dist
key: xen-${{ matrix.os }}-${{ needs.init.outputs.XEN_HASH }}
- name: Cache Libvmi files
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-${{ matrix.os }}-${{ needs.init.outputs.LIBVMI_HASH }}
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
- name: autoreconf
run: autoreconf -vif
- name: Compile from make dist tarball
env:
CC: clang
CXX: clang++
run: |
./configure
make -j2 dist
mkdir build && cd build
tar xvf ../drakvuf-*.tar.gz
cd *drakvuf*
./autogen.sh
./configure
make -j2
- name: Check after make
run: |
make -j2 check
codeql-analyze:
name: Code QL Analyze
runs-on: ${{ matrix.os }}
needs:
- init
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-24.04'
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
queries: security-and-quality
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y \
clang llvm lld build-essential libjson-c-dev \
liblzo2-dev libglib2.0-dev meson ninja-build check
- name: Cache Xen debball
uses: actions/cache@v4
with:
path: xen/dist
key: xen-${{ matrix.os }}-${{ needs.init.outputs.XEN_HASH }}
- name: Cache Libvmi files
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-${{ matrix.os }}-${{ needs.init.outputs.LIBVMI_HASH }}
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
- name: Compile and install DRAKVUF
run: |
meson setup build --native-file llvm.ini
ninja -C build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
scan-build:
runs-on: ubuntu-latest
needs:
- init
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
# Install packages
sudo apt-get update -q
sudo apt-get install -y \
clang clang-tools-15 llvm lld \
libjson-c-dev meson ninja-build
- name: Cache Xen debball
uses: actions/cache@v4
with:
path: xen/dist
key: xen-ubuntu-latest-${{ needs.init.outputs.XEN_HASH }}
- name: Cache Libvmi files
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-ubuntu-latest-${{ needs.init.outputs.LIBVMI_HASH }}
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
- name: Scan build
run: |
meson setup build --buildtype debug --native-file llvm.ini
analyze-build-15 -v --cdb build/compile_commands.json \
--status-bugs \
--disable-checker deadcode.DeadStores
cognitive-complexity:
runs-on: ubuntu-latest
needs:
- init
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
# Install packages
sudo apt-get update -q
sudo apt-get install -y \
clang clang-tools clang-tidy llvm lld \
libjson-c-dev meson ninja-build
- name: Cache Xen debball
uses: actions/cache@v4
with:
path: xen/dist
key: xen-ubuntu-latest-${{ needs.init.outputs.XEN_HASH }}
- name: Cache Libvmi files
uses: actions/cache@v4
with:
path: libvmi/dist
key: libvmi-ubuntu-latest-${{ needs.init.outputs.LIBVMI_HASH }}
- name: Install Xen debball
run: |
sudo apt-get install -f ./xen/dist/xen-*.deb
- name: Install LibVMI
run: |
cd libvmi/dist
sudo apt install -f ./*.deb
sudo ldconfig
cd ../..
- name: Calculate cognitive complexity for pr
env:
CC: clang
CXX: clang++
run: |
cp scripts/complexity.sh /tmp
/tmp/complexity.sh
mv complexity.log /tmp/complexity.log
- uses: actions/checkout@v4
with:
ref: main
- name: Calculate cognitive complexity for main
env:
CC: clang
CXX: clang++
run: /tmp/complexity.sh
- name: compare complexity
run: |
FUNCTIONS=$(tail -2 complexity.log | head -1 | awk '{ print $2 }')
THRESHOLD=$(tail -1 complexity.log | awk '{ print $2 }')
CURRENT_FUNCTIONS=$(tail -2 /tmp/complexity.log | head -1 | awk '{ print $2 }')
COMPLEXITY=$(tail -1 /tmp/complexity.log | awk '{ print $2 }')
echo "Complexity: $THRESHOLD" >> $GITHUB_STEP_SUMMARY
echo "Complex functions: $FUNCTIONS" >> $GITHUB_STEP_SUMMARY
echo "Complex functions with PR: $CURRENT_FUNCTIONS" >> $GITHUB_STEP_SUMMARY
echo "Total complexity with PR: $COMPLEXITY" >> $GITHUB_STEP_SUMMARY
if [ $CURRENT_FUNCTIONS -gt $FUNCTIONS ] || [ $COMPLEXITY -gt $THRESHOLD ]; then
echo "## Complexity reduction in scope" >> $GITHUB_STEP_SUMMARY
echo "Please don't increase complexity of existing complex functions or introduce new ones"
echo "Showing diff of main (<) and this PR (>)"
diff complexity.log /tmp/complexity.log | egrep '>|<'
exit 1
fi