From 95a4f920750b94e06ba453f3fbe7be89741c6abe Mon Sep 17 00:00:00 2001 From: oqyude Date: Fri, 23 Oct 2026 20:23:33 +0300 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20sops=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8=D1=82=D1=8C=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=20secrets/,=20=D0=B0=20=D0=BD=D0=B5=20=D1=82=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=BA=D0=BE=20=D0=BA=D0=BE=D1=80=D0=BD=D0=B5=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проверка #7 искала файлы только в secrets/ и не замечала вложенные каталоги: modules/server/secrets/, modules/containers/secrets/, modules/essentials/secrets/, modules/wsl/secrets/. Теперь обходятся все файлы под */secrets/*, а совпадения, требующие непривязанного правила (поведение sops для вложенных каталогов), перечисляются отдельно — предположение видно, а не спрятано. PASS: 2 FAIL: 0; 13 файлов помечены как требующие непривязанного правила. --- .ci/checks.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.ci/checks.sh b/.ci/checks.sh index fb61a7d..68e09dd 100755 --- a/.ci/checks.sh +++ b/.ci/checks.sh @@ -72,19 +72,38 @@ check_nix_flake_check() { } check_sops_path_regex() { - echo "Check #7: secrets/ files match .sops.yaml path_regex ..." + echo "Check #7: sops-encrypted files match .sops.yaml path_regex ..." local regex regex=$(awk -F'path_regex:[[:space:]]*' '/path_regex:/ {print $2; exit}' .sops.yaml) if [ -z "${regex:-}" ]; then echo " SKIP: no path_regex found in .sops.yaml" return 0 fi - local mismatches=() - while IFS= read -r -d '' f; do - if ! printf '%s\n' "$f" | grep -Eqx "${regex}"; then + local mismatches=() unanchored=() f + # Every file under any `secrets/` directory is a candidate for the sops + # creation rule — not only the ones in the top-level `secrets/`. The + # repo keeps them in five places: secrets/, modules/server/secrets/, + # modules/containers/secrets/, modules/essentials/secrets/ and + # modules/wsl/secrets/. + # + # Matching semantics: sops compares path_regex against the path, and the + # comparison is not anchored at the start of the path for a rule like + # `secrets/[^/]+...`. A file is therefore counted as protected when it + # matches the rule, and files that match only in the unanchored form are + # listed separately so the assumption stays visible instead of silent. + while IFS= read -r f; do + f="${f#./}" + if ! printf '%s\n' "$f" | grep -Eq "${regex}"; then mismatches+=("$f") + elif ! printf '%s\n' "$f" | grep -Eq "^${regex}"; then + unanchored+=("$f") fi - done < <(find secrets -type f -print0 2>/dev/null) + done < <(find . -type f -path '*/secrets/*' -not -path './.git/*' 2>/dev/null | sort) + if [ "${#unanchored[@]}" -gt 0 ]; then + echo " NOTE: ${#unanchored[@]} file(s) match the rule only when it is not anchored" + echo " at the start of the path (sops behaviour for nested secrets/):" + printf ' %s\n' "${unanchored[@]}" + fi if [ "${#mismatches[@]}" -eq 0 ]; then report 0 "sops path_regex ($regex)" else