diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a2139c8711761a2ea22f3d16dd3687a52417e4a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,116 @@ +before_script: + - "source ~gitlab-runner/cicd_support/cicd_support.shinc" + + +after_script: + - "echo Test Complete." + +stages: + - clean + - build + - test + + + +# +# Cleaning +# + +#template +.do-clean: &do-nightly-clean + stage: clean + script: + - ./cicd_testing/do-clean.sh + +# per os items +do-nightly-clean-ubuntu18: + <<: *do-nightly-clean + tags: + - ubuntu18 + variables: + OS: 'ubuntu18' + +do-nightly-clean-ubuntu16: + <<: *do-nightly-clean + tags: + - ubuntu16 + variables: + OS: 'ubuntu16' + +do-nightly-clean-centos75: + <<: *do-nightly-clean + tags: + - centos75 + variables: + OS: 'centos75' + + +# +# building +# + + +# template +.do-build: &do-build + stage: build + script: + - ./cicd_testing/do-build.sh + + +# per os items +do-build-ubuntu18: + <<: *do-build + tags: + - ubuntu18 + variables: + OS: 'ubuntu18' + + +do-build-ubuntu16: + <<: *do-build + tags: + - ubuntu16 + variables: + OS: 'ubuntu16' + +do-build-centos75: + <<: *do-build + tags: + - centos75 + variables: + OS: 'centos75' + + + +# +# $PSZ ls +# + +# template +.xform-ls: &xform-ls + stage: test + script: + - ./cicd_testing/xform-ls.sh + +#per OS +xform-ls-ubuntu18: + <<: *xform-ls + tags: + - ubuntu18 + variables: + OS: 'ubuntu18' + +xform-ls-ubuntu16: + <<: *xform-ls + tags: + - ubuntu16 + variables: + OS: 'ubuntu16' + +xform-ls-centos75: + <<: *xform-ls + tags: + - centos75 + variables: + OS: 'centos75' + diff --git a/SMP-fullanalyze64-ida7.sh b/SMP-fullanalyze64-ida7.sh new file mode 100755 index 0000000000000000000000000000000000000000..746c1ec6ea1f134d3f469b0ca872f3660d2c0344 --- /dev/null +++ b/SMP-fullanalyze64-ida7.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Make terminal ansi-color +export TVOPT=ansi +# Fix screwed-up LD environment on power machines. +# export LD_LIBRARY_PATH=/uf1/jdh8d/RA/NICECAP/idapro_lib/ +export LD_LIBRARY_PATH=${IDAROOT} +# Set IDA path. +export IDADIR=$IDAROOT +# Make sure that the idal executable can be reached from PATH. +export PATH=$PATH:$IDADIR +export STARS_ROOT_FILENAME=$1 +export IDALOG=$1.log +# export IDALOG_SILENT=1 +# Extract the code addresses with objdump. +objdump -d --prefix-addresses $1 | grep "^[0-9]" > $1.SMPobjdump + +# Extract the exception-handling function target addresses. +# dwarfdump -F $1 | grep "^<" | cut --delimiter="<" --field=3 | cut --delimiter=":" --field=1 | cut --bytes 4-10 > $1.eh_frame_addrs +# Make readelf do the same thing as the above dwarfdump command, to +# eliminate configuration dependence on dwarfdump. +readelf -wF $1 | grep "pc=" | cut --delimiter="=" --field=3 | cut --delimiter="." --field=1 > $1.eh_frame_addrs + +if [ "${IDAROOT}"X = "X" ]; then echo Please set IDAROOT; exit 1; fi +if [ ! -f ${IDAROOT}/libida.so ]; then echo IDAROOT is set poorly, please fix.; exit 1; fi + + +# remove tmp files +rm -f $1.id? $1.{i64,nam,til,log,syms} +rm -f `basename $1 .psexe`.{i64,nam,til} `basename $1 .psexe`.id? +rm -f `basename $1 .ncexe`.{i64,nam,til} `basename $1 .ncexe`.id? +rm -f `basename $1 .exe`.{i64,nam,til} `basename $1 .exe`.id? + +old_stty=`stty -g` + + + +# Run the linux IDA Pro with the SMPStaticAnalyzer plugin. +# jdh - added -B for batch mode, avoids any prompts. +# jdh - note: can't use -B, as the plugin doesn't run! + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP7noasm.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP7.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +# TVHEADLESS=1 valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idat64 -A -SSMP7.idc $1 + + +# SMP seems to mess up the terminal, using this to fix it. +/usr/bin/reset +stty $old_stty + +# Get the output file SMP.syms into $1.syms. +# mv SMP.annot $1.annot + diff --git a/cicd_testing/do-build.sh b/cicd_testing/do-build.sh new file mode 100755 index 0000000000000000000000000000000000000000..64af6b87bfb4f840771b4cd7ac79637cc8f3e2e0 --- /dev/null +++ b/cicd_testing/do-build.sh @@ -0,0 +1,38 @@ +#/bin/bash + +set -e +set -x + +main() +{ + + # update submodules + git submodule sync --recursive + git submodule update --recursive --init + + # gather info for debugging later, probably not necessary + pwd + hostname + whoami + env|grep "^CICD" + + local orig_dir=$(pwd) + + # puts peasoup_umbrella (and all submodules) in CICD_MODULE_WORK_DIR + cicd_setup_module_dependency allnp/peasoup_umbrella.git stars_umbrella + + + # puts the version of zipr to test in stars_umbrella/SMPStaticAnalyzer. + cicd_put_module_in_tree stars_umbrella/SMPStaticAnalyzer + + # Build peasoup_umbrella as stars_umbrella + cd $CICD_MODULE_WORK_DIR/stars_umbrella + source set_env_vars + sudo ./get-peasoup-packages.sh all + ./build-all.sh + dropdb $PGDATABASE 2>/dev/null || true ; ./postgres_setup.sh + + cd $orig_dir +} + +main "$@" diff --git a/cicd_testing/do-clean.sh b/cicd_testing/do-clean.sh new file mode 100755 index 0000000000000000000000000000000000000000..409081b3fb57d525654283a1bcd864d47107d8c8 --- /dev/null +++ b/cicd_testing/do-clean.sh @@ -0,0 +1,22 @@ +#/bin/bash + +set -e +set -x + +main() +{ + + # gather info for debugging later, probably not necessary + pwd + hostname + whoami + env|grep "^CICD" + + + if [[ $CICD_NIGHTLY == 1 ]] ; then + rm -rf $CICD_MODULE_WORK_DIR/stars_umbrella + fi + +} + +main "$@" diff --git a/cicd_testing/starstest.sh b/cicd_testing/starstest.sh new file mode 100755 index 0000000000000000000000000000000000000000..5b26e4345d4cac16c9804588b95de6a1b4354886 --- /dev/null +++ b/cicd_testing/starstest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Usage: + +function validate { + if grep "FROMIB COMPLETE 20 SWITCHTABLE" $1.STARSxrefs > /dev/null; then + if grep "FROMIB COMPLETE 1 RETURNTARGET" $1.STARSxrefs > /dev/null; then + if tail $1.infoannot | grep "SUCCESS ANALYSISCOMPLETED" > /dev/null; then + echo "STARS success" + exitstatus=0 + else + echo "Failed to find SUCCESS ANALYSISCOMPLETED annotation" + exitstatus=1 + fi + else + echo "Failed to find any COMPLETE RETURNTARGET xref annotations" + exitstatus=2 + fi + else + echo "Failed to find COMPLETE 20 SWITCHTABLE xref annotation" + exitstatus=3 + fi + return $exitstatus +} + +function test { + ./$SMPSA_HOME/SMP-fullanalyze64-ida7.sh $1 + validate $1 +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build { + rm -f starstest_$1.exe + gcc -m64 -$1 -o starstest_$1.exe $SMPSA_HOME/tests/starstest.c +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build_and_test { + build $1 + test starstest_$1.exe +} + +# Build and test each of the optimization levels -O0, -Og, and -O3. +if build_and_test O0 ; then + if build_and_test Og ; then + build_and_test O3 + fi +fi + + diff --git a/cicd_testing/xform-ls.sh b/cicd_testing/xform-ls.sh new file mode 100755 index 0000000000000000000000000000000000000000..ffcea7fc767233176772f64d77184fa4a6f40fe0 --- /dev/null +++ b/cicd_testing/xform-ls.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +set -x + +cd $CICD_MODULE_WORK_DIR/stars_umbrella +source set_env_vars +cd /tmp +rm -rf ls.stars.killdeads stars_ped_ls; $PSZ /bin/ls ./ls.stars.killdeads -c rida=on -s meds_static=off -c kill_deads=on --tempdir stars_ped_ls || true +if [[ ! -x ./ls.stars.killdeads ]]; then cat stars_ped_ls/logs/*; fi +rm -rf stars_ped_ls +./ls.stars.killdeads