GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: CI セキュリティスキャン 3 件追加 (#205) by ymnao · Pull Request #218 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Jun 22, 2026

Copy link
Copy Markdown
Owner

概要

CI セキュリティスキャンを 3 件追加し、Dependabot 単独運用が拾わない層を塞ぐ。アプリコードは変更せず workflow ファイルのみ。レビュー指摘 6 件 (P1×1 / P2×5) を全件反映済み。

関連 Issue

closes #205

移行 Stage

該当なし(CI/CD 側の補強)。

変更内容

追加された workflow (3 件)

  • CodeQL (.github/workflows/codeql.yml 新規) — JS/TS 静的解析。push to main / PR / weekly schedule (日曜 05:30 UTC)。build-mode: none、paths-ignore で markdown / docs / ISSUE_TEMPLATE を除外、security-events: write + actions: read 権限を job ローカルに付与
  • dependency-review-action (.github/workflows/ci.yml に job 追加) — PR diff で新規追加される依存に既知 advisory が無いか gate。fail-on-severity: high、PR trigger 限定 (if: github.event_name == 'pull_request')
  • pnpm audit 定期実行 (.github/workflows/audit.yml 新規) — weekly schedule (月曜 06:30 UTC) + workflow_dispatch。pnpm audit --audit-level=high --json 検出時のみ issue 自動作成、既存 open issue があれば gh issue comment で append (body 上書き回避)

設計判断

  • action SHA pin: codeql-action v4.36.2 / dependency-review-action v5.0.0 / create-issue-from-file v6.0.0 を SHA pin、タグは comment 併記
  • cron 時間分散: CodeQL = 日曜 05:30 UTC、audit = 月曜 06:30 UTC。GitHub の cron ±15min ジッタを考慮して :30 を選定
  • CodeQL concurrency: group を ${{ github.event_name == 'schedule' && 'scheduled' || github.ref }} で trigger 別に分離。schedule run が push に巻き込まれて中断されるのを防ぐ
  • audit の exit code 厳密判定: jq -e . で JSON 妥当性検証、case で 0=no_advisory / 1=advisory / *=fail に分岐。registry/network エラーで誤って issue 作成されない
  • audit の credential leak 防御: actions/checkout に persist-credentials: false。後段 pnpm install の postinstall scripts から issues: write token を盗まれないようにする
  • security-audit label 冪等作成: gh label create --force で workflow 内で label を保証。未存在 label への addLabels は 422 で fail することへの対策
  • 既存 issue は append: peter-evans/create-issue-from-file の issue-number は body を上書きするため、既存 open issue があれば gh issue comment --body-file で append、無い場合のみ新規作成

採用見送り (issue 記載通り)

  • Snyk / Trivy = external secrets ゼロ方針と不整合
  • SBOM 生成 = v1.0.0 (release: v1.0.0 リリース実施(昇格条件 6 項目すべて pass を確認) #34) のリリース成果物 transparency で扱う

動作確認

ローカル検証 (全 pass)

  • node_modules/.bin/biome check . — 既存 info 2 件のみ (本 PR 無関係)
  • node_modules/.bin/tsc --noEmit — clean
  • node_modules/.bin/vitest run — 2163 passed / 2 skipped
  • actionlint -no-color — 全 workflow clean
  • js-yaml parse — 全 OK
  • heredoc 展開を実 bash で実証 ($(date) / $(cat ...) / ``` escape)
  • audit ロジックのシナリオテスト 5 件 — valid+0 / valid+1 / valid+5 / invalid+1 / empty+0 すべて期待通り
  • 実機 pnpm audit --json (v11.6.0) で出力形式 {"advisories":{},"metadata":{...}} を確認

CI / merge gate 確認 (PR 作成後)

  • CodeQL workflow が PR check で green になる (baseline scan で alert 0 件)
  • dependency-review job が PR check で green になる (本 PR は依存変更なしで no-op pass)
  • pnpm audit workflow を workflow_dispatch で手動実行して advisory 0 の no-op を確認 (merge 後)

Branch protection 必須化 (merge 前に実施)

現状の必須 checks は [lint, typecheck, test, build, e2e, electron-e2e] のみで、dependency-review / CodeQL が gate になっていない。本 PR で CI が走って status check が登録された後、branch protection の必須 checks に追加する。

  • PR の CI が走り、dependency-review / Analyze (javascript-typescript) が status check として GitHub に登録されたことを確認
  • 必須 checks を更新:
gh api repos/ymnao/scripta/branches/main/protection/required_status_checks \
  --method PATCH \
  -F strict=true \
  -f 'contexts[]=lint' \
  -f 'contexts[]=typecheck' \
  -f 'contexts[]=test' \
  -f 'contexts[]=build' \
  -f 'contexts[]=e2e' \
  -f 'contexts[]=electron-e2e' \
  -f 'contexts[]=dependency-review' \
  -f 'contexts[]=Analyze (javascript-typescript)'
  • 更新後 gh api repos/ymnao/scripta/branches/main/protection/required_status_checks --jq '.contexts' で 8 件になったことを確認
  • その後 PR を merge

レビュー対応履歴

ラウンド コミット 内容
/simplify b057191 paths-ignore 追加 / concurrency cancel 動的化 (後で更に改善)
review 1 (3 件) 5a6713c CodeQL concurrency group key 分離 / audit issue 上書き回避 (gh issue comment へ切替) / pnpm audit exit code 厳密判定
review 2 (3 件) 094ec71 security-audit label 冪等作成 / checkout persist-credentials: false / dependency-review 必須化は本 PR description で手順明示

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ymnao added 4 commits June 22, 2026 03:15
@ymnao
chore: CI セキュリティスキャン 3 件追加 (#205)
1412db9
- CodeQL workflow 新規 (.github/workflows/codeql.yml) — JS/TS 静的解析、
  push/PR/weekly schedule、build-mode: none、SHA pin
- dependency-review-action を ci.yml に job 追加 — PR diff の新規依存に
  既知 advisory が無いか gate、fail-on-severity: high、PR 限定
- pnpm audit weekly 新規 (.github/workflows/audit.yml) — 検出時のみ
  peter-evans/create-issue-from-file で issue 作成、同 label の open issue が
  あれば issue-number 渡してコメント追加で idempotent

全 action は SHA pin (codeql v4.36.2 / dep-review v5.0.0 / create-issue
v6.0.0)。cron は日曜 05:30 UTC (codeql) と月曜 06:30 UTC (audit) で
曜日・時間分散。

closes #205
@ymnao
refactor: /simplify 指摘 2 件対応 (CodeQL workflow)
b057191
- paths-ignore で markdown / docs / ISSUE_TEMPLATE の no-op push を scan 対象外に
  (schedule trigger には paths-ignore が適用されないので main baseline は保持)
- concurrency.cancel-in-progress を `${{ github.event_name != 'schedule' }}` で
  動的化。schedule run の SARIF upload が PR push に巻き込まれて中断されるのを
  防ぐ (audit.yml の cancel-in-progress: false と同方針に揃える)

/simplify の他指摘 2 件はいずれも skip:
- peter-evans/create-issue-from-file v6 の native search-existing オプション →
  v6 action.yml に該当 input は存在せず (agent の hallucination、false positive)
- audit job が pnpm install --frozen-lockfile を full 実行する非効率 →
  composite action 改修は他 job への副作用があり scope creep。別 PR で対応
@ymnao
fix: レビュー指摘 3 件対応 (concurrency / 上書き回避 / exit code)
5a6713c
P2-1: CodeQL の定期実行が main への push でキャンセルされる
  concurrency.cancel-in-progress を schedule では false に動的化していたが、
  GitHub Actions の cancel-in-progress は **後発 job 側** の設定が effective なので、
  schedule 走行中に push が来ると後発 push の cancel-in-progress: true で
  先発 schedule がキャンセルされる。group key 自体を分離する必要がある。
  → group を `codeql-${{ github.event_name == 'schedule' && 'scheduled' || github.ref }}`
    に変更し、schedule run を別 group へ隔離 (cancel-in-progress: true へ戻す)

P2-2: 既存監査 Issue にコメント追加されず本文が上書きされる
  peter-evans/create-issue-from-file の issue-number は src/main.ts:46-52 で
  octokit.issues.update を呼んでおり、body を完全上書きする (= 過去の検出履歴と
  対応記録が失われる)。
  → 既存 issue がある場合は gh issue comment で append、無い場合のみ
    create-issue-from-file で新規作成、と step を 2 つに分割。
    create step は if: ... && issue_number == ''
    comment step は if: ... && issue_number != ''

P2-3: pnpm audit の全エラーを advisory と判定する
  「非 0 = advisory あり」と単純化していたため、registry / network エラーで
  非 0 exit になった場合も has_advisories=true となり、空 / 不正な内容の issue が
  作成されていた。
  → jq で JSON 妥当性を検証 → invalid なら job fail
    exit code を case で 0/1/* に厳密分岐 → 0=no_advisory、1=advisory、
    それ以外 (registry/network error 想定) は job fail
  pnpm v11.6.0 で `pnpm audit --json` の出力形式 (`{"advisories":{},"metadata":{...}}`)
  を実機確認、jq -e . が truthy 判定で通ることを確認済み。
@ymnao
fix: レビュー指摘 2 件対応 (label 冪等化 / credential leak 防御)
094ec71
P1-1: security-audit ラベルが存在せず Issue 重複生成される
  peter-evans/create-issue-from-file は「issue create → addLabels」順で API を
  叩くが、未存在ラベルへの addLabels は GitHub REST API 仕様で 422 を返し
  action 全体が fail する。issue 作成済み・label 未付与の状態となり、次回 run の
  find_issue が見落として重複 issue が量産される。
  → workflow 内で `gh label create security-audit --force` を冪等に実行する step を
    追加 (--force で既存なら update、無ければ create)

P2-2: issues: write トークンが依存パッケージの postinstall から悪用可能
  actions/checkout はデフォルトで `.git/config` に GITHUB_TOKEN を保存
  (persist-credentials: true)。後段 setup-node-pnpm の pnpm install 実行時に
  侵害パッケージの postinstall script が token を読み取り、issue API を叩いて
  改ざん・spam に悪用され得る。本 job は issues: write を持つため悪用範囲が大きい。
  → audit.yml の checkout に `with: persist-credentials: false` を追加。
    gh CLI を使う step は env.GH_TOKEN で明示的に渡しているため影響なし。
  ※ codeql.yml と ci.yml の dependency-review は setup-node-pnpm を使わず
    postinstall scripts を実行しないので本対応の範囲外。

P2-1: dependency-review がマージゲートになっていない、は別途対応
  branch protection の必須 checks は [lint, typecheck, test, build, e2e,
  electron-e2e] で dependency-review / codeql が含まれない。本 PR では workflow
  を整え、merge 後に手動で branch protection を更新する想定 (gh api で PATCH)。
  PR description に手順を明記する。
@github-advanced-security

github-advanced-security AI commented Jun 22, 2026

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao merged commit e67440e into main Jun 22, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao deleted the chore/ci-security-scan branch June 22, 2026 16:24
@ymnao ymnao mentioned this pull request Jun 24, 2026
chore: v0.5.0 リリース準備 #224
Merged
2 of 3 tasks
ymnao added a commit that referenced this pull request Jun 24, 2026
@ymnao
chore: v0.5.0 リリース準備 (#224)
6126d37
- `CHANGELOG.md` に v0.5.0 セクションを追加
  - Added: #202 → #221 (バックリンクパネル)
  - Fixed: #220 → #222 (タブ切替 undo 履歴消失)
  - Security: #204 → #210 (Electron Tier 1 補完), #205 → #218 (CI スキャン 3 件),
    #223 (codeql-skip stub), #201 (undici 9 件)
  - Internal: #203 → #223 (ADR-0010 MiniSearch Rejected)
  - Dependencies: #199 + #211-#217 → #219 (Dependabot 8 件集約)
- `package.json` の `version` を `0.4.0` → `0.5.0`
- HANDOFF の規約通り、本 commit では `pnpm <script>` を呼ばない
  (lockfile / node_modules には触れない)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

chore: CI セキュリティスキャン追加 (CodeQL / dependency-review / pnpm audit)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ymnao @github-advanced-security
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.