forked from CERTCC/kaiju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
223 lines (204 loc) · 8.09 KB
/
azure-pipelines.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
schedules:
- cron: "0 12 * * 0"
displayName: Weekly Sunday build
branches:
include:
- main
always: true
jobs:
- job: Build_Kaiju
variables:
CCACHE_DIR: $(Pipeline.Workspace)/cache
GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle
AUTOCATS_DIR: $(Pipeline.Workspace)/autocats
GHIHORN_TEST_DIR: $(Pipeline.Workspace)/autocats/exe/ghihorn
GRADLE_VERSION: gradle-6.9.2
GRADLE_URL: https://services.gradle.org/distributions/$(GRADLE_VERSION)-bin.zip
GRADLE_INSTALL_DIR: $(Pipeline.Workspace)/gradle
Z3_VERSION: z3-4.8.14
strategy:
matrix:
# Disabled because we can't even build ghidra master with gradle 6.9.2
#ghidra-git:
# ghidraVersion: "master"
ghidra1015:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.5_build/ghidra_10.1.5_PUBLIC_20220726.zip"
ghidraVersion: "10.1.5"
ghidra1014:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.4_build/ghidra_10.1.4_PUBLIC_20220519.zip"
ghidraVersion: "10.1.4"
ghidra1013:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.3_build/ghidra_10.1.3_PUBLIC_20220421.zip"
ghidraVersion: "10.1.3"
ghidra1012:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.2_build/ghidra_10.1.2_PUBLIC_20220125.zip"
ghidraVersion: "10.1.2"
ghidra1011:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1.1_build/ghidra_10.1.1_PUBLIC_20211221.zip"
ghidraVersion: "10.1.1"
ghidra101:
ghidraUrl: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.1_build/ghidra_10.1_PUBLIC_20211210.zip"
ghidraVersion: "10.1"
pool:
vmImage: 'Ubuntu-20.04'
steps:
- bash: |
set -e
sudo apt-get -y update
sudo apt-get install ccache -y
echo "##vso[task.prependpath]/usr/lib/ccache"
displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc
- task: Cache@2
inputs:
key: 'ccache | "$(System.JobDisplayName)" ' # Same for each version of Ghidra more or less
restoreKeys: 'ccache'
path: $(CCACHE_DIR)
displayName: ccache
- script: |
echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)"
echo "##vso[task.prependpath]$(JAVA_HOME_11_X64)/bin:$(PATH)"
displayName: "Set java version"
- task: Cache@2
inputs:
key: '"$(Z3_VERSION)" | z3'
path: $(Pipeline.Workspace)/z3
displayName: Cache z3 dir
- task: Cache@2
condition: and(succeeded(), ne(variables['ghidraUrl'], ''))
inputs:
key: '"$(ghidraUrl)" | binary'
path: $(Pipeline.Workspace)/zip
displayName: Cache ghidra binary
- task: Cache@2
inputs:
key: 'gradle | "$(Agent.OS)" | "$(System.JobDisplayName)" '
restoreKeys: 'gradle'
path: $(GRADLE_USER_HOME)
displayName: Gradle build cache
- task: Cache@2
inputs:
key: '"$(AUTOCATS_DIR)" | "autocats" | "ghihorn"'
restoreKeys: "autocats"
path: $(AUTOCATS_DIR)
displayName: Cache AUTOCATS
- task: Cache@2
inputs:
key: '"$(GRADLE_URL)" | gradle'
path: $(GRADLE_INSTALL_DIR)
displayName: Cache Gradle 6.x
- bash: |
set -ex
sudo apt-get -y install ninja-build
test -d $(Pipeline.Workspace)/z3 || git clone -b $(Z3_VERSION) --depth 1 https://github.com/Z3Prover/z3.git z3
mkdir -p z3/build
cd z3/build
git checkout $(Z3_VERSION)
cmake -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DZ3_BUILD_JAVA_BINDINGS=On ..
ninja
echo '##vso[task.setvariable variable=LD_LIBRARY_PATH]$(Pipeline.Workspace)/z3/build'
condition: succeeded()
workingDirectory: $(Pipeline.Workspace)
displayName: Build Z3
- bash: |
set -e
test -d zip || (mkdir zip && cd zip && wget $(ghidraUrl))
unzip zip/*.zip
condition: and(succeeded(), ne(variables['ghidraUrl'], ''))
workingDirectory: $(Pipeline.Workspace)
displayName: Download Ghidra binary from $(ghidraUrl)
- bash: |
set -e
sudo apt-get -y install bison flex xvfb
git clone --depth 1 https://github.com/NationalSecurityAgency/ghidra
condition: and(succeeded(), eq(variables['ghidraUrl'], ''))
workingDirectory: $(Pipeline.Workspace)
displayName: Download and build Ghidra from git part 1
- task: Cache@2
displayName: Cache Ghidra dependencies
inputs:
key: 'gradle deps'
path: $(Pipeline.Workspace)/ghidra/dependencies
condition: and(succeeded(), eq(variables['ghidraUrl'], ''))
- bash: |
set -e
echo "##vso[task.prependpath]$(GRADLE_INSTALL_DIR)/$(GRADLE_VERSION)/bin"
test -d $(GRADLE_INSTALL_DIR) && exit 0
wget $(GRADLE_URL) -O gradle.zip
unzip -d $(GRADLE_INSTALL_DIR) gradle.zip
rm gradle.zip
workingDirectory: $(Pipeline.Workspace)
displayName: Download gradle 6.x binary from $(GRADLE_URL)
- bash: |
set -ex
cd ghidra
gradle --build-cache --init-script gradle/support/fetchDependencies.gradle init
gradle --build-cache buildGhidra -x ip
mkdir -p $(Pipeline.Workspace)/zip
cp build/dist/*.zip $(Pipeline.Workspace)/zip/
cd $(Pipeline.Workspace)
unzip zip/*.zip
condition: and(succeeded(), eq(variables['ghidraUrl'], ''))
workingDirectory: $(Pipeline.Workspace)
displayName: Download and build Ghidra from git part 2
- bash: |
set -e
Z3CLASSPATH=$(Pipeline.Workspace)/z3/build GHIDRA_INSTALL_DIR=$(find $(Pipeline.Workspace) -maxdepth 1 -type d -name 'ghidra_*') gradle -PKAIJU_AUTOCATS_DIR=$AUTOCATS_DIR --build-cache
displayName: Build Kaiju extension and plugins
workingDirectory: .
- bash: |
set -ex
test -d $AUTOCATS_DIR || git clone https://github.com/cmu-sei/autocats $AUTOCATS_DIR
(cd $AUTOCATS_DIR && git pull)
displayName: Download AUTOCATS
- bash: |
set -e
# Needs a head
Xvfb :1 &
DISPLAY=:1 Z3CLASSPATH=$(Pipeline.Workspace)/z3/build GHIDRA_INSTALL_DIR=$(find $(Pipeline.Workspace) -maxdepth 1 -type d -name 'ghidra_*') gradle -PKAIJU_AUTOCATS_DIR=$AUTOCATS_DIR --build-cache --stacktrace --info test
kill %%
displayName: Run Kaiju tests
workingDirectory: .
- script: gradle --stop
- publish: dist/
- task: GitHubRelease@0
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.Reason'], 'Schedule'))
inputs:
gitHubConnection: gh
repositoryName: $(Build.Repository.Name)
action: delete
tagSource: manual
tag: ghidra-$(ghidraVersion)
continueOnError: true
- task: DownloadSecureFile@1
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.Reason'], 'Schedule'))
name: deployKey
inputs:
secureFile: 'deploy.key'
- bash: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
chmod og-r $(deployKey.secureFilePath)
ssh-add $(deployKey.secureFilePath)
git config --global user.email "[email protected]"
git config --global user.name "eschwartz"
git remote add ssh-origin [email protected]:sei-eschwartz/kaiju.git
git push --delete ssh-origin ghidra-$(ghidraVersion)
rm -f $(deployKey.secureFilePath)
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.Reason'], 'Schedule'))
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
continueOnError: true
displayName: Delete old git tag ghidra-$(ghidraVersion)
- task: GitHubRelease@0
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.Reason'], 'Schedule'))
inputs:
gitHubConnection: gh
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: manual
tag: ghidra-$(ghidraVersion)
title: CERT Kaiju binary analysis extension for Ghidra $(ghidraVersion)
assets: dist/*.zip
addChangeLog: false