-
-
Notifications
You must be signed in to change notification settings - Fork 16
171 lines (152 loc) · 5.49 KB
/
test.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
name: test
on:
push:
paths:
- 'cvehound/**'
- 'tests/**'
pull_request:
paths:
- 'cvehound/**'
- 'tests/**'
workflow_dispatch:
schedule:
- cron: '0 0 * * MON'
jobs:
install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
python-version: "3.5"
- os: ubuntu-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.10"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install CVEhound
run: python -m pip --disable-pip-version-check install .
- name: Run CVEHound
run: |
cvehound --help
cvehound --version
build:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
os: [ubuntu-20.04]
ocaml-version: [4.07.1]
coccinelle-version: [1.0.7, 1.0.8, 1.0.9, 1.1.0, 1.1.1, git]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- name: Cache Opam
uses: actions/cache@v3
if: ${{ matrix.coccinelle-version != 'system' }}
with:
path: ~/.opam
key: ${{ runner.os }}-opam-2.1.5-${{ matrix.ocaml-version }}-${{ matrix.coccinelle-version }}
restore-keys: |
${{ runner.os }}-opam-2.1.5-${{ matrix.ocaml-version }}-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Update Apt-Get Index
run: sudo apt-get update -qq
- name: Install system Coccinelle with apt
if: ${{ matrix.coccinelle-version == 'system' }}
run: |
sudo apt-get install -y coccinelle
- name: Set up Opam
if: ${{ matrix.coccinelle-version != 'system' }}
run: |
sudo apt-get install -y python-dev aspcud ocaml
wget --quiet --no-clobber https://github.com/ocaml/opam/releases/download/2.1.5/opam-2.1.5-x86_64-linux -O opam
chmod +x opam
sudo mv opam /usr/local/bin
opam init --auto-setup --disable-sandboxing --compiler=${{ matrix.ocaml-version }}
opam update
opam upgrade --yes
- name: Install Coccinelle with opam (${{ matrix.coccinelle-version }})
if: ${{ matrix.coccinelle-version != 'system' && matrix.coccinelle-version != 'git' }}
run: |
eval $(opam env)
opam install -y coccinelle.${{ matrix.coccinelle-version }}
- name: Install latest Coccinelle from git
if: ${{ matrix.coccinelle-version == 'git' }}
run: |
eval $(opam env)
opam remove -y coccinelle
opam install -y num camlp4 pcre pyml menhir
git clone https://github.com/coccinelle/coccinelle
cd coccinelle
./autogen
./configure --prefix /usr/local --libdir /usr/local/lib --enable-python --enable-ocaml --enable-pcre-syntax --enable-pcre --enable-opt --disable-bytes
make all.opt
sudo make install
- name: Spatch Version
run: |
which opam >/dev/null 2>&1 && eval $(opam env)
spatch --version
if [[ ${{ matrix.coccinelle-version }} != 'system' && ${{ matrix.coccinelle-version }} != 'git' ]]; then
spatch_version="$(spatch --version | head -1)"
if [[ ${{ matrix.coccinelle-version }} != '1.0.9' ]]; then
if [[ "$spatch_version" != "spatch version ${{ matrix.coccinelle-version }}"* ]]; then
echo "Wrong coccinelle version installed" >&2
exit 1
fi
elif [[ "$spatch_version" != "spatch version 1.0.8"* ]]; then
echo "Wrong coccinelle version installed" >&2
exit 1
fi
fi
- name: Install CVEhound
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pytest
python -m pip install -e '.[tests]'
- name: Cache Kernel Bundle
uses: actions/cache@v3
with:
path: clone.bundle
key: linux-${{ steps.date.outputs.date }}
- name: Download Linux Tree
run: |
if [[ ! -f clone.bundle ]]; then
sudo apt-get install -y axel
axel -q https://mirrors.edge.kernel.org/pub/scm/.bundles/pub/scm/linux/kernel/git/stable/linux/clone.bundle
fi
git clone clone.bundle tests/linux
cd tests/linux
git remote set-url origin git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote add stable git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
git remote update origin
git fetch stable
git fetch next
cd -
- name: Test with pytest
run: |
sudo setcap cap_sys_nice,cap_sys_admin+eip $(realpath $(which python3))
which opam >/dev/null 2>&1 && eval $(opam env)
readarray RULES < <(git diff --name-only ${{ github.event.before }}..${{ github.event.after }} | grep -o 'CVE-[[:digit:]]*-[[:digit:]]*')
if [[ ${#RULES[@]} -gt 0 && ${#RULES[@]} -le 5 ]]; then
pytest --runslow $(for rule in ${RULES[@]}; do echo " --cve=$rule "; done)
else
pytest
fi