From 1883c6b194a297d55ea99402787d65f99daf3a33 Mon Sep 17 00:00:00 2001 From: Andrew Quijano Date: Sat, 10 Aug 2024 18:25:03 -0400 Subject: [PATCH] Have database point to postgres 14 on n local host if running LAVA locally --- scripts/lava.sh | 12 ++++++------ scripts/vars.sh | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/lava.sh b/scripts/lava.sh index b51ce698..eb0f66b5 100755 --- a/scripts/lava.sh +++ b/scripts/lava.sh @@ -132,9 +132,9 @@ RESET_DB() { lf="$logs/dbwipe.log" truncate "$lf" progress "everything" 1 "Resetting lava db -- logging to $lf" - run_remote "$buildhost" "dropdb -U postgres -h database $db || true" "$lf" - run_remote "$buildhost" "createdb -U postgres -h database $db || true" "$lf" - run_remote "$buildhost" "psql -d $db -h database -f $lava/tools/lavaODB/generated/lava.sql -U postgres" "$lf" + run_remote "$buildhost" "dropdb -U postgres -h $dbhost $db || true" "$lf" + run_remote "$buildhost" "createdb -U postgres -h $dbhost $db || true" "$lf" + run_remote "$buildhost" "psql -d $db -h $dbhost -f $lava/tools/lavaODB/generated/lava.sql -U postgres" "$lf" run_remote "$buildhost" "echo dbwipe complete" "$lf" } @@ -211,7 +211,7 @@ if [ $taint -eq 1 ]; then # If we didn't just reset the DB, we need clear out any existing taint labels before running FBI progress "everything" 1 "Clearing taint data from DB" lf="$logs/dbwipe_taint.log" - run_remote "$buildhost" "psql -U postgres -h database -c \"delete from dua_viable_bytes; delete from labelset;\" $db" "$lf" + run_remote "$buildhost" "psql -U postgres -h $dbhost -c \"delete from dua_viable_bytes; delete from labelset;\" $db" "$lf" fi progress "everything" 1 "Taint step -- running panda and fbi" for input in $inputs @@ -222,14 +222,14 @@ if [ $taint -eq 1 ]; then progress "everything" 1 "PANDA taint analysis prospective bug mining -- input $input -- logging to $lf" run_remote "$buildhost" "$python $scripts/bug_mining.py $hostjson $project_name $input $curtail" "$lf" echo -n "Num Bugs in db: " - bug_count=$(run_remote "$buildhost" "psql -At $db -U postgres -h database -c 'select count(*) from bug'") + bug_count=$(run_remote "$buildhost" "psql -At $db -U postgres -h $dbhost -c 'select count(*) from bug'") if [ "$bug_count" = "0" ]; then echo "FATAL ERROR: no bugs found" exit 1 fi echo "Found $bug_count bugs" echo - run_remote "$buildhost" "psql $db -U postgres -h database -c 'select count(*), type from bug group by type order by type'" + run_remote "$buildhost" "psql $db -U postgres -h $dbhost -c 'select count(*), type from bug group by type order by type'" done tock echo "bug_mining complete $time_diff seconds" diff --git a/scripts/vars.sh b/scripts/vars.sh index 484e51ad..5dc6bdd3 100644 --- a/scripts/vars.sh +++ b/scripts/vars.sh @@ -84,3 +84,8 @@ scripts="$lava/scripts" python="/usr/bin/python3" pdb="/usr/bin/python3 -m pdb " dockername="lava32" + +db_host="database" +if [ "$buildhost" = "localhost" ]; then + dbhost="/var/run/postgresql/14-main.pg_stat_tmp" +fi \ No newline at end of file