#!/bin/bash # Script d'installation pour tous les outils avancΓ©s Warfactory # Installe fuzzing, formal verification, concurrency analysis, etc. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" echo "πŸ”§ Setting up Warfactory Advanced Tools..." echo "" # Detect OS if [[ "$OSTYPE" == "linux-gnu"* ]]; then OS="linux" DISTRO=$(lsb_release -si 2>/dev/null || echo "Unknown") elif [[ "$OSTYPE" == "darwin"* ]]; then OS="macos" else echo "❌ Unsupported OS: $OSTYPE" exit 1 fi echo "πŸ–₯️ Detected OS: $OS" echo "" # ============================================================================= # FUZZING TOOLS # ============================================================================= echo "πŸ” Installing Fuzzing Tools..." # AFL++ if ! command -v afl-fuzz &> /dev/null; then echo " Installing AFL++..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get update sudo apt-get install -y afl++ elif [[ "$DISTRO" == "Fedora" ]] || [[ "$DISTRO" == "CentOS" ]]; then sudo dnf install -y afl else # Build from source git clone https://github.com/AFLplusplus/AFLplusplus.git /tmp/aflplusplus cd /tmp/aflplusplus make all sudo make install fi elif [[ "$OS" == "macos" ]]; then brew install afl++ fi echo " βœ“ AFL++ installed" else echo " βœ“ AFL++ already installed" fi # honggfuzz if ! command -v honggfuzz &> /dev/null; then echo " Installing honggfuzz..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get install -y honggfuzz else # Build from source git clone https://github.com/google/honggfuzz.git /tmp/honggfuzz cd /tmp/honggfuzz make sudo make install fi elif [[ "$OS" == "macos" ]]; then brew install honggfuzz fi echo " βœ“ honggfuzz installed" else echo " βœ“ honggfuzz already installed" fi # ============================================================================= # FORMAL VERIFICATION TOOLS # ============================================================================= echo "" echo "πŸ”¬ Installing Formal Verification Tools..." # CBMC if ! command -v cbmc &> /dev/null; then echo " Installing CBMC..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get install -y cbmc else # Download binary release CBMC_VERSION="5.95.1" wget "https://github.com/diffblue/cbmc/releases/download/cbmc-${CBMC_VERSION}/cbmc-${CBMC_VERSION}-linux-64.tgz" -O /tmp/cbmc.tgz cd /tmp tar -xzf cbmc.tgz sudo cp cbmc-*/bin/* /usr/local/bin/ fi elif [[ "$OS" == "macos" ]]; then brew install cbmc fi echo " βœ“ CBMC installed" else echo " βœ“ CBMC already installed" fi # KLEE (plus complexe, nΓ©cessite LLVM) if ! command -v klee &> /dev/null; then echo " Installing KLEE..." if [[ "$OS" == "linux" ]]; then # KLEE is complex to build, use Docker image instead echo " πŸ“¦ KLEE will use Docker image (recommended)" echo " Run: docker pull klee/klee" echo " Usage: docker run --rm -v \$(pwd):/tmp klee/klee klee /tmp/your_file.bc" elif [[ "$OS" == "macos" ]]; then echo " πŸ“¦ KLEE installation on macOS requires manual setup" echo " See: https://klee.github.io/build-llvm9/" fi else echo " βœ“ KLEE already installed" fi # ============================================================================= # STATIC ANALYSIS TOOLS # ============================================================================= echo "" echo "πŸ” Installing Static Analysis Tools..." # Cppcheck if ! command -v cppcheck &> /dev/null; then echo " Installing Cppcheck..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get install -y cppcheck elif [[ "$DISTRO" == "Fedora" ]] || [[ "$DISTRO" == "CentOS" ]]; then sudo dnf install -y cppcheck fi elif [[ "$OS" == "macos" ]]; then brew install cppcheck fi echo " βœ“ Cppcheck installed" else echo " βœ“ Cppcheck already installed" fi # ABI compliance checker if ! command -v abi-compliance-checker &> /dev/null; then echo " Installing ABI Compliance Checker..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get install -y abi-compliance-checker else # Install from source git clone https://github.com/lvc/abi-compliance-checker.git /tmp/abi-checker cd /tmp/abi-checker sudo make install prefix=/usr/local fi elif [[ "$OS" == "macos" ]]; then # Build from source git clone https://github.com/lvc/abi-compliance-checker.git /tmp/abi-checker cd /tmp/abi-checker sudo make install prefix=/usr/local fi echo " βœ“ ABI Compliance Checker installed" else echo " βœ“ ABI Compliance Checker already installed" fi # ============================================================================= # CONCURRENCY ANALYSIS TOOLS # ============================================================================= echo "" echo "🧡 Installing Concurrency Analysis Tools..." # Valgrind if ! command -v valgrind &> /dev/null; then echo " Installing Valgrind..." if [[ "$OS" == "linux" ]]; then if [[ "$DISTRO" == "Ubuntu" ]] || [[ "$DISTRO" == "Debian" ]]; then sudo apt-get install -y valgrind elif [[ "$DISTRO" == "Fedora" ]] || [[ "$DISTRO" == "CentOS" ]]; then sudo dnf install -y valgrind fi elif [[ "$OS" == "macos" ]]; then brew install --HEAD valgrind fi echo " βœ“ Valgrind installed" else echo " βœ“ Valgrind already installed" fi # ============================================================================= # GUIDELINES SUPPORT LIBRARY # ============================================================================= echo "" echo "πŸ“‹ Setting up Guidelines Support Library..." GSL_DIR="$PROJECT_ROOT/third_party/gsl" if [[ ! -d "$GSL_DIR" ]]; then echo " Cloning Microsoft GSL..." git clone https://github.com/microsoft/GSL.git "$GSL_DIR" echo " βœ“ GSL cloned to third_party/gsl" else echo " βœ“ GSL already available" fi # ============================================================================= # VERIFICATION # ============================================================================= echo "" echo "βœ… Verifying installations..." TOOLS=( "afl-fuzz:AFL++" "honggfuzz:honggfuzz" "cbmc:CBMC" "cppcheck:Cppcheck" "valgrind:Valgrind" "abi-compliance-checker:ABI Checker" "clang:Clang (for libFuzzer)" "llvm-profdata:LLVM tools" ) for tool_info in "${TOOLS[@]}"; do tool="${tool_info%:*}" name="${tool_info#*:}" if command -v "$tool" &> /dev/null; then echo " βœ“ $name: $(which $tool)" else echo " ❌ $name: not found" fi done echo "" echo "🎯 Setup complete!" echo "" echo "πŸ“– Usage examples:" echo " mkdir build && cd build" echo " cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_ADVANCED_TOOLS=ON .." echo " make economy-engine" echo "" echo "πŸ” Run fuzzing:" echo " make economy-engine_fuzz_all" echo "" echo "πŸ”¬ Run formal verification:" echo " make economy-engine_cbmc" echo "" echo "🧡 Run concurrency analysis:" echo " make economy-engine_helgrind" echo "" echo "πŸ“Š Generate coverage report:" echo " make economy-engine_coverage_run" echo "" echo "πŸ”— Check ABI compatibility:" echo " make economy-engine_abi_check"