Skip to content

feat(release): package hardened services and scan pinned images - #175

Merged
TN019 merged 9 commits into
mainfrom
feat/release-packaging
Dec 1, 2026
Merged

TN019 merged 9 commits into
mainfrom
feat/release-packaging

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Why

There was no installable form of the services: nothing packaged the binaries, the configuration or a service user, and the only unit file was the lab's lab/systemd/gated.service. A release also needs its build and lab images checked for known vulnerabilities.

What changed

  • CMake install() rules and CPack produce two Debian packages, gatepost-gated and gatepost-gate-hub. Each carries its binary, a launcher in /usr/lib/gatepost, a systemd unit, and example configuration under /etc/gatepost marked as conffiles.
  • packaging/postinst creates the gatepost system user and group, /var/lib/gatepost, a root-only /etc/gatepost/credentials and a group-readable /etc/gatepost/mac-keys, then runs systemctl daemon-reload. It does not enable or start a service.
  • Both units run as gatepost with NoNewPrivileges, ProtectSystem=strict, ProtectHome, PrivateTmp, kernel and cgroup protections and StateDirectory=gatepost, and receive their TLS files through LoadCredential=. gated.service is Type=notify with WatchdogSec=10 and only CAP_NET_RAW.
  • packaging/run-gated.sh and packaging/run-gate-hub.sh map the credential directory to the GATEPOST_TLS_* variables and start the daemons from the environment file; run-gated refuses to start without GATEPOST_HUB.
  • .github/workflows/release.yml, on v* tags or manual dispatch: build and test the release preset, build the packages, generate an SPDX SBOM with Syft 1.55.0, and fail on HIGH or CRITICAL vulnerabilities with an available fix in the build and lab images, found by Trivy 0.71.1. Actions and scanner images are pinned by digest.
  • The build image moves to a newer Debian snapshot, and the lab's Mailpit image is pinned by digest.
  • New docs/operations/packages.md and docs/operations/logging.md with Chinese versions, linked from both READMEs.

How to verify

Requires Docker. From the repository root:

./scripts/dev.sh build-image
./scripts/dev.sh test release
docker run --rm -v "$PWD:/src" -w /src gatepost-build:current sh -c \
  'cmake --install build/release --prefix /tmp/gatepost-stage &&
   cpack --config build/release/CPackConfig.cmake -G DEB -B build/packages &&
   for p in build/packages/*.deb; do dpkg-deb -I "$p"; dpkg-deb -c "$p"; done'

Check the two package names, their dependencies, the unit files, launchers and conffiles. On a systemd target, run systemd-analyze verify on the installed units as the packages page describes. The package version still comes from project(), which is 0.3.0 here.


背景

之前服务没有可安装的形式:没有东西把程序、配置和服务用户打包,唯一的服务单元是实验环境里的 lab/systemd/gated.service。发布还需要检查构建镜像和实验镜像有没有已知漏洞。

改动

  • 用 CMake 的 install() 规则和 CPack 生成两个 Debian 软件包:gatepost-gated 和 gatepost-gate-hub。每个包含程序本身、/usr/lib/gatepost 下的启动脚本、systemd 服务单元,以及 /etc/gatepost 下标记为 conffile 的示例配置。
  • packaging/postinst 创建 gatepost 系统用户和组、/var/lib/gatepost、只有 root 能访问的 /etc/gatepost/credentials 和组可读的 /etc/gatepost/mac-keys,然后执行 systemctl daemon-reload。它不会启用或启动服务。
  • 两个服务单元都以 gatepost 身份运行,设置 NoNewPrivileges、ProtectSystem=strict、ProtectHome、PrivateTmp、内核与 cgroup 保护以及 StateDirectory=gatepost,TLS 文件通过 LoadCredential= 传入。gated.service 为 Type=notify,带 WatchdogSec=10,只保留 CAP_NET_RAW。
  • packaging/run-gated.sh 和 packaging/run-gate-hub.sh 把凭据目录映射到 GATEPOST_TLS_* 变量,按环境文件启动守护进程;没有 GATEPOST_HUB 时 run-gated 拒绝启动。
  • .github/workflows/release.yml 在推送 v* 标签或手动触发时运行:构建并测试 release preset,打包,用 Syft 1.55.0 生成 SPDX SBOM,并用 Trivy 0.71.1 扫描构建镜像和实验镜像,发现有修复版本的 HIGH 或 CRITICAL 漏洞即失败。各 action 和扫描工具镜像都按 digest 固定。
  • 构建镜像改用更新的 Debian 快照,实验环境的 Mailpit 镜像按 digest 固定。
  • 新增 docs/operations/packages.md、docs/operations/logging.md 及中文版,两个 README 都加了链接。

怎么验证

需要 Docker。在仓库根目录运行:

./scripts/dev.sh build-image
./scripts/dev.sh test release
docker run --rm -v "$PWD:/src" -w /src gatepost-build:current sh -c \
  'cmake --install build/release --prefix /tmp/gatepost-stage &&
   cpack --config build/release/CPackConfig.cmake -G DEB -B build/packages &&
   for p in build/packages/*.deb; do dpkg-deb -I "$p"; dpkg-deb -c "$p"; done'

核对两个包名、依赖、服务单元、启动脚本和 conffile。在使用 systemd 的目标机上,按软件包文档对安装好的服务单元运行 systemd-analyze verify。包的版本仍取自 project(),这里还是 0.3.0。

Noah Williams and others added 9 commits October 30, 2026 14:00
…LS status port

With the season list at about 3.5 MB, a north gate whose download is lost in a path-MTU black hole keeps the hub's single TLS status listener busy for about six seconds once per 20-second fetch cycle. Venue gates that ask during that time give up after 300 ms. The drill fails until 8444 serves more than one connection at a time.
… every gate

Port 8444 serves one connection at a time, so a client that asks for /tickets and stops reading makes every other gate wait seconds for /status. A connection beyond the work queue should be closed at once and counted.
…ist-version test

If the gate fetches the new list after the hub installs it and before the test reads the metrics, the assertion that the gate became stale does not hold. Pausing the gate while the hub changes its list removes that window.
Port 8444 served one connection at a time, so one client that stopped reading held /status and ticket fetches for every gate for seconds. It now hands accepted connections to a bounded queue of 16 served by four workers, closes and counts a connection when the queue is full, and keeps the 2 s step and 10 s connection deadlines. Port 8081 stays one thread for staff. The TLS slow-reader check in the status deadline test described the one-thread behaviour: status waited until the slow reader was cut; it now requires an answer within 1 s.
The hub now mails when the data centre is unreachable or the uplink watcher stops.
This review covers the north entrance ticket list failure, the lab reproductions, recovery work, and remaining limitations.
Clarify when extra tickets are needed to reproduce the sender hold.
This decision preserves path-MTU feedback and makes each gate's installed list visible. It also aligns the hub's served and decision lists and bounds the TLS status listener.

Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Ingrid Larsen · reviewer

Does installing the package start the gate service?


安装软件包会启动闸机服务吗?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Yuki Tanaka · author

No. postinst only creates the user and directories and runs daemon-reload. Enabling the unit is left until the credentials and the environment file are in place, as the packages page says.


不会。postinst 只创建用户和目录并执行 daemon-reload。要等凭据和环境文件都放好后再启用服务,软件包文档里也是这么写的。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Ingrid Larsen · reviewer

Trivy runs with --ignore-unfixed. What exactly blocks a release?


Trivy 带了 --ignore-unfixed,到底什么会挡住发布?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Yuki Tanaka · author

HIGH or CRITICAL vulnerabilities that have a fix available, in either the build or the lab image; --exit-code 1 fails the job. Findings without a fix are not reported by this step.


构建镜像或实验镜像里有修复版本的 HIGH 或 CRITICAL 漏洞;--exit-code 1 会让任务失败。没有修复版本的漏洞,这一步不会报出。

@TN019
TN019 merged commit e44073b into main Dec 1, 2026
5 checks passed
@TN019
TN019 deleted the feat/release-packaging branch December 1, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant