Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
18614b7
Scripts clean final, postgres startup script fixed
chase1k Oct 24, 2025
5c37c89
fixed to show execution count + type
oleglazari Oct 27, 2025
fcb750d
added postgres coverage analytics
oleglazari Oct 28, 2025
ad2b8f8
added proper run fuzzilli
oleglazari Oct 28, 2025
388cdc4
added helper script to query
oleglazari Oct 29, 2025
7f28c79
Script fixing again
chase1k Oct 29, 2025
0ee43d7
Merge with database coverage
chase1k Oct 29, 2025
fd4bf24
Resolve merge conflict: replace runFuzzilli.sh with Scripts/RunFuzzil…
oleglazari Oct 29, 2025
bc0df4c
Run fuzzilli script cleaner
chase1k Oct 29, 2025
ba44155
Script clean #7
chase1k Oct 29, 2025
3346d3c
Optional logging
chase1k Oct 29, 2025
5b3b4c0
Resolve merge conflicts and integrate distributed database features
oleglazari Oct 29, 2025
e284ce7
Oleg's slop code fixed, removed sql errors and database might actuall…
chase1k Oct 29, 2025
973c022
Query script updated for new structure
chase1k Oct 29, 2025
f840ff4
DBQuery.sh coverage statisics iteration 1
chase1k Oct 29, 2025
f6f828a
DBQuery.sh coverage statisics iteration 2
chase1k Oct 29, 2025
791afc5
DBQuery.sh coverage statisics iteration 3
chase1k Oct 29, 2025
b415b99
Merge branch 'distributed-database' of https://github.com/VRIG-RITSEC…
oleglazari Oct 29, 2025
c0451e8
added coverage fixes + refactor to program hash instead of bsae64
oleglazari Oct 29, 2025
0df6281
added env files
oleglazari Oct 29, 2025
8fef24a
Merge branch 'main' into distributed-database
oleglazari Oct 29, 2025
beca5f4
added semi
oleglazari Nov 7, 2025
7c3c680
added workers, sync todo
oleglazari Nov 7, 2025
a8aef7c
Update sync interval to 60 seconds in docker-compose and scripts; add…
oleglazari Nov 7, 2025
f2eba9e
Add multiple worker configurations in docker-compose; update sync int…
oleglazari Nov 7, 2025
6c66a73
got rid of postgress tests
oleglazari Nov 7, 2025
34c363c
semi-working distributed
oleglazari Nov 11, 2025
0127400
removed all deadcode, added useful scripts
oleglazari Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Distributed Fuzzing Environment Configuration
# Copy this file to .env and modify as needed

# Master PostgreSQL Database Configuration
POSTGRES_PASSWORD=fuzzilli123

# Fuzzer Configuration
FUZZER_COUNT=3
SYNC_INTERVAL=300
TIMEOUT=2500
MIN_MUTATIONS_PER_SAMPLE=25

# Optional: Override default fuzzer instance names
# FUZZER_INSTANCE_NAMES=fuzzer-1,fuzzer-2,fuzzer-3

# Optional: Custom V8 revision
# V8_REVISION=b0157a634e584163cbe6004db3161dc16dea20f9

# Optional: Resource limits
# FUZZER_MEMORY_LIMIT=2G
# FUZZER_MEMORY_RESERVATION=1G

# Optional: Enable debug logging
# DEBUG_LOGGING=true
58 changes: 58 additions & 0 deletions Cloud/VRIG/Dockerfile.distributed
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Stage 1: Build Fuzzilli
FROM docker.io/swift:latest

ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL=bash

RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install nodejs

RUN useradd -m builder
WORKDIR /home/builder

ADD .. fuzzillai

# build Fuzzilli
RUN cd fuzzillai && \
# Temporarily remove test target to avoid build issues
sed -i '/\.testTarget(name: "FuzzilliTests"/,/),$/d' Package.swift && \
swift build -c release --product FuzzilliCli && \
# Verify the executable was created
ls -la .build/release/ && \
find .build -name "FuzzilliCli" -type f -executable

#####################
# Stage 2: Runtime
FROM docker.io/swift:latest

ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL=bash

RUN apt-get -y update && apt-get -y upgrade

RUN useradd -m app

WORKDIR /home/app

# Copy Fuzzilli executable
COPY --from=0 /home/builder/fuzzillai/.build/release/FuzzilliCli FuzzilliCli

# Create directory for V8 build (will be mounted from host)
RUN mkdir -p ./fuzzbuild

RUN mkdir -p ./Corpus

# Environment variables for distributed fuzzing
ENV POSTGRES_URL=postgresql://fuzzilli:fuzzilli123@postgres-master:5432/fuzzilli_master
ENV FUZZER_INSTANCE_NAME=fuzzer-default
ENV TIMEOUT=2500
ENV MIN_MUTATIONS_PER_SAMPLE=25
ENV DEBUG_LOGGING=false

# Default command for distributed fuzzing
# Single master database mode - all workers connect directly to master
CMD ./FuzzilliCli --profile=v8debug --engine=multi --resume --corpus=postgresql \
--postgres-url="${POSTGRES_URL}" \
--timeout="${TIMEOUT}" \
--minMutationsPerSample="${MIN_MUTATIONS_PER_SAMPLE}" \
--postgres-logging ./fuzzbuild/d8
1 change: 0 additions & 1 deletion Scripts/RunFuzzilli.sh

This file was deleted.

103 changes: 0 additions & 103 deletions Scripts/SetupPostgres.sh

This file was deleted.

145 changes: 145 additions & 0 deletions Scripts/benchmark-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/bin/bash

# benchmark-server.sh - Benchmark server to determine optimal worker count
# Usage: ./Scripts/benchmark-server.sh

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'

echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} Server Performance Benchmark${NC}"
echo -e "${CYAN}========================================${NC}"
echo ""

# Get system specs
echo -e "${BLUE}=== System Specifications ===${NC}"
CPU_CORES=$(nproc)
TOTAL_MEM=$(free -h | grep Mem | awk '{print $2}')
AVAIL_MEM=$(free -h | grep Mem | awk '{print $7}')
DISK_SPACE=$(df -h / | tail -1 | awk '{print $4}')

echo -e "CPU Cores: ${GREEN}${CPU_CORES}${NC}"
echo -e "Total Memory: ${GREEN}${TOTAL_MEM}${NC}"
echo -e "Available Memory: ${GREEN}${AVAIL_MEM}${NC}"
echo -e "Disk Space: ${GREEN}${DISK_SPACE}${NC}"
echo ""

# Estimate resource usage per worker
echo -e "${BLUE}=== Resource Estimation ===${NC}"
echo "Estimating resource usage per fuzzer worker..."
echo ""

# Typical resource usage per worker (can be adjusted based on observations)
ESTIMATED_CPU_PER_WORKER=15 # percentage
ESTIMATED_MEM_PER_WORKER=512 # MB
ESTIMATED_DB_CONNECTIONS_PER_WORKER=5

# Calculate recommendations
MAX_WORKERS_BY_CPU=$((CPU_CORES * 100 / ESTIMATED_CPU_PER_WORKER))
AVAIL_MEM_MB=$(free -m | grep Mem | awk '{print $7}')
MAX_WORKERS_BY_MEM=$((AVAIL_MEM_MB / ESTIMATED_MEM_PER_WORKER))
MAX_DB_CONNECTIONS=100 # PostgreSQL default max_connections
MAX_WORKERS_BY_DB=$((MAX_DB_CONNECTIONS / ESTIMATED_DB_CONNECTIONS_PER_WORKER))

# Conservative estimate (use minimum)
RECOMMENDED_WORKERS=$((MAX_WORKERS_BY_CPU < MAX_WORKERS_BY_MEM ? MAX_WORKERS_BY_CPU : MAX_WORKERS_BY_MEM))
RECOMMENDED_WORKERS=$((RECOMMENDED_WORKERS < MAX_WORKERS_BY_DB ? RECOMMENDED_WORKERS : MAX_WORKERS_BY_DB))

# Apply safety margin (80% of calculated)
RECOMMENDED_WORKERS=$((RECOMMENDED_WORKERS * 80 / 100))
RECOMMENDED_WORKERS=$((RECOMMENDED_WORKERS > 1 ? RECOMMENDED_WORKERS : 1))

echo -e "Estimated CPU per worker: ${YELLOW}${ESTIMATED_CPU_PER_WORKER}%${NC}"
echo -e "Estimated Memory per worker: ${YELLOW}${ESTIMATED_MEM_PER_WORKER}MB${NC}"
echo -e "Estimated DB conns per worker: ${YELLOW}${ESTIMATED_DB_CONNECTIONS_PER_WORKER}${NC}"
echo ""

echo -e "${BLUE}=== Capacity Analysis ===${NC}"
echo -e "Max workers (CPU): ${CYAN}${MAX_WORKERS_BY_CPU}${NC}"
echo -e "Max workers (Memory): ${CYAN}${MAX_WORKERS_BY_MEM}${NC}"
echo -e "Max workers (DB): ${CYAN}${MAX_WORKERS_BY_DB}${NC}"
echo ""

echo -e "${GREEN}=== Recommended Configuration ===${NC}"
echo -e "Recommended Workers: ${GREEN}${RECOMMENDED_WORKERS}${NC}"
echo ""

# Performance test with current workers
if docker ps --format "{{.Names}}" | grep -q "fuzzer-worker"; then
echo -e "${BLUE}=== Current Performance Test ===${NC}"
echo "Testing current worker performance..."
echo ""

# Get current worker count
CURRENT_WORKERS=$(docker ps --format "{{.Names}}" | grep -c "fuzzer-worker" || echo "0")
echo -e "Current Workers: ${CYAN}${CURRENT_WORKERS}${NC}"

# Monitor for 30 seconds
echo "Monitoring for 30 seconds..."
START_TIME=$(date +%s)

# Get initial stats
if docker ps --format "{{.Names}}" | grep -q "fuzzilli-postgres-master"; then
DB_CONTAINER="fuzzilli-postgres-master"
DB_NAME="fuzzilli_master"
DB_USER="fuzzilli"

INITIAL_EXECS=$(docker exec "$DB_CONTAINER" psql -U "$DB_USER" -d "$DB_NAME" -t -A -c "
SELECT COUNT(*) FROM execution WHERE created_at > NOW() - INTERVAL '1 minute';
" 2>/dev/null || echo "0")

sleep 30

FINAL_EXECS=$(docker exec "$DB_CONTAINER" psql -U "$DB_USER" -d "$DB_NAME" -t -A -c "
SELECT COUNT(*) FROM execution WHERE created_at > NOW() - INTERVAL '1 minute';
" 2>/dev/null || echo "0")

EXECS_PER_SEC=$(( (FINAL_EXECS - INITIAL_EXECS) / 30 ))
EXECS_PER_WORKER=$(( EXECS_PER_SEC / CURRENT_WORKERS ))

echo -e "Executions/sec: ${GREEN}${EXECS_PER_SEC}${NC}"
echo -e "Executions/worker: ${GREEN}${EXECS_PER_WORKER}${NC}"
echo ""

# Get system load
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
MEM_USAGE=$(free | grep Mem | awk '{printf "%.1f", ($3/$2) * 100.0}')

echo -e "CPU Usage: ${CYAN}${CPU_USAGE}%${NC}"
echo -e "Memory Usage: ${CYAN}${MEM_USAGE}%${NC}"
echo ""

# Scaling recommendations
echo -e "${BLUE}=== Scaling Recommendations ===${NC}"
if (( $(echo "$CPU_USAGE < 50" | bc -l) )) && (( $(echo "$MEM_USAGE < 50" | bc -l) )); then
SUGGESTED_WORKERS=$((CURRENT_WORKERS * 2))
echo -e "${GREEN}✓ System has capacity${NC}"
echo -e "Suggested workers: ${GREEN}${SUGGESTED_WORKERS}${NC} (double current)"
elif (( $(echo "$CPU_USAGE > 80" | bc -l) )) || (( $(echo "$MEM_USAGE > 80" | bc -l) )); then
SUGGESTED_WORKERS=$((CURRENT_WORKERS / 2))
SUGGESTED_WORKERS=$((SUGGESTED_WORKERS > 1 ? SUGGESTED_WORKERS : 1))
echo -e "${RED}⚠ System under high load${NC}"
echo -e "Suggested workers: ${YELLOW}${SUGGESTED_WORKERS}${NC} (reduce by half)"
else
echo -e "${YELLOW}System load is moderate${NC}"
echo -e "Current worker count seems appropriate"
fi
fi
else
echo -e "${YELLOW}No workers currently running${NC}"
echo -e "Start workers with: ${CYAN}./Scripts/start-distributed.sh ${RECOMMENDED_WORKERS}${NC}"
fi

echo ""
echo -e "${CYAN}========================================${NC}"

Loading