-
-
Notifications
You must be signed in to change notification settings - Fork 16
163 lines (143 loc) · 5.05 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
name: test
on:
push:
paths:
- 'cvehound/**'
- 'tests/**'
pull_request:
paths:
- 'cvehound/**'
- 'tests/**'
workflow_dispatch:
schedule:
- cron: '0 0 * * MON'
env:
STABLE_BRANCHES: ("linux-6.6.y" "linux-6.1.y" "linux-5.15.y" "linux-5.10.y" "linux-5.4.y" "linux-4.19.y")
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@v5
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, 1.2, 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: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
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: Setup Opam
if: ${{ matrix.coccinelle-version != 'system' }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-version }}
opam-disable-sandboxing: true
cache-prefix: ${{ matrix.coccinelle-version }}
- name: Install Coccinelle with opam (${{ matrix.coccinelle-version }})
if: ${{ matrix.coccinelle-version != 'system' && matrix.coccinelle-version != 'git' }}
run: opam install -y coccinelle.${{ matrix.coccinelle-version }}
- name: Clone Coccinelle
uses: actions/checkout@v4
if: ${{ matrix.coccinelle-version == 'git' }}
with:
repository: coccinelle/coccinelle
path: coccinelle
- name: Install latest Coccinelle from git
if: ${{ matrix.coccinelle-version == 'git' }}
run: |
eval $(opam env)
cd coccinelle
opam install -y .
- 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@v4
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 set-branches origin master
git remote add next --no-tags git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote set-branches next master
stable=${{env.STABLE_BRANCHES}}
git remote add stable --no-tags git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
git remote set-branches stable ${stable[@]}
git fetch --all
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