Files
Lou Stella 9c183fa110 Update Analytics to Support ATT&CK v19 (#4036)
---------

Co-authored-by: pyth0n1c <87383215+pyth0n1c@users.noreply.github.com>
Co-authored-by: Nasreddine Bencherchali <nasreddineb@splunk.com>
2026-05-05 17:29:28 +02:00

47 lines
969 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
usage() {
printf 'Usage: %s <file.yml>\n' "${0##*/}" >&2
}
if [[ $# -ne 1 ]]; then
usage
exit 2
fi
file=$1
if [[ $file != *.yml ]]; then
printf 'Error: filename must include the .yml extension.\n' >&2
exit 2
fi
if [[ ! -f $file ]]; then
printf 'Error: file not found: %s\n' "$file" >&2
exit 1
fi
if [[ ! -r $file || ! -w $file ]]; then
printf 'Error: file must be readable and writable: %s\n' "$file" >&2
exit 1
fi
if ! command -v yq >/dev/null 2>&1; then
printf 'Error: yq is required but was not found on PATH.\n' >&2
exit 1
fi
if ! yq eval -e 'has("version")' "$file" >/dev/null; then
printf 'Error: expected a top-level Version field.\n' >&2
exit 1
fi
if ! yq eval -e 'has("date")' "$file" >/dev/null; then
printf 'Error: expected a top-level Date field.\n' >&2
exit 1
fi
today=$(date +%F)
TODAY=$today yq eval -i '.version = ((.version | tonumber) + 1) | .date = strenv(TODAY)' "$file"