Skip to content

ci(sim): check browser image and dependency security - #4

Merged
TN019 merged 8 commits into
mainfrom
ci/image-and-dependency-checks
Dec 1, 2026
Merged

TN019 merged 8 commits into
mainfrom
ci/image-and-dependency-checks

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

Pull requests should run the same checks contributors run locally, exercise the page in a real browser, and stop if the container image ships known high or critical vulnerabilities.

What changed

  • Add .github/workflows/ci.yml, triggered on pull_request only, with read-only contents permission, a 25-minute timeout and a concurrency group that cancels superseded runs.
  • The check job installs pnpm 10.20.0, sets up Node from .nvmrc with the pnpm cache, then runs pnpm install --frozen-lockfile, pnpm lint, pnpm typecheck, pnpm test and pnpm build.
  • It installs Chromium, starts the bridge on 28080/7600 with scripts/fake-gates.mjs, and runs e2e/entrance.spec.ts.
  • It builds gatepost-sim:ci, uploads an SPDX SBOM as gatepost-sim.spdx.json with anchore/sbom-action, and scans the image with aquasecurity/trivy-action, failing on CRITICAL,HIGH. Every action is pinned by commit SHA.
  • Add renovate.json (config:recommended, label dependencies).

How to verify

Open a pull request and check that the check job runs every step. Locally, the image steps can be reproduced with:

docker build -t gatepost-sim:ci .

背景

拉取请求应该跑贡献者在本地跑的同一套检查,在真实浏览器里验证页面,并且在容器镜像带有已知高危或严重漏洞时拦下来。

改动

  • 新增 .github/workflows/ci.yml:只在 pull_request 时触发,contents 权限只读,超时 25 分钟,并用并发组取消被新提交取代的运行。
  • check 任务安装 pnpm 10.20.0,按 .nvmrc 配置 Node 并启用 pnpm 缓存,然后依次运行 pnpm install --frozen-lockfile、pnpm lint、pnpm typecheck、pnpm test、pnpm build。
  • 安装 Chromium,在 28080/7600 上启动 bridge 和 scripts/fake-gates.mjs,运行 e2e/entrance.spec.ts。
  • 构建 gatepost-sim:ci 镜像,用 anchore/sbom-action 生成 SPDX 格式的 SBOM 并上传为 gatepost-sim.spdx.json,再用 aquasecurity/trivy-action 扫描镜像,发现 CRITICAL,HIGH 级别漏洞即失败。所有 action 都按提交 SHA 固定。
  • 新增 renovate.json(config:recommended,标签 dependencies)。

怎么验证

发起一个拉取请求,确认 check 任务的每一步都执行了。镜像相关步骤可在本地这样重现:

docker build -t gatepost-sim:ci .

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · reviewer

The browser step starts the bridge without WEB_ROOT or TICKET_FILE. Does the page load?


浏览器那一步启动 bridge 时没有设置 WEB_ROOT 和 TICKET_FILE,页面能正常加载吗?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · author

Yes. It runs from the repository root after pnpm build, so the default WEB_ROOT resolves to web/dist. Without a ticket file the ticket list is empty, and entrance.spec.ts types its barcode into the lane instead.


能。这一步在 pnpm build 之后、从仓库根目录运行,默认的 WEB_ROOT 正好解析到 web/dist。没有票据文件时票据列表为空,而 entrance.spec.ts 是直接在通道里输入条码的,不受影响。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Mateo Rossi · reviewer

Trivy fails on HIGH as well as CRITICAL. A base-image CVE will block unrelated pull requests.


Trivy 在 HIGH 级别也会失败。基础镜像出一个 CVE 就会挡住无关的拉取请求。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · author

That is intended. The base image is pinned by digest, and Renovate opens the update for it, so the fix lands in one pull request instead of being ignored everywhere.


这是有意的。基础镜像按摘要固定,由 Renovate 发起更新,修复会集中在一个拉取请求里完成,而不是在各处被忽略。

@TN019
TN019 merged commit cc8cdea into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the ci/image-and-dependency-checks branch December 1, 2026 00:13
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