fix(build): исключить SIGPIPE из релизных гейтов под pipefail
Поиск с флагом -q прекращает чтение на первом совпадении и закрывает свой конец
канала. Продюсер, которому осталось что писать, получает SIGPIPE и завершается
кодом 141, а `set -o pipefail` делает 141 статусом всей конструкции:
совпадение НАЙДЕНО -> продюсер оборван -> статус 141 -> «не найдено»
Для утвердительных проверок это ложный FAIL. Для отрицательных — «такой
конструкции в коде нет» — ложный PASS: запрещённая конструкция найдена, а гейт
зелёный. Отрицательными проверками закреплена половина инвариантов приёмки,
включая запрет обхода тестов и запрет `pnpm audit --prod`.
Порог резкий: пока вывод продюсера помещается в буфер канала (64 KiB на Linux),
он не блокируется и успевает завершиться раньше, чем потребитель начнёт читать.
Замер, 60 прогонов на размер: до 60 KiB — 0 отказов, ровно на 64 KiB — 58/60,
от 96 KiB — 60/60. То есть проверка выглядит исправной ровно до первого
источника крупнее буфера, а такие файлы в репозитории уже есть.
- 56 мест переведены на here-string: `grep -q PATTERN <<<"$content"`;
- продюсеры-команды (ss|awk, dpkg-query, /proc/cpuinfo, systemctl
list-unit-files) сначала читаются в переменную;
- введён code_has: десять отрицательных сканов держались на `|| true` внутри
code_without_comments, гасившем 141, — то есть на побочном эффекте
подавления ошибок, а не на заявленном свойстве;
- несуществующий путь в скане больше не означает успех: `2>/dev/null || true`
превращал опечатку в пустой вывод, а пустой вывод для проверки «этого в коде
нет» — это PASS. Проверка явная, а не через set -e: в контексте `! code_has`
bash отключает errexit на весь вызов;
- возврат пайплайна запрещён отдельной приёмкой.
This commit is contained in:
+41
-41
@@ -45,22 +45,22 @@ verify_archive() {
|
||||
local listing
|
||||
listing="$(tar -tzf "$archive")"
|
||||
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/install.sh$' || fail "archive missing install.sh"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/LICENSE$' || fail "archive missing LICENSE"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/orchestrator/hy2xs-orchestrator$' || fail "archive missing orchestrator artifact"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/ui/hy2xs-admin/hy2xs-admin$' || fail "archive missing bundled UI binary"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/systemd/hysteria-server.service$' || fail "archive missing hysteria systemd unit"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/systemd/hy2xs-admin.service$' || fail "archive missing admin systemd unit"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/templates/hysteria/config.yaml.tpl$' || fail "archive missing Hysteria config template"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/config/hy2xs.env$' || fail "archive missing canonical runtime config"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/templates/env/post-install.env.tpl$' || fail "archive missing post-install env template"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/checksums.txt$' || fail "archive missing checksums"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.version$' || fail "archive missing pinned Hysteria version"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.url$' || fail "archive missing pinned Hysteria artifact url"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.sha256$' || fail "archive missing pinned Hysteria sha256"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.resolution$' || fail "archive missing Hysteria resolution marker"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/package.release_line$' || fail "archive missing product release line"
|
||||
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/package.config_schema_version$' || fail "archive missing packaged config schema version"
|
||||
grep -q '^hy2xs-install/install.sh$' <<<"$listing" || fail "archive missing install.sh"
|
||||
grep -q '^hy2xs-install/LICENSE$' <<<"$listing" || fail "archive missing LICENSE"
|
||||
grep -q '^hy2xs-install/orchestrator/hy2xs-orchestrator$' <<<"$listing" || fail "archive missing orchestrator artifact"
|
||||
grep -q '^hy2xs-install/ui/hy2xs-admin/hy2xs-admin$' <<<"$listing" || fail "archive missing bundled UI binary"
|
||||
grep -q '^hy2xs-install/systemd/hysteria-server.service$' <<<"$listing" || fail "archive missing hysteria systemd unit"
|
||||
grep -q '^hy2xs-install/systemd/hy2xs-admin.service$' <<<"$listing" || fail "archive missing admin systemd unit"
|
||||
grep -q '^hy2xs-install/templates/hysteria/config.yaml.tpl$' <<<"$listing" || fail "archive missing Hysteria config template"
|
||||
grep -q '^hy2xs-install/config/hy2xs.env$' <<<"$listing" || fail "archive missing canonical runtime config"
|
||||
grep -q '^hy2xs-install/templates/env/post-install.env.tpl$' <<<"$listing" || fail "archive missing post-install env template"
|
||||
grep -q '^hy2xs-install/metadata/checksums.txt$' <<<"$listing" || fail "archive missing checksums"
|
||||
grep -q '^hy2xs-install/metadata/hysteria.version$' <<<"$listing" || fail "archive missing pinned Hysteria version"
|
||||
grep -q '^hy2xs-install/metadata/hysteria.url$' <<<"$listing" || fail "archive missing pinned Hysteria artifact url"
|
||||
grep -q '^hy2xs-install/metadata/hysteria.sha256$' <<<"$listing" || fail "archive missing pinned Hysteria sha256"
|
||||
grep -q '^hy2xs-install/metadata/hysteria.resolution$' <<<"$listing" || fail "archive missing Hysteria resolution marker"
|
||||
grep -q '^hy2xs-install/metadata/package.release_line$' <<<"$listing" || fail "archive missing product release line"
|
||||
grep -q '^hy2xs-install/metadata/package.config_schema_version$' <<<"$listing" || fail "archive missing packaged config schema version"
|
||||
|
||||
# Контракт установки проверяется структурно: install.sh — read-only bootstrap
|
||||
# целиком, у PHASE 1 ровно один владелец — оркестратор.
|
||||
@@ -73,9 +73,9 @@ verify_archive() {
|
||||
# Владение мутацией нельзя было отследить, потому что мутировали двое.
|
||||
local packaged_installer mutation_hits
|
||||
packaged_installer="$(tar -xOzf "$archive" hy2xs-install/install.sh)"
|
||||
printf '%s\n' "$packaged_installer" | grep -q 'preflight-install' \
|
||||
grep -q 'preflight-install' <<<"$packaged_installer" \
|
||||
|| fail "packaged install.sh does not run the read-only preflight"
|
||||
printf '%s\n' "$packaged_installer" | grep -q 'preflight-install --package-dir' \
|
||||
grep -q 'preflight-install --package-dir' <<<"$packaged_installer" \
|
||||
|| fail "packaged install.sh: could not locate the preflight invocation"
|
||||
|
||||
# Комментарии отбрасываются: строка, ОБЪЯСНЯЮЩАЯ, почему установщик больше
|
||||
@@ -87,25 +87,25 @@ verify_archive() {
|
||||
|| fail "packaged install.sh must not mutate the host; PHASE 1 belongs to the orchestrator alone. Found:
|
||||
$mutation_hits"
|
||||
|
||||
printf '%s\n' "$packaged_installer" | grep -q 'exec .*install --package-dir' \
|
||||
grep -q 'exec .*install --package-dir' <<<"$packaged_installer" \
|
||||
|| fail "packaged install.sh must hand the whole mutating phase to the orchestrator via exec"
|
||||
|
||||
local license_text
|
||||
license_text="$(tar -xOzf "$archive" hy2xs-install/LICENSE)"
|
||||
printf '%s\n' "$license_text" | grep -q 'GNU AFFERO GENERAL PUBLIC LICENSE' \
|
||||
grep -q 'GNU AFFERO GENERAL PUBLIC LICENSE' <<<"$license_text" \
|
||||
|| fail "packaged LICENSE is not the GNU Affero General Public License"
|
||||
printf '%s\n' "$license_text" | grep -q 'Version 3, 19 November 2007' \
|
||||
grep -q 'Version 3, 19 November 2007' <<<"$license_text" \
|
||||
|| fail "packaged LICENSE is not AGPL version 3"
|
||||
|
||||
local env_content
|
||||
env_content="$(tar -xOzf "$archive" hy2xs-install/config/hy2xs.env)"
|
||||
printf '%s\n' "$env_content" | grep -q 'replace-with-your-domain.example' && fail "packaged hy2xs.env contains placeholder domain"
|
||||
printf '%s\n' "$env_content" | grep -q 'replace-with-your-email@example.com' && fail "packaged hy2xs.env contains placeholder email"
|
||||
grep -q 'replace-with-your-domain.example' <<<"$env_content" && fail "packaged hy2xs.env contains placeholder domain"
|
||||
grep -q 'replace-with-your-email@example.com' <<<"$env_content" && fail "packaged hy2xs.env contains placeholder email"
|
||||
|
||||
local hysteria_tpl
|
||||
hysteria_tpl="$(tar -xOzf "$archive" hy2xs-install/templates/hysteria/config.yaml.tpl)"
|
||||
printf '%s\n' "$hysteria_tpl" | grep -q '/internal/hysteria/auth?access_token={{HYSTERIA_API_SECRET}}' || fail "hysteria auth template must include machine access_token"
|
||||
printf '%s\n' "$hysteria_tpl" | grep -q '{{OBFS_BLOCK}}' || fail "hysteria template must render a typed obfs block"
|
||||
grep -q '/internal/hysteria/auth?access_token={{HYSTERIA_API_SECRET}}' <<<"$hysteria_tpl" || fail "hysteria auth template must include machine access_token"
|
||||
grep -q '{{OBFS_BLOCK}}' <<<"$hysteria_tpl" || fail "hysteria template must render a typed obfs block"
|
||||
|
||||
# Замороженная версия обязана совпадать во всех местах пакета.
|
||||
local pinned_version pinned_sha pinned_url meta_env
|
||||
@@ -114,24 +114,24 @@ $mutation_hits"
|
||||
pinned_url="$(tar -xOzf "$archive" hy2xs-install/metadata/hysteria.url | tr -d '\n')"
|
||||
meta_env="$(tar -xOzf "$archive" hy2xs-install/metadata/package.env)"
|
||||
|
||||
printf '%s' "$pinned_version" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$' \
|
||||
grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$' <<<"$pinned_version" \
|
||||
|| fail "packaged Hysteria version is not a concrete vX.Y.Z: $pinned_version"
|
||||
printf '%s' "$pinned_sha" | grep -Eq '^[a-f0-9]{64}$' \
|
||||
grep -Eq '^[a-f0-9]{64}$' <<<"$pinned_sha" \
|
||||
|| fail "packaged Hysteria sha256 is not a 64-char hex digest"
|
||||
printf '%s' "$pinned_url" | grep -Fq "$pinned_version" \
|
||||
grep -Fq "$pinned_version" <<<"$pinned_url" \
|
||||
|| fail "packaged Hysteria artifact url does not point at the pinned version: $pinned_url"
|
||||
if printf '%s' "$pinned_url" | grep -q 'latest'; then
|
||||
if grep -q 'latest' <<<"$pinned_url"; then
|
||||
fail "packaged Hysteria artifact url must be immutable, not a moving latest: $pinned_url"
|
||||
fi
|
||||
|
||||
printf '%s\n' "$meta_env" | grep -q "^hysteria_version=${pinned_version}$" \
|
||||
grep -q "^hysteria_version=${pinned_version}$" <<<"$meta_env" \
|
||||
|| fail "metadata package.env disagrees with metadata/hysteria.version"
|
||||
printf '%s\n' "$meta_env" | grep -q "^hysteria_artifact_sha256=${pinned_sha}$" \
|
||||
grep -q "^hysteria_artifact_sha256=${pinned_sha}$" <<<"$meta_env" \
|
||||
|| fail "metadata package.env disagrees with metadata/hysteria.sha256"
|
||||
|
||||
local post_install_tpl
|
||||
post_install_tpl="$(tar -xOzf "$archive" hy2xs-install/templates/env/post-install.env.tpl)"
|
||||
printf '%s\n' "$post_install_tpl" | grep -q '^HY2_AUTH_URL=http://127.0.0.1:{{UI_PORT}}/internal/hysteria/auth?access_token={{HYSTERIA_API_SECRET}}$' || fail "post-install env template must include machine access_token in HY2_AUTH_URL"
|
||||
grep -q '^HY2_AUTH_URL=http://127.0.0.1:{{UI_PORT}}/internal/hysteria/auth?access_token={{HYSTERIA_API_SECRET}}$' <<<"$post_install_tpl" || fail "post-install env template must include machine access_token in HY2_AUTH_URL"
|
||||
|
||||
local tmp
|
||||
tmp="$(mktemp -d)"
|
||||
@@ -144,22 +144,22 @@ $mutation_hits"
|
||||
|
||||
local meta
|
||||
meta="$(cat "$tmp/hy2xs-install/metadata/package.env")"
|
||||
printf '%s\n' "$meta" | grep -q '^source_git_commit=' || fail "metadata missing source_git_commit"
|
||||
printf '%s\n' "$meta" | grep -q '^dirty_tree=' || fail "metadata missing dirty_tree"
|
||||
printf '%s\n' "$meta" | grep -q '^build_profile=production$' || fail "metadata missing build_profile=production"
|
||||
printf '%s\n' "$meta" | grep -q '^license=AGPL-3.0-only$' || fail "metadata missing license=AGPL-3.0-only"
|
||||
grep -q '^source_git_commit=' <<<"$meta" || fail "metadata missing source_git_commit"
|
||||
grep -q '^dirty_tree=' <<<"$meta" || fail "metadata missing dirty_tree"
|
||||
grep -q '^build_profile=production$' <<<"$meta" || fail "metadata missing build_profile=production"
|
||||
grep -q '^license=AGPL-3.0-only$' <<<"$meta" || fail "metadata missing license=AGPL-3.0-only"
|
||||
|
||||
# Поколение продукта обязано доехать до пакета: install-state строится из
|
||||
# него, а reconfigure/repair по нему отличают v1 от чужой установки.
|
||||
printf '%s\n' "$meta" | grep -q "^version=${HY2XS_VERSION}$" \
|
||||
grep -q "^version=${HY2XS_VERSION}$" <<<"$meta" \
|
||||
|| fail "metadata version disagrees with versions.env HY2XS_VERSION=${HY2XS_VERSION}"
|
||||
printf '%s\n' "$meta" | grep -q "^release_line=${HY2XS_RELEASE_LINE}$" \
|
||||
grep -q "^release_line=${HY2XS_RELEASE_LINE}$" <<<"$meta" \
|
||||
|| fail "metadata release_line disagrees with versions.env HY2XS_RELEASE_LINE=${HY2XS_RELEASE_LINE}"
|
||||
printf '%s\n' "$meta" | grep -q "^config_schema_version=${HY2XS_CONFIG_SCHEMA_VERSION}$" \
|
||||
grep -q "^config_schema_version=${HY2XS_CONFIG_SCHEMA_VERSION}$" <<<"$meta" \
|
||||
|| fail "metadata config_schema_version disagrees with versions.env"
|
||||
printf '%s\n' "$meta" | grep -q "^target_version=${HY2XS_TARGET_OS_VERSION}$" \
|
||||
grep -q "^target_version=${HY2XS_TARGET_OS_VERSION}$" <<<"$meta" \
|
||||
|| fail "metadata target_version disagrees with versions.env"
|
||||
printf '%s\n' "$meta" | grep -q "^target_arch=${HY2XS_TARGET_ARCH}$" \
|
||||
grep -q "^target_arch=${HY2XS_TARGET_ARCH}$" <<<"$meta" \
|
||||
|| fail "metadata target_arch disagrees with versions.env"
|
||||
|
||||
local packaged_schema
|
||||
|
||||
Reference in New Issue
Block a user