forked from NationalSecurityAgency/ghidra
-
Notifications
You must be signed in to change notification settings - Fork 0
234 lines (220 loc) · 9.7 KB
/
codeql.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
---
# codeql workflow for ghidra
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches:
- master
- patch
- stable
- additional_codeql_langs
- dependabot/*
- autofix/alert-*
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
- patch
- stable
- additional_codeql_langs
- dependabot/*
- autofix/alert-*
schedule:
- cron: '43 20 * * 5'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: 'ubuntu-latest'
timeout-minutes: 420
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ['c-cpp', 'java-kotlin', 'javascript-typescript', 'python']
# CodeQL supports the following languages:
# 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript',
# 'python', 'ruby', 'swift'
# Use 'java-kotlin' to analyze code written in Java, Kotlin, or both
# Use 'javascript-typescript' to analyze code written in JavaScript,
# TypeScript, or both
# Learn more about CodeQL language support at:
# https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/[email protected]
if: matrix.language == 'c-cpp' || matrix.language == 'java-kotlin'
with:
distribution: 'temurin'
# The Java version to set up. Takes a whole or semver Java version.
# See examples of supported syntax in README file
java-version: '17'
# The package type (jdk, jre, jdk+fx, jre+fx)
java-package: 'jdk'
# Name of the build platform to cache dependencies.
# It can be "maven", "gradle" or "sbt".
cache: 'gradle'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a
# config file.
# By default, queries listed here will override any specified in a
# config file.
# Prefix the list here with "+" to use these queries and those in the
# config file.
# For more details on CodeQL's query packs, refer to:
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- name: Setup Gradle
if: matrix.language == 'java-kotlin'
uses: gradle/gradle-build-action@v3
- name: Additional dependencies
if: matrix.language == 'c-cpp' || matrix.language == 'java-kotlin'
run: |
sudo apt-get -qq update
sudo apt-get -qq install gradle dh-make libgradle-core-java \
libgradle-plugins-java gradle-propdeps-plugin gradle-debian-helper \
libgradle-jflex-plugin-java gradle-plugin-protobuf \
gradle-ice-builder-plugin libgradle-android-plugin-java \
gradle-apt-plugin liblightvalue-gradle-plugin-java binutils \
binutils-dev binutils-multiarch-dev default-jre libasprintf-dev \
libgettextpo-dev ecj libecj-java maven-debian-helper gdb gdbserver \
mingw-w64 wine wine64 libiberty-dev
env | uniq | sort | uniq
if test -x "$(which ecj)"; then \
which -a ecj; \
for myecj in $(which -a ecj); do \
stat -t "${myecj}" || echo "figure out use of ${myecj} yourself"; \
done; \
else \
echo "No usable ecj found; skipping..."; \
fi
- name: Manual Gradle init
if: matrix.language == 'c-cpp' || matrix.language == 'java-kotlin'
run: |
# shellcheck disable=SC2235
if test -x "$(which gradle)" && test -w . && test -w "${HOME}"; then \
if test -w "${HOME}/work/ghidra/ghidra/.gradle" || (test -n "${GRADLE_HOME}" && test -d "${GRADLE_HOME}" && test -w "${GRADLE_HOME}"); then \
echo "initializing gradle ($(which gradle))..."; \
gradle --quiet --continue wrapper || \
find . -name '*/gradlew' -print || echo "whoami? $(whoami)"; \
echo "full list of gradles found:"; \
which -a gradle; \
echo "version info for each of them:"; \
for mygradle in $(which -a gradle); do \
if test -x "${mygradle}" && test -d "$(dirname "${mygradle}")/../share/gradle/bin/.."; then \
"${mygradle}" --version || sudo "${mygradle}" --version || \
stat -t "${mygradle}"; \
else \
echo "warning: cannot use ${mygradle}"; \
fi; \
done; \
echo "continuing with gradle initialization..."; \
gradle --info -I gradle/support/fetchDependencies.gradle init || \
(if test -x ./gradlew; then \
./gradlew --debug -I gradle/support/fetchDependencies.gradle init; \
else \
echo "missing or invalid gradle wrapper" >&2 && exit 1; \
fi) || \
(sudo gradle --quiet --continue -I gradle/support/fetchDependencies.gradle init) | tee gradle_output.log || \
ls "gradle*" 2>gradle_ls_err.txt || pwd; \
echo "one more gradle setup step..."; \
gradle --quiet prepdev eclipse buildNatives || \
(if test -x ./gradlew; then \
./gradlew prepdev eclipse buildNatives; \
else \
echo "missing or invalid gradle wrapper" >&2 && exit 1; \
fi) || \
(echo "gradle files are:" && find . -name '*.gradle' -print); \
else \
echo "Skipping gradle init due to missing/unwritable gradle locs"; \
fi; \
else \
echo "Conditions are wrong for initializing gradle"; \
fi
# Autobuild attempts to build any compiled languages
# (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually
- name: Autobuild
if: matrix.language != 'c-cpp' && matrix.language != 'java-kotlin'
uses: github/codeql-action/autobuild@v3
- name: Manual build (C and C++)
if: matrix.language == 'c-cpp'
run: |
# shellcheck disable=SC2001,SC2044
for cfile in $(find . -name '*.c' -type f); do \
cobjfile="$(echo "${cfile}" | sed "s/\.c/.o/g")"; \
if test ! -e "${cobjfile}"; then \
echo "gcc -c -w -Wno-error -I. -iquote . \"${cfile}\""; \
gcc -c -w -Wno-error -I. -I"$(dirname "${cfile}")" -iquote . \
-iquote "$(dirname "${cfile}")" "${cfile}" || \
stat -t "${cfile}" || echo "cfile is ${cfile}"; \
else \
echo "object file ${cobjfile} already exists for ${cfile}."; \
cp -v "${cobjfile}" "$(dirname "${cfile}")" || \
cp -v "${cobjfile}" . || cp -v "${cobjfile}" .. || \
(if test -d /tmp && test -w /tmp; then \
cp -v "${cobjfile}" /tmp; fi) || \
stat -t "${cobjfile}"; \
fi; \
done
# shellcheck disable=SC2044
for ccfile in $(find . -name '*.cc' -type f); do \
echo "One last attempt at compiling ${ccfile}..."; \
g++ -c "${ccfile}" || g++ -w -c -I. -iquote . "${ccfile}" || \
g++ -w -Wno-error -c -I. -iquote . -I.. -iquote .. \
-I"$(dirname "${cfile}")" \
-iquote "$(dirname "${cfile}")" "${ccfile}" || \
stat -t "${ccfile}"; \
done
# shellcheck disable=SC2044
for cppfile in $(find . -name '*.cpp' -type f); do \
echo "One last attempt at compiling ${cppfile}..."; \
g++ -Wno-write-strings -Wfatal-errors -c "${cppfile}" || \
g++ -w -Wfatal-errors -c -I. -iquote . "${cppfile}" || \
g++ -w -Wno-error -Wfatal-errors -fpermissive -c -I. -iquote . \
-I.. -iquote .. -I"$(dirname "${cfile}")" \
-iquote "$(dirname "${cfile}")" "${cppfile}" || \
stat -t "${cppfile}"; \
done
- name: Manual build (Java)
if: matrix.language == 'java-kotlin'
run: |
i=0
# shellcheck disable=SC2060
total=$(find . -maxdepth 6 -name '*.java' -type f | wc -l | tr -d [:blank:])
# shellcheck disable=SC2044,SC2060
for javafile in $(find . -maxdepth 6 -name '*.java' -type f); do \
i=$((i+1)); \
echo "One last attempt at compiling ${javafile} (file ${i} of ${total} with path length: '$(echo "${javafile}" | wc -c | tr -d [:blank:])')..."; \
javac -nowarn -Xdiags:compact -Xmaxerrs 1 "${javafile}" || \
stat -t "${javafile}"; \
done; \
date
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"