#!/usr/bin/env bash # JR-021 — jRay never injects into index.html on disk. # # This is a requirement to *not do* something, so it is verified by absence. # A unit test cannot show that no code path writes the tag; a grep can. # # The prohibition is on injection, not on writing: JR-022's migration must write # to index.html in order to remove a legacy patch. So the check is for code that # *adds* the script tag, not for File.Write* generally. # # TRACES: JR-021 | PR-004 set -euo pipefail cd "$(dirname "$0")/../.." src="Jellyfin.Plugin.JRay" status=0 # The injection is "script tag + marker" written back to the file. The removal # path also names both, so match on the concatenation that builds a patched # document rather than on the constants themselves. if grep -rn --include='*.cs' -E '(ScriptTag|Injected)[[:space:]]*\+.*BodyClose|ReplaceLast|""[[:space:]]*,' "$src" \ | grep -v 'FileTransformationRegistration.cs'; then echo "FAIL (JR-021): index.html injection logic found outside the File Transformation callback." >&2 status=1 fi # WebClientPatchService is removal-only. Any write there must be the cleaned # document; a write of a *patched* one is the regression this guards. if grep -n -E 'WriteAllText\((?!.*cleaned)' -P "$src/Services/WebClientPatchService.cs" >/dev/null 2>&1; then echo "FAIL (JR-021): WebClientPatchService writes something other than the cleaned document." >&2 status=1 fi # The disk-patching entry point must not come back. if grep -rn --include='*.cs' -E '\bWebClientPatchService\.Apply\b' "$src"; then echo "FAIL (JR-021): the injecting Apply() entry point has been reintroduced." >&2 status=1 fi if [ "$status" -eq 0 ]; then echo "OK (JR-021): no on-disk injection path." fi exit "$status"