feat: add batch diagnostic commands
This commit is contained in:
parent
1fa6555813
commit
c28c4ec270
14
README.md
14
README.md
|
|
@ -34,6 +34,17 @@ The input must be inside the evidence root. The reference time makes
|
|||
time-sensitive findings reproducible, and the producer version records the
|
||||
analyzer revision. Existing outputs are rejected unless `--force` is supplied.
|
||||
|
||||
Analyse every JSON capture in a directory tree while preserving its relative
|
||||
path in the output directory:
|
||||
|
||||
```bash
|
||||
bash tools/analyse-all.sh /path/to/captures \
|
||||
--evidence-root /path/to/evidence \
|
||||
--output-dir /path/to/diagnostics \
|
||||
--reference-time 2026-09-15T12:00:00Z \
|
||||
--producer-version "$(git rev-parse HEAD)"
|
||||
```
|
||||
|
||||
The bundled catalog contains 53 reviewed Windows event rules and seven advisory
|
||||
watchlist definitions. Watchlist matches identify candidates for investigation;
|
||||
they do not assert exploitation or hardware failure.
|
||||
|
|
@ -47,6 +58,9 @@ raw values with:
|
|||
bash tools/validate.sh diagnostic.json --evidence-root /path/to/evidence
|
||||
```
|
||||
|
||||
Use `bash tools/validate-all.sh DIRECTORY --evidence-root /path/to/evidence`
|
||||
to validate every JSON diagnostic in a directory tree.
|
||||
|
||||
The public format is documented in
|
||||
[docs/diagnostic-contract.md](docs/diagnostic-contract.md), and the JSON Schema
|
||||
is available at [schemas/diagnostic.schema.json](schemas/diagnostic.schema.json).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
usage(){ echo "Usage: $0 INPUT_DIR --evidence-root DIR --output-dir DIR --reference-time TIME --producer-version VERSION [--force]" >&2; exit 2; }
|
||||
input_dir=${1:-}; [[ -n "$input_dir" ]]||usage; shift
|
||||
evidence_root= output_dir= reference_time= producer_version= force=false
|
||||
while (($#)); do case $1 in
|
||||
--evidence-root) (($# >= 2))||usage; evidence_root=$2; shift 2;; --output-dir) (($# >= 2))||usage; output_dir=$2; shift 2;;
|
||||
--reference-time) (($# >= 2))||usage; reference_time=$2; shift 2;; --producer-version) (($# >= 2))||usage; producer_version=$2; shift 2;;
|
||||
--force) force=true; shift;; *) usage;; esac; done
|
||||
for value in "$evidence_root" "$output_dir" "$reference_time" "$producer_version"; do [[ -n "$value" ]]||usage; done
|
||||
input_dir=$(realpath "$input_dir"); mkdir -p "$output_dir"; output_dir=$(realpath "$output_dir")
|
||||
[[ "$output_dir" != "$input_dir" && "$output_dir" != "$input_dir"/* ]]||{ echo "output directory must be outside the input tree" >&2; exit 1; }
|
||||
count=0
|
||||
while IFS= read -r -d '' input; do
|
||||
relative=${input#"$input_dir/"}; output="$output_dir/${relative%.json}.diagnostic.json"
|
||||
mkdir -p "$(dirname "$output")"; arguments=()
|
||||
[[ "$force" == false ]]||arguments+=(--force)
|
||||
"$root/tools/analyse.sh" "$input" --evidence-root "$evidence_root" --output "$output" \
|
||||
--reference-time "$reference_time" --producer-version "$producer_version" "${arguments[@]}"
|
||||
((count+=1))
|
||||
done < <(find "$input_dir" -type f -name '*.json' -print0 | sort -z)
|
||||
((count > 0))||{ echo "$input_dir: no JSON captures found" >&2; exit 1; }
|
||||
echo "Analysed $count captures into $output_dir"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
usage(){ echo "Usage: $0 INPUT_DIR [--evidence-root DIR]" >&2; exit 2; }
|
||||
input_dir=${1:-}; [[ -n "$input_dir" ]]||usage; shift; evidence_root=
|
||||
while (($#)); do case $1 in --evidence-root) (($# >= 2))||usage; evidence_root=$2; shift 2;; *) usage;; esac; done
|
||||
count=0
|
||||
while IFS= read -r -d '' input; do
|
||||
arguments=(); [[ -z "$evidence_root" ]]||arguments+=(--evidence-root "$evidence_root")
|
||||
"$root/tools/validate.sh" "$input" "${arguments[@]}"; ((count+=1))
|
||||
done < <(find "$input_dir" -type f -name '*.json' -print0 | sort -z)
|
||||
((count > 0))||{ echo "$input_dir: no JSON diagnostics found" >&2; exit 1; }
|
||||
echo "Validated $count diagnostics"
|
||||
Reference in New Issue