Add seed_dir

This commit is contained in:
Matthew Knight 2026-03-06 09:35:57 -08:00
parent b16d352643
commit 37b9ddac39
No known key found for this signature in database
1 changed files with 37 additions and 3 deletions

View File

@ -27,6 +27,15 @@ inputs:
description: 'Binary name in zig-out/bin/ (auto-detected if only one)' description: 'Binary name in zig-out/bin/ (auto-detected if only one)'
required: false required: false
default: '' default: ''
seed_dir:
description: |
Directory containing per-target seed inputs. Each subdirectory should match
a target name from the targets input. Files are merged with the downloaded corpus.
Example layout:
seeds/lexer/valid-token.txt
seeds/parser/minimal-program.txt
required: false
default: ''
duration: duration:
description: 'Fuzz duration per target in seconds' description: 'Fuzz duration per target in seconds'
required: false required: false
@ -73,6 +82,7 @@ runs:
COMMIT: ${{ inputs.commit }} COMMIT: ${{ inputs.commit }}
TARGETS: ${{ inputs.targets }} TARGETS: ${{ inputs.targets }}
FUZZ_BINARY: ${{ inputs.fuzz_binary }} FUZZ_BINARY: ${{ inputs.fuzz_binary }}
SEED_DIR: ${{ inputs.seed_dir }}
DURATION: ${{ inputs.duration }} DURATION: ${{ inputs.duration }}
EXTRA_AFL_ARGS: ${{ inputs.afl_args }} EXTRA_AFL_ARGS: ${{ inputs.afl_args }}
TARGET_PLATFORM: ${{ inputs.target }} TARGET_PLATFORM: ${{ inputs.target }}
@ -130,6 +140,15 @@ runs:
rm -rf "${SEEDS}" rm -rf "${SEEDS}"
mkdir -p "${SEEDS}" mkdir -p "${SEEDS}"
# Copy per-target seeds from repo if available.
if [ -n "${SEED_DIR}" ] && [ -d "${SEED_DIR}/${FUZZ_TARGET}" ]; then
REPO_SEED_COUNT=$(find "${SEED_DIR}/${FUZZ_TARGET}" -maxdepth 1 -type f | wc -l)
if [ "${REPO_SEED_COUNT}" -gt 0 ]; then
cp "${SEED_DIR}/${FUZZ_TARGET}"/* "${SEEDS}/" 2>/dev/null || true
echo "Copied ${REPO_SEED_COUNT} repo seeds from ${SEED_DIR}/${FUZZ_TARGET}"
fi
fi
DL_START=$(date +%s) DL_START=$(date +%s)
cairn corpus download \ cairn corpus download \
-server "${CAIRN_SERVER}" \ -server "${CAIRN_SERVER}" \
@ -248,17 +267,32 @@ runs:
done done
fi fi
# ── Upload new corpus entries ── # ── Minimize and upload corpus ──
QUEUE_DIR="${FINDINGS}/default/queue" QUEUE_DIR="${FINDINGS}/default/queue"
if [ -d "${QUEUE_DIR}" ]; then if [ -d "${QUEUE_DIR}" ]; then
QUEUE_COUNT=$(find "${QUEUE_DIR}" -maxdepth 1 -type f -name 'id:*' | wc -l) QUEUE_COUNT=$(find "${QUEUE_DIR}" -maxdepth 1 -type f -name 'id:*' | wc -l)
if [ "${QUEUE_COUNT}" -gt 0 ]; then if [ "${QUEUE_COUNT}" -gt 0 ]; then
echo "Uploading corpus (${QUEUE_COUNT} entries)..." UPLOAD_DIR="corpus-upload-${TARGET_NUM}"
rm -rf "${UPLOAD_DIR}"
mkdir -p "${UPLOAD_DIR}"
CMIN_START=$(date +%s)
if afl-cmin -i "${QUEUE_DIR}" -o "${UPLOAD_DIR}" -- "${FUZZ_BIN}" >/dev/null 2>&1; then
CMIN_ELAPSED=$(( $(date +%s) - CMIN_START ))
UPLOAD_COUNT=$(find "${UPLOAD_DIR}" -maxdepth 1 -type f | wc -l)
echo "Corpus for upload minimized: ${QUEUE_COUNT} -> ${UPLOAD_COUNT} entries (${CMIN_ELAPSED}s)"
else
echo "afl-cmin failed, uploading full queue"
rm -rf "${UPLOAD_DIR}"
UPLOAD_DIR="${QUEUE_DIR}"
UPLOAD_COUNT="${QUEUE_COUNT}"
fi
echo "Uploading corpus (${UPLOAD_COUNT} entries)..."
cairn corpus upload \ cairn corpus upload \
-server "${CAIRN_SERVER}" \ -server "${CAIRN_SERVER}" \
-target-id "${CAIRN_TARGET_ID}" \ -target-id "${CAIRN_TARGET_ID}" \
-run-id "${RUN_ID}" \ -run-id "${RUN_ID}" \
-dir "${QUEUE_DIR}" -dir "${UPLOAD_DIR}"
rm -rf "corpus-upload-${TARGET_NUM}"
fi fi
fi fi