fix(security): document unsafe and TLS overrides (#2835)

This commit is contained in:
安正超
2026-05-06 23:09:02 +08:00
committed by GitHub
parent 70be0804ee
commit 4728abcff1
18 changed files with 89 additions and 17 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "$ROOT_DIR"
status=0
while IFS=: read -r file line _; do
start=$((line > 3 ? line - 3 : 1))
end=$((line + 6))
if ! sed -n "${start},${end}p" "$file" | rg -q "SAFETY:"; then
printf '%s:%s: unsafe_code allowance must have a nearby SAFETY comment\n' "$file" "$line" >&2
status=1
fi
done < <(rg -n '^[[:space:]]*#!?\[allow\([^]]*\bunsafe_code\b[^]]*\)\]' --glob '*.rs' .)
exit "$status"