Files
ha-freshharvest/scripts/audit.sh
T
flan 3e880ff2c1
Validate / hassfest (push) Failing after 23s
Validate / pytest (push) Successful in 9s
Validate / HACS (push) Failing after 1m21s
Expose every order component as its own entity and prepare for release
Each cost line is now an entity rather than an attribute: subtotal, box price,
add-ons, tax and delivery fee, plus a total and free-delivery-remaining for the
open order, a delivery-day sensor, and a binary sensor that turns off at the
cutoff. Entities share a base class and declare a scope, so a description
states only the field it reads.

Also parses the driver tip, Bounty savings and the free-delivery threshold. The
threshold is carried across orders because the progress bar only renders on
carts that have not met it.

Adds LICENSE, hacs.json, a CI workflow, a pre-publish audit script, and a test
that cross-checks every entity's translation_key against both translation
files. Manifest URLs now point at GitHub rather than a private forge.
2026-08-03 19:32:50 +00:00

67 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Pre-publish audit: nothing personal, nothing pointing at private infrastructure,
# and every file a public HACS repository needs.
#
# grep exits 1 when it finds nothing, so this judges on OUTPUT, not exit status —
# testing the exit code reports every clean check as a finding.
set -uo pipefail
cd "$(dirname "$0")/.."
findings=0
# This script necessarily contains the very strings it searches for, so it
# excludes itself — otherwise every check reports itself as a finding.
EXCLUDES=(--exclude-dir=.git --exclude-dir=.pytest_cache --exclude-dir=__pycache__
--exclude-dir=.venv --exclude=audit.sh)
check() {
local label="$1"; shift
local out
out="$("$@" 2>/dev/null)"
if [ -z "$out" ]; then
printf ' \033[32m✓\033[0m %s\n' "$label"
else
printf ' \033[31m✗\033[0m %s\n' "$label"
printf '%s\n' "$out" | head -8 | sed 's/^/ /'
findings=$((findings + 1))
fi
}
echo "Content"
check "no account-holder details" \
grep -rniE "holden|salomon|arch\.fyi|garden ln|decatur|\(678|30030" "${EXCLUDES[@]}" .
check "no private infrastructure URLs" \
grep -rniE "onetick|truenas|192\.168\.|ha-box" "${EXCLUDES[@]}" .
check "no real cart identifiers" \
grep -rnE "2772590|2778336" "${EXCLUDES[@]}" .
check "no live account figures in docs" \
grep -rnE "109\.06|105\.88|72\.88" README.md CHANGELOG.md
check "no hardcoded secrets" \
grep -rniE "api[_-]?key\s*[:=]\s*[\"'][^\"']{8,}|access_token\s*[:=]\s*[\"'][^\"']{8,}" \
"${EXCLUDES[@]}" --include=*.py --include=*.json --include=*.yaml .
echo "Required files"
for f in LICENSE hacs.json README.md CHANGELOG.md NOTICE \
.github/workflows/validate.yml \
custom_components/freshharvest/manifest.json \
custom_components/freshharvest/translations/en.json; do
if [ -e "$f" ]; then
printf ' \033[32m✓\033[0m %s\n' "$f"
else
printf ' \033[31m✗\033[0m missing %s\n' "$f"
findings=$((findings + 1))
fi
done
echo "Manifest"
check "manifest URLs are public" \
grep -nE '"(documentation|issue_tracker)": "(?!https://github\.com/)' -P \
custom_components/freshharvest/manifest.json
echo
if [ "$findings" -eq 0 ]; then
printf '\033[32mAudit clean — 0 findings\033[0m\n'
else
printf '\033[31m%s finding(s)\033[0m\n' "$findings"
fi
exit "$findings"