-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a verification for users and CI (#4)
* Add initial code for a verification script * Add a CI for verifying pipeline still works * Add install line * Add angr * Update readme for verification script
- Loading branch information
Showing
17 changed files
with
678 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Core Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Java 19 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' # See 'Supported distributions' for available options | ||
java-version: '19' | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
sudo apt-get update && sudo apt-get install unzip openjdk-19-jdk graphviz-dev -y | ||
pip3 install -e . | ||
pip3 install angr | ||
- name: Run verification tests | ||
run: | | ||
# a hack to allow for docker containers in github actions and ARM | ||
export JAVA_OPTS="-Djdk.lang.Process.launchMechanism=vfork" | ||
./scripts/ci_verify_pipeline.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "1.0.1" | ||
__version__ = "1.1.0" | ||
|
||
# create loggers | ||
import logging | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
PROJECT_DIR="$SCRIPT_DIR/.." | ||
EXAMPLE_PROJECT_DIR="$SCRIPT_DIR/../tests/example_project" | ||
RESULTS_DIR="$SCRIPT_DIR/../results/O2" | ||
CORES="$(nproc --all)" | ||
|
||
echo "Installing dependencies..." | ||
sudo apt-get update && sudo apt-get install -y gcc make strip | ||
|
||
echo "[+] Checking if results directory exists..." | ||
if [ ! -d "$RESULTS_DIR" ]; then | ||
echo "[+] Creating results directory..." | ||
mkdir -p "$RESULTS_DIR" | ||
fi | ||
|
||
echo "[+] Running pipeline in $PROJECT_DIR..." | ||
cd "$PROJECT_DIR" || exit 1 | ||
|
||
echo "[+] Running compilation pipeline..." && \ | ||
# runs on the default opts, which is O2 | ||
./eval.py --compile example_project --cores "$CORES" && \ | ||
echo "[+] Running decompilation pipeline (only for source)..." && \ | ||
./eval.py --decompile example_project --cores "$CORES" --use-dec source && \ | ||
echo "[+] Copying decompilation..." && \ | ||
mkdir -p "$PROJECT_DIR"/results/O2/example_project/sailr_decompiled && \ | ||
cp "$PROJECT_DIR"/tests/ci/angr* "$PROJECT_DIR"/results/O2/example_project/sailr_decompiled && \ | ||
echo "[+] Running measurement pipeline (gotos, bools, calls, cfged)..." && \ | ||
./eval.py --measure example_project --use-metric gotos cfged bools func_calls --use-dec source angr_sailr angr_dream --cores "$CORES" && \ | ||
echo "[+] Running aggregation pipeline..." && \ | ||
./eval.py --summarize-targets example_project --use-dec source angr_sailr angr_dream --use-metric gotos cfged bools func_calls --show-stats && \ | ||
# cleanup | ||
rm -rf "$RESULTS_DIR/example_project" && \ | ||
echo "[+] The pipeline has successfully finished!" || (echo "[!] Pipeline failed, check the last stage it was in to figure out where!" && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
PROJECT_DIR="$SCRIPT_DIR/.." | ||
EXAMPLE_PROJECT_DIR="$SCRIPT_DIR/../tests/example_project" | ||
RESULTS_DIR="$SCRIPT_DIR/../results/O2" | ||
CORES="$(nproc --all)" | ||
|
||
echo "[+] Checking if results directory exists..." | ||
if [ ! -d "$RESULTS_DIR" ]; then | ||
echo "[+] Creating results directory..." | ||
mkdir -p "$RESULTS_DIR" | ||
fi | ||
|
||
echo "[+] Running pipeline in $PROJECT_DIR..." | ||
cd "$PROJECT_DIR" || exit 1 | ||
|
||
echo "[+] The following runs will require sudo for docker and file permissions..." | ||
echo "[+] Running compilation pipeline..." && \ | ||
# runs on the default opts, which is O2 | ||
sudo ./docker-eval.sh --compile example_project --cores "$CORES" && \ | ||
echo "[+] Running decompilation pipeline (only for source)..." && \ | ||
./eval.py --decompile example_project --cores "$CORES" --use-dec source && \ | ||
echo "[+] Running decompilation pipeline (for other decompilers)..." && \ | ||
sudo ./docker-eval.sh --decompile example_project --use-dec angr_sailr angr_dream --cores "$CORES" && \ | ||
echo "[+] Running measurement pipeline (gotos, bools, calls, cfged)..." && \ | ||
./eval.py --measure example_project --use-metric gotos cfged bools func_calls --use-dec source angr_sailr angr_dream --cores "$CORES" && \ | ||
echo "[+] Running aggregation pipeline..." && \ | ||
./eval.py --summarize-targets example_project --use-dec source angr_sailr angr_dream --use-metric gotos cfged bools func_calls --show-stats && \ | ||
# cleanup | ||
#rm -rf "$RESULTS_DIR/example_project" && \ | ||
echo "[+] The pipeline has successfully finished!" || (echo "[!] Pipeline failed, check the last stage it was in to figure out where!" && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package_name = "example_project" | ||
# path is relative to ./results/{opt_level}/ directory, so usually should start with ../../ | ||
source_remote = "../../tests/example_project" | ||
# see other targets for real remote types | ||
remote_type = "local" | ||
download = true | ||
# post_download_cmds are run only once after first download | ||
# for commands that run before every make, use pre_make_cmds | ||
post_download_cmds = ["./bootstrap.sh"] | ||
# useful for git repos (will checkout) | ||
version = "v0.0.0" | ||
# the directory name of the entire project | ||
package_dir = "example_project" | ||
make_cmd = "make" | ||
post_make_cmds = [] | ||
# location (inside package_dir) that has the source code | ||
source_dir = "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
void complete_job() { | ||
unsigned long long v1; // rax | ||
|
||
v1 = puts("checking..."); | ||
return; | ||
} | ||
|
||
void next_job() { | ||
unsigned long long v1; // rax | ||
|
||
puts("next_job"); | ||
v1 = 1; | ||
return; | ||
} | ||
|
||
void refresh_jobs() { | ||
unsigned long long v1; // rax | ||
|
||
puts("refresh_jobs"); | ||
v1 = 2; | ||
return; | ||
} | ||
|
||
void fast_unlock() { | ||
unsigned long long v1; // rax | ||
|
||
puts("fast_unlock"); | ||
v1 = 4; | ||
return; | ||
} | ||
|
||
void log_workers() { | ||
unsigned long long v1; // rax | ||
|
||
v1 = puts("log_workers"); | ||
return; | ||
} | ||
|
||
long long schedule_job(unsigned long a0, unsigned long long a1, unsigned long a2) { | ||
if (a0 && a1) { | ||
complete_job(); | ||
if (EARLY_EXIT != a2) { | ||
next_job(); | ||
refresh_jobs(); | ||
} | ||
} | ||
if (!a0 || !a1) | ||
refresh_jobs(); | ||
if (a1 || EARLY_EXIT != a2) | ||
fast_unlock(); | ||
complete_job(); | ||
log_workers(); | ||
return job_status(a1); | ||
} | ||
|
||
long long job_status(unsigned long a0) { | ||
puts("job_status"); | ||
return a0; | ||
} | ||
|
||
int main(unsigned long a0, struct struct_0 *a1[3]) { | ||
return schedule_job(a1[0]->field_0, a1[1]->field_0, a1[2]->field_0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[complete_job] | ||
1 = [ 96,] | ||
2 = [ 96,] | ||
3 = [ 96,] | ||
4 = [ 96, 100, 107,] | ||
5 = [ 96, 107, 100,] | ||
|
||
[next_job] | ||
1 = [ 0,] | ||
2 = [ 0,] | ||
3 = [ 0,] | ||
4 = [ 0, 4, 8, 15,] | ||
5 = [ 20,] | ||
6 = [ 25, 29,] | ||
|
||
[refresh_jobs] | ||
1 = [ 32,] | ||
2 = [ 32,] | ||
3 = [ 32,] | ||
4 = [ 32, 36, 40, 47,] | ||
5 = [ 52,] | ||
6 = [ 57, 61,] | ||
|
||
[fast_unlock] | ||
1 = [ 64,] | ||
2 = [ 64,] | ||
3 = [ 64,] | ||
4 = [ 64, 68, 72, 79,] | ||
5 = [ 84,] | ||
6 = [ 89, 93,] | ||
|
||
[log_workers] | ||
1 = [ 112,] | ||
2 = [ 112,] | ||
3 = [ 112,] | ||
4 = [ 112, 116, 123,] | ||
5 = [ 112, 123, 116,] | ||
|
||
[schedule_job] | ||
1 = [ 160,] | ||
2 = [ 160, 164, 165, 167, 168, 172, 174,] | ||
3 = [ 180, 182, 184,] | ||
4 = [ 195, 189,] | ||
5 = [ 197, 199,] | ||
6 = [ 204, 206,] | ||
10 = [ 224, 226,] | ||
11 = [ 195, 189,] | ||
12 = [ 211, 213,] | ||
13 = [ 235, 237,] | ||
14 = [ 242, 244,] | ||
15 = [ 257,] | ||
|
||
[job_status] | ||
1 = [ 128,] | ||
2 = [ 128, 132, 134, 137, 144,] | ||
3 = [ 149, 152, 154,] | ||
|
||
[main] | ||
1 = [ 352,] | ||
2 = [ 380,] |
Oops, something went wrong.