Skip to content

feat: structured logging の安全性を強化 - #60

Open
koh110 wants to merge 5 commits into
mainfrom
fix/structured-logging
Open

koh110 wants to merge 5 commits into
mainfrom
fix/structured-logging

Conversation

@koh110

@koh110 koh110 commented Sep 1, 2026 •

Copy link
Copy Markdown
Owner

概要

Issue #49 に対応し、structured logging における credential・PII・request payload の accidental leakage を防止します。

変更内容

  • logger の meta / redact() 引数を LogValue / LogMeta 型で制約
    • JSON-safe なプリミティブ、配列、object のみを許可
    • Headers / Request / Response / provider response の丸ごと渡しを型レベルで拒否
  • logger の sensitive field redaction を追加
  • Authorization / Cookie / token / credential 系フィールドを [REDACTED] 化
  • Error / external SDK error を name / message / stack / cause の限定 shape に変換
  • api の access log・application error log・authorization failure log で requestId を追跡
  • application code の console.* 利用を lint で制限
  • sensitive logging、request body/headers の丸ごと logging、object spread を検出する lint rule を追加
  • api / client / task に redaction・Error serialization・requestId の回帰テストと型レベル拒否テストを追加
  • logging の設計・運用ガイドを追加

検証結果

  • npm run test-lint-rules — PASS
  • npm run lint -w api — PASS(既存 local auth warning のみ)
  • npm run lint -w client — PASS(既存 local auth warning のみ)
  • npm run lint -w task — PASS
  • npm run tsc -w api — PASS
  • npm run tsc -w client — PASS
  • npm run tsc -w task — PASS
  • npm run typecheck-bin -w shared — PASS
  • npm run build -w shared — PASS
  • npm run build -w api — PASS
  • npm run build -w client — PASS
  • npm run build -w task — PASS
  • api tests — 26 passed
  • client tests — 21 passed
  • task tests — 17 passed
  • git diff --check — PASS
  • redaction を一時的に外す sabotage run で、代表 leakage test が失敗することを確認
  • @ts-expect-error による非 JSON-safe 値の型拒否を検証

Review

  • fable fresh-context review — PASS
  • fable closure review — PASS(追加変更前のレビュー)
  • 今回の型境界変更に対する fresh review — FAIL(テスト不足を指摘)
  • 指摘を修正し、型レベル拒否テストを追加済み
  • blocking / major finding — 解消済み

関連 Issue

Closes #49

未実施

  • 追加変更後の GitHub Actions 完了待ちは未実施です。
  • 初期化時の Docker 起動では既存 nginx 1.31 と Alpine モジュールのバージョン不整合が発生しましたが、対象 workspace のローカル build・lint・test は完了しています。

@koh110
koh110 force-pushed the fix/structured-logging branch from f27b1cf to a971f6f Compare September 24, 2026 07:30
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.

structured logging / sensitive data redaction を静的検査する

1 participant