-
Notifications
You must be signed in to change notification settings - Fork 68
70 lines (68 loc) · 2.09 KB
/
tests.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
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# file name consistency
test_filenames:
runs-on: ubuntu-20.04
steps:
- name: Checkout testfiles repository
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Test repository files
run: python .github/check_sample_filenames.py .
# to allow quicker tests, capa should run less than THRESHOLD seconds on added/modified test files
test_runtime:
runs-on: ubuntu-20.04
steps:
# We check the submodules separately as the rules submodule's reference may not be our PR/master
- name: Checkout capa without submodules
uses: actions/checkout@v3
with:
repository: mandiant/capa
- name: Checkout capa-rules
uses: actions/checkout@v3
with:
repository: mandiant/capa-rules
path: rules
- name: Checkout capa-testfiles
uses: actions/checkout@v3
with:
path: tests/data
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install capa
run: pip install -e .
- name: Get modified files
id: files
uses: Ana06/[email protected]
with:
format: 'csv'
- name: Check capa runtime on modified files
run: |
THRESHOLD=180
exitcode=0
cd tests/data
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.all }}')
for changed_file in "${added_modified_files[@]}"; do
if [[ $changed_file =~ .exe_|.dll_|.elf_|.sys_|.raw32|.raw64 ]]; then
time0=$SECONDS
capa -q -v "$changed_file"
diff=$(($SECONDS-time0))
if [[ $diff -gt $THRESHOLD ]]; then
echo "capa ran for $diff seconds, please provide a different sample so we can test more quickly"
exitcode=1
else
echo "all good, capa ran for $diff seconds"
fi
fi
done
exit $exitcode