6 # same revision used in the build recipe of the testing environment
8 BOTAN_DIR
=$DEPS_BUILD_DIR/botan
10 if test -d "$BOTAN_DIR"; then
14 echo "$ build_botan()"
16 # if the leak detective is enabled we have to disable threading support
17 # (used for std::async) as that causes invalid frees somehow, the
18 # locking allocator causes a static leak via the first function that
19 # references it (e.g. crypter or hasher), so we disable that too
20 if test "$LEAK_DETECTIVE" = "yes"; then
21 BOTAN_CONFIG
="--without-os-features=threads
22 --disable-modules=locking_allocator"
24 # disable some larger modules we don't need for the tests
25 BOTAN_CONFIG
="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss
26 --prefix=$DEPS_PREFIX"
28 git clone https
://github.com
/randombit
/botan.git
$BOTAN_DIR &&
30 git checkout
-qf $BOTAN_REV &&
31 python .
/configure.py
--amalgamation $BOTAN_CONFIG &&
32 make -j4 libs
>/dev
/null
&&
33 sudo
make install >/dev
/null
&&
34 sudo ldconfig ||
exit $?
40 WOLFSSL_REV
=v4.8
.0-stable
41 WOLFSSL_DIR
=$DEPS_BUILD_DIR/wolfssl
43 if test -d "$WOLFSSL_DIR"; then
47 echo "$ build_wolfssl()"
49 WOLFSSL_CFLAGS
="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB -DHAVE_AES_ECB \
50 -DHAVE_ECC_BRAINPOOL -DWOLFSSL_MIN_AUTH_TAG_SZ=8"
51 WOLFSSL_CONFIG
="--prefix=$DEPS_PREFIX
52 --disable-crypttests --disable-examples
53 --enable-aesccm --enable-aesctr --enable-camellia
54 --enable-curve25519 --enable-curve448 --enable-des3
55 --enable-ecccustcurves --enable-ed25519 --enable-ed448
56 --enable-keygen --enable-md4 --enable-rsapss --enable-sha3
59 git clone https
://github.com
/wolfSSL
/wolfssl.git
$WOLFSSL_DIR &&
61 git checkout
-qf $WOLFSSL_REV &&
63 .
/configure C_EXTRA_FLAGS
="$WOLFSSL_CFLAGS" $WOLFSSL_CONFIG &&
64 make -j4 >/dev
/null
&&
65 sudo
make install >/dev
/null
&&
66 sudo ldconfig ||
exit $?
73 TSS2_PKG
=tpm2-tss-
$TSS2_REV
74 TSS2_DIR
=$DEPS_BUILD_DIR/$TSS2_PKG
75 TSS2_SRC
=https
://github.com
/tpm2-software
/tpm2-tss
/releases
/download
/$TSS2_REV/$TSS2_PKG.
tar.gz
77 if test -d "$TSS2_DIR"; then
83 curl
-L $TSS2_SRC |
tar xz
-C $DEPS_BUILD_DIR &&
85 .
/configure
--prefix=$DEPS_PREFIX --disable-doxygen-doc &&
86 make -j4 >/dev
/null
&&
87 sudo
make install >/dev
/null
&&
88 sudo ldconfig ||
exit $?
93 : ${DEPS_BUILD_DIR=$BUILD_DIR/..}
94 : ${DEPS_PREFIX=/usr/local}
96 if [ -e /etc
/os-release
]; then
98 elif [ -e /usr
/lib
/os-release
]; then
106 CFLAGS
="-g -O2 -Wall -Wno-format -Wno-format-security -Wno-pointer-sign -Werror"
110 # should be the default, but lets make sure
111 CONFIG
="--with-printf-hooks=glibc"
114 CONFIG
="--disable-defaults --enable-pki --enable-openssl --enable-pem"
115 export TESTS_PLUGINS
="test-vectors pem openssl!"
119 CONFIG
="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
120 export TESTS_PLUGINS
="test-vectors pkcs1 gcrypt!"
121 if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "20.04" ]; then
122 DEPS
="libgcrypt20-dev"
124 DEPS
="libgcrypt11-dev"
128 CONFIG
="--disable-defaults --enable-pki --enable-botan --enable-pem"
129 export TESTS_PLUGINS
="test-vectors pem botan!"
131 if test "$1" = "build-deps"; then
136 CONFIG
="--disable-defaults --enable-pki --enable-wolfssl --enable-pem"
137 export TESTS_PLUGINS
="test-vectors pem wolfssl!"
138 # build with custom options to enable all the features the plugin supports
140 if test "$1" = "build-deps"; then
145 CONFIG
="--with-printf-hooks=builtin"
147 all|coverage|sonarcloud
)
148 if [ "$TEST" = "sonarcloud" ]; then
149 if [ -z "$SONAR_PROJECT" -o -z "$SONAR_ORGANIZATION" -o -z "$SONAR_TOKEN" ]; then
150 echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
151 "environment variables are required to run this test"
155 CONFIG
="--enable-all --disable-android-dns --disable-android-log
156 --disable-kernel-pfroute --disable-keychain
157 --disable-lock-profiler --disable-padlock --disable-fuzzing
158 --disable-osx-attr --disable-tkm --disable-uci
159 --disable-unwind-backtraces
160 --disable-svc --disable-dbghelp-backtraces --disable-socket-win
161 --disable-kernel-wfp --disable-kernel-iph --disable-winhttp
162 --disable-python-eggs-install"
163 # not enabled on the build server
164 CONFIG
="$CONFIG --disable-af-alg"
165 if test "$TEST" != "coverage"; then
166 CONFIG
="$CONFIG --disable-coverage"
168 # not actually required but configure checks for it
171 DEPS
="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
172 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
173 libldap2-dev libpcsclite-dev libpam0g-dev binutils-dev libnm-dev
174 libgcrypt20-dev libjson-c-dev python3-pip libtspi-dev libsystemd-dev"
175 if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "20.04" ]; then
176 DEPS
="$DEPS libiptc-dev"
178 DEPS
="$DEPS iptables-dev python3-setuptools"
181 if test "$1" = "build-deps"; then
188 CONFIG
="--disable-defaults --enable-svc --enable-ikev2
189 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
190 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
191 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
192 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
193 --enable-updown --enable-ext-auth --enable-libipsec --enable-pkcs11
194 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
195 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
196 --enable-pki --enable-swanctl --enable-socket-win
197 --enable-kernel-iph --enable-kernel-wfp --enable-winhttp"
198 # no make check for Windows binaries unless we run on a windows host
199 if test "$APPVEYOR" != "True"; then
202 CONFIG
="$CONFIG --enable-openssl"
203 CFLAGS
="$CFLAGS -I$OPENSSL_DIR/include"
204 LDFLAGS
="-L$OPENSSL_DIR"
207 CFLAGS
="$CFLAGS -mno-ms-bitfields"
208 DEPS
="gcc-mingw-w64-base"
211 CONFIG
="--host=x86_64-w64-mingw32 $CONFIG --enable-dbghelp-backtraces"
212 DEPS
="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
213 CC
="x86_64-w64-mingw32-gcc"
216 CONFIG
="--host=i686-w64-mingw32 $CONFIG"
217 DEPS
="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
218 CC
="i686-w64-mingw32-gcc"
223 if test "$1" = "deps"; then
224 git clone git
://git.strongswan.org
/android-ndk-boringssl.git
-b ndk-static \
225 src
/frontends
/android
/app
/src
/main
/jni
/openssl
230 # this causes a false positive in ip-packet.c since Xcode 8.3
231 CFLAGS
="$CFLAGS -Wno-address-of-packed-member"
232 # use the same options as in the Homebrew Formula
233 CONFIG
="--disable-defaults --enable-charon --enable-cmd --enable-constraints
234 --enable-curl --enable-eap-gtc --enable-eap-identity
235 --enable-eap-md5 --enable-eap-mschapv2 --enable-farp --enable-ikev1
236 --enable-ikev2 --enable-kernel-libipsec --enable-kernel-pfkey
237 --enable-kernel-pfroute --enable-nonce --enable-openssl
238 --enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
239 --enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
240 --enable-scepclient --enable-socket-default --enable-sshkey
241 --enable-stroke --enable-swanctl --enable-unity --enable-updown
242 --enable-x509 --enable-xauth-generic"
243 DEPS
="automake autoconf libtool bison gettext openssl curl"
244 BREW_PREFIX
=$
(brew
--prefix)
245 export PATH
=$BREW_PREFIX/opt
/bison
/bin
:$PATH
246 export ACLOCAL_PATH
=$BREW_PREFIX/opt
/gettext
/share
/aclocal
:$ACLOCAL_PATH
247 for pkg
in openssl curl
249 PKG_CONFIG_PATH
=$BREW_PREFIX/opt
/$pkg/lib
/pkgconfig
:$PKG_CONFIG_PATH
250 CPPFLAGS
="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
251 LDFLAGS
="-L$BREW_PREFIX/opt/$pkg/lib $LDFLAGS"
253 export PKG_CONFIG_PATH
258 # use the options of the FreeBSD port (including options), except smp,
259 # which requires a patch but is deprecated anyway, only using the builtin
261 CONFIG
="--enable-kernel-pfkey --enable-kernel-pfroute --disable-scripts
262 --disable-kernel-netlink --enable-openssl --enable-eap-identity
263 --enable-eap-md5 --enable-eap-tls --enable-eap-mschapv2
264 --enable-eap-peap --enable-eap-ttls --enable-md4 --enable-blowfish
265 --enable-addrblock --enable-whitelist --enable-cmd --enable-curl
266 --enable-eap-aka --enable-eap-aka-3gpp2 --enable-eap-dynamic
267 --enable-eap-radius --enable-eap-sim --enable-eap-sim-file
268 --enable-gcm --enable-ipseckey --enable-kernel-libipsec
269 --enable-load-tester --enable-ldap --enable-mediation
270 --enable-mysql --enable-sqlite --enable-tpm --enable-tss-tss2
271 --enable-unbound --enable-unity --enable-xauth-eap --enable-xauth-pam
272 --with-printf-hooks=builtin --enable-attr-sql --enable-sql
274 DEPS
="git gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns tpm2-tss"
275 export GPERF
=/usr
/local
/bin
/gperf
276 export LEX
=/usr
/local
/bin
/flex
279 CFLAGS
="$CFLAGS -DNO_CHECK_MEMWIPE"
280 CONFIG
="--enable-fuzzing --enable-static --disable-shared --disable-scripts
281 --enable-imc-test --enable-tnccs-20"
282 # don't run any of the unit tests
283 export TESTS_RUNNERS
=
285 if test -z "$1"; then
286 if test -z "$FUZZING_CORPORA"; then
287 git clone
--depth 1 https
://github.com
/strongswan
/fuzzing-corpora.git fuzzing-corpora
288 export FUZZING_CORPORA
=$BUILD_DIR/fuzzing-corpora
290 # these are about the same as those on OSS-Fuzz (except for the
291 # symbolize options and strip_path_prefix)
292 export ASAN_OPTIONS
=redzone
=16:handle_sigill
=1:strict_string_check
=1:\
293 allocator_release_to_os_interval_ms
=500:strict_memcmp
=1:detect_container_overflow
=1:\
294 coverage
=0:allocator_may_return_null
=1:use_sigaltstack
=1:detect_stack_use_after_return
=1:\
295 alloc_dealloc_mismatch
=0:detect_leaks
=1:print_scariness
=1:max_uar_stack_size_log
=16:\
296 handle_abort
=1:check_malloc_usable_size
=0:quarantine_size_mb
=10:detect_odr_violation
=0:\
297 symbolize
=1:handle_segv
=1:fast_unwind_on_fatal
=0:external_symbolizer_path
=/usr
/bin
/llvm-symbolizer-3.5
301 DEPS
="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
302 if test "$TEST" = "nm"; then
303 DEPS
="$DEPS libnm-glib-vpn-dev libnm-gtk-dev"
305 CONFIG
="$CONFIG --without-libnm-glib"
307 cd src
/frontends
/gnome
308 # don't run ./configure with ./autogen.sh
316 CONFIG
="--disable-defaults"
320 if [ -z "$LGTM_PROJECT" -o -z "$LGTM_TOKEN" ]; then
321 echo "The LGTM_PROJECT and LGTM_TOKEN environment variables" \
322 "are required to run this test"
326 if test -z "$1"; then
328 # after rebases or for new/duplicate branches, the passed base commit
329 # ID might not be valid
330 git rev-parse
-q --verify $base^
{commit
}
332 # this will always compare against master, while via base we
333 # otherwise only contains "new" commits
334 base
=$
(git merge-base origin
/master
${COMMIT_ID})
336 base
=$
(git rev-parse
$base)
338 echo "Starting code review for $COMMIT_ID (base $base) on lgtm.com"
339 git
diff --binary $base > lgtm.
patch ||
exit $?
340 curl
-s -X POST
--data-binary @lgtm.
patch \
341 "https://lgtm.com/api/v1.0/codereviews/${LGTM_PROJECT}?base=${base}&external-id=${BUILD_NUMBER}" \
342 -H 'Content-Type: application/octet-stream' \
343 -H 'Accept: application/json' \
344 -H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res ||
exit $?
345 lgtm_check_url
=$
(jq
-r '."task-result-url"' lgtm.res
)
346 if [ -z "$lgtm_check_url" -o "$lgtm_check_url" = "null" ]; then
350 lgtm_url
=$
(jq
-r '."task-result"."results-url"' lgtm.res
)
351 echo "Progress and full results: ${lgtm_url}"
353 echo -n "Waiting for completion: "
355 while [ "$lgtm_status" = "pending" ]; do
357 curl
-s -X GET
"${lgtm_check_url}" \
358 -H 'Accept: application/json' \
359 -H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res
365 lgtm_status
=$
(jq
-r '.status' lgtm.res
)
369 if [ "$lgtm_status" != "success" ]; then
370 lgtm_message
=$
(jq
-r '.["status-message"]' lgtm.res
)
371 echo "Code review failed: ${lgtm_message}"
374 lgtm_new
=$
(jq
-r '.languages[].new' lgtm.res |
awk '{t+=$1} END {print t}')
375 lgtm_fixed
=$
(jq
-r '.languages[].fixed' lgtm.res |
awk '{t+=$1} END {print t}')
376 echo -n "Code review complete: "
377 printf "%b\n" "\e[1;31m${lgtm_new}\e[0m new alerts, \e[1;32m${lgtm_fixed}\e[0m fixed"
382 echo "$0: unknown test $TEST" >&2
391 sudo apt-get update
-qq && \
392 sudo apt-get
install -qq bison flex gperf
gettext $DEPS
399 pkg
install -y automake autoconf libtool pkgconf
&& \
400 pkg
install -y bison flex gperf
gettext $DEPS
406 test -z "$PYDEPS" || pip3
-q install --user $PYDEPS
417 --disable-dependency-tracking
418 --enable-silent-rules
419 --enable-test-vectors
420 --enable-monolithic=${MONOLITHIC-no}
421 --enable-leak-detective=${LEAK_DETECTIVE-no}"
423 echo "$ ./autogen.sh"
424 .
/autogen.sh ||
exit $?
425 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
426 CC
="$CC" CFLAGS
="$CFLAGS" .
/configure
$CONFIG ||
exit $?
436 echo "$ make $TARGET"
439 # without target, coverage is currently not supported anyway because
440 # sonarqube only supports gcov, not lcov
441 build-wrapper-linux-x86-64
--out-dir bw-output
make -j4 ||
exit $?
444 make -j4 $TARGET ||
exit $?
450 if test -s make.warnings
; then
458 -Dsonar.
host.url
=https
://sonarcloud.io \
459 -Dsonar.projectKey
=${SONAR_PROJECT} \
460 -Dsonar.organization
=${SONAR_ORGANIZATION} \
461 -Dsonar.login
=${SONAR_TOKEN} \
462 -Dsonar.projectVersion
=$
(git describe
--exclude 'android-*')+${BUILD_NUMBER} \
464 -Dsonar.cfamily.threads
=2 \
465 -Dsonar.cfamily.cache.enabled
=true \
466 -Dsonar.cfamily.cache.path
=$HOME/.sonar-cache \
467 -Dsonar.cfamily.build-wrapper-output
=bw-output ||
exit $?
468 rm -r bw-output .scannerwork
472 cd src
/frontends
/android
473 echo "$ ./gradlew build"
474 NDK_CCACHE
=ccache .
/gradlew build ||
exit $?
480 # ensure there are no unignored build artifacts (or other changes) in the Git repo
481 unclean
="$(git status --porcelain)"
482 if test -n "$unclean"; then
483 echo "Unignored build artifacts or other changes:"