feat: golangci-lint v2 設定ファイルを追加(unused / revive / gosec を有効化)#276
feat: golangci-lint v2 設定ファイルを追加(unused / revive / gosec を有効化)#276taminororo wants to merge 2 commits into
Conversation
- 既存の placeholder 設定を v2 schema に置き換え - gosec で SSRF / 弱暗号 / エラー無視等を検出(G104 はノイズ抑制のため除外) - gosec G201/G202 は SeeFT の変数経由 SQL 連結パターンを検出しない gosec の既知の限界あり、SQL injection 防止は AGENTS.md + CodeRabbit に依存 - CI 化は別 issue で対応予定 refs #274
📝 WalkthroughWalkthrough
ChangesLinter 設定更新
マニュアル・スライドパイプライン Q&A(新規追加)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
コマンド実行したら4つしか違反が検出されなかったけど大丈夫そうかな? |
|
0c41c75 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
docs/proposals/manual-slide-pipeline-qa.md (1)
208-209: ⚡ Quick winOAuthトークン埋め込みを選択肢として残さないでください。
Line 208 は「トークン埋め込み」を許容する読まれ方になるため、秘密情報管理の観点で危険です。
埋め込み禁止(Secret Manager / CI Secrets / OS keychain を使用)を明記しておくのがよいです。修正例
-- [ ] 認証の持ち方(PM 個人サブスク → スクリプトに OAuth トークン埋め込み?) +- [ ] 認証の持ち方(トークンのコード埋め込みは禁止。Secret Manager / CI Secrets / OS keychain のいずれかで管理)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/proposals/manual-slide-pipeline-qa.md` around lines 208 - 209, 行の「認証の持ち方(PM 個人サブスク → スクリプトに OAuth トークン埋め込み?)」という文がトークン埋め込みを許容して読めるため、該当箇所を編集して「埋め込み禁止」を明記し、代替として Secret Manager / CI Secrets / OS keychain などの安全な秘密管理手段を必ず使うよう指示するように修正してください(該当テキストを「埋め込み禁止(Secret Manager / CI Secrets / OS keychain を使用)」のように置き換える)。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/proposals/manual-slide-pipeline-qa.md`:
- Around line 39-55: The fenced code block in
docs/proposals/manual-slide-pipeline-qa.md (the block starting with ```) is
missing a language spec causing markdownlint MD040; fix it by adding a language
identifier (e.g., text) after the opening backticks so the block becomes ```text
— update the single fenced block that contains the flow diagram to include the
language spec and save the file.
- Around line 247-253: Replace the policy section titled "**メインバックエンド: 上林の
Claude Max プランを新 PM と共用**" (the bullets currently suggesting sharing an
individual Claude Max account) with a non-sharing policy: remove any instruction
that a new PM should log into 上林’s personal account and explicitly state that
personal account sharing is prohibited per Anthropic Consumer Terms of Service;
instead prescribe organization-managed authentication (e.g., organization API
keys, service accounts, or provisioned org credentials) as the default, keep the
note to re-evaluate post-Vietnam but only with an org-managed migration option,
and update the bullets and any examples to reference the new auth methods rather
than `claude login` into a personal account.
---
Nitpick comments:
In `@docs/proposals/manual-slide-pipeline-qa.md`:
- Around line 208-209: 行の「認証の持ち方(PM 個人サブスク → スクリプトに OAuth
トークン埋め込み?)」という文がトークン埋め込みを許容して読めるため、該当箇所を編集して「埋め込み禁止」を明記し、代替として Secret Manager /
CI Secrets / OS keychain
などの安全な秘密管理手段を必ず使うよう指示するように修正してください(該当テキストを「埋め込み禁止(Secret Manager / CI Secrets /
OS keychain を使用)」のように置き換える)。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 59c3d8e8-ea8b-412d-9e45-e23ede96c8de
📒 Files selected for processing (1)
docs/proposals/manual-slide-pipeline-qa.md
| ``` | ||
| [マニュアル作成者] | ||
| ↓ Google Doc 編集 | ||
| ↓ 完了 or 更新したら PM に通知 | ||
|
|
||
| [PM(上林、引き継ぎ後は新PM)] | ||
| ↓ Doc を HTML エクスポート(Google Docs の「ダウンロード → Web ページ」) | ||
| ↓ ローカルで生成ツール実行(コマンド1回、3〜6 分) | ||
| ↓ 生成された Web ページを SeeFT の配信先にデプロイ | ||
| ↓ SeeFT シフトページのリンクを更新(Doc URL → Web ページ URL) | ||
|
|
||
| [マニュアル確認担当者] | ||
| ↓ 元 Doc と生成 Web ページを照合 | ||
| ↓ OK → 完了 / NG → PM に修正依頼 | ||
|
|
||
| [技大祭当日も同じフロー: Doc 変更 → PM 再生成 → URL は同じまま中身だけ更新] | ||
| ``` |
There was a problem hiding this comment.
コードフェンスに言語指定を追加してください(MD040)。
Line 39 の fenced code block に言語が未指定です。markdownlint 警告の解消のため、text などを明示してください。
修正例
-```
+```text
[マニュアル作成者]
↓ Google Doc 編集
↓ 完了 or 更新したら PM に通知
...
[技大祭当日も同じフロー: Doc 変更 → PM 再生成 → URL は同じまま中身だけ更新]
-```
+```📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ``` | |
| [マニュアル作成者] | |
| ↓ Google Doc 編集 | |
| ↓ 完了 or 更新したら PM に通知 | |
| [PM(上林、引き継ぎ後は新PM)] | |
| ↓ Doc を HTML エクスポート(Google Docs の「ダウンロード → Web ページ」) | |
| ↓ ローカルで生成ツール実行(コマンド1回、3〜6 分) | |
| ↓ 生成された Web ページを SeeFT の配信先にデプロイ | |
| ↓ SeeFT シフトページのリンクを更新(Doc URL → Web ページ URL) | |
| [マニュアル確認担当者] | |
| ↓ 元 Doc と生成 Web ページを照合 | |
| ↓ OK → 完了 / NG → PM に修正依頼 | |
| [技大祭当日も同じフロー: Doc 変更 → PM 再生成 → URL は同じまま中身だけ更新] | |
| ``` |
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 39-39: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/proposals/manual-slide-pipeline-qa.md` around lines 39 - 55, The fenced
code block in docs/proposals/manual-slide-pipeline-qa.md (the block starting
with ```) is missing a language spec causing markdownlint MD040; fix it by
adding a language identifier (e.g., text) after the opening backticks so the
block becomes ```text — update the single fenced block that contains the flow
diagram to include the language spec and save the file.
| **メインバックエンド: 上林の Claude Max プランを新 PM と共用** | ||
|
|
||
| - 上林の既存 Max プラン契約の容量を新 PM が利用する | ||
| - 追加コストゼロ(既に上林が支払い中) | ||
| - 新 PM の Mac に 1 度だけ `claude login` → OAuth トークンが保存される → 以降は新 PM が普通にコマンドを叩くだけ | ||
| - ベトナム滞在中の上林はほぼ Claude を使わない → 実質単一ユーザーパターンになり、TOS リスクは実用上ほぼゼロ | ||
| - ベトナム終了後(10月以降)に方針を再決定(新 PM 個人契約に移行 or 共用継続) |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Anthropic Claude Max の最新利用規約で、個人アカウントの共有利用(別ユーザーが別端末で使用)は許可されていますか?公式ToS/Usage Policyの該当条項を提示してください。
💡 Result:
いいえ、Anthropic Claude Maxの最新利用規約(Consumer Terms of Service)では、個人アカウントの共有利用(別ユーザーが別端末で使用)は許可されていません。[1][2]
Citations:
個人アカウント共用は Claude Max の利用規約で明確に禁止されています。
Line 247-253 の方針は Anthropic の公式利用規約(Consumer Terms of Service)に違反します。同規約では、別ユーザーが別端末で個人アカウントを使用することは許可されていません。
上林の既存 Max プラン契約を新 PM と共用する運用は、利用規約違反および責任分界の不明確化につながるため、運用ドキュメント上は「個人契約の共用を前提にしない」方針へ修正が必須です。組織管理可能な認証方式(組織 API キー・サービス用認証)を主系に置くことで、規約リスクと監査トレーサビリティを同時に解決できます。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/proposals/manual-slide-pipeline-qa.md` around lines 247 - 253, Replace
the policy section titled "**メインバックエンド: 上林の Claude Max プランを新 PM と共用**" (the
bullets currently suggesting sharing an individual Claude Max account) with a
non-sharing policy: remove any instruction that a new PM should log into 上林’s
personal account and explicitly state that personal account sharing is
prohibited per Anthropic Consumer Terms of Service; instead prescribe
organization-managed authentication (e.g., organization API keys, service
accounts, or provisioned org credentials) as the default, keep the note to
re-evaluate post-Vietnam but only with an org-managed migration option, and
update the bullets and any examples to reference the new auth methods rather
than `claude login` into a personal account.
91c0df9 to
c7375a4
Compare
対応Issue
resolve #274
概要
.golangci.ymlを golangci-lint v2 の schema で書き直し、unused/revive/gosecを有効化しました。CI 化は別 issue で対応します。なぜ
.golangci.ymlは placeholder(issues.exclude-use-default: falseのみ)で実質未設定だった設定内容
設計判断:
default: none+ 明示enablerevive.severity: warninggosec:(空設定)run.timeout: 5mFinanSu の
.golangci.ymlを起点に、SeeFT 用に gosec を追加。ローカル実行結果(v2.11.4 / 2026-05-02)
検出された違反 7 件:
api/lib/externals/db/db.goc.db.Close()のエラー未処理api/lib/externals/server/server.goe.Start(":1234")のエラー未処理api/lib/usecase/mail_auth_usecase.gosessionRep.DeleteByUserID(...)のエラー未処理api/lib/usecase/rescue_unified_usecase.goapi/lib/usecase/rescue_unified_usecase.goapi/lib/usecase/user_usecase.goburearRepis unusedapi/lib/usecase/user_usecase.gotaskRepis unused→ いずれも 本 PR のスコープ外。個別 PR で対応。
補足: gosec の SQL injection 検出限界(実験で確定)
gosecの G201/G202(SQL 文字列連結)は*sql.DB型の識別子を介していない呼び出しを SQL 実行関数として認識できない。db.QueryContext(ctx, "..."+id))q := "..."+id; db.QueryContext(ctx, q))q := "..."+id; crud.UpdateDB(ctx, q))b.client.DB().QueryRowContext(ctx, q))db := b.client.DB(); db.QueryRowContext(ctx, q))SeeFT の repository 層は ラッパー関数経由(
b.crud.UpdateDB(c, query)等) および メソッドチェーン直結(b.client.DB().QueryRowContext(...)) の両パターンを使用しているため、grep で確認した SQL 文字列連結 41 件は gosec では 0 件報告。→ SQL injection 防止策は AGENTS.md (#269) のプレースホルダ規約 + CodeRabbit (#273) + 人間レビュー に依存する方針。gosec は SSRF・弱暗号などの補完的検出として活用。
画面スクリーンショット等
設定ファイル追加のため画面なし。
テスト項目
.golangci.ymlがリポジトリルートに配置されているcd api && golangci-lint run --config=../.golangci.yml ./...で上記 7 件が検出されるgolangci-lint config verify --config=.golangci.ymlで設定が validate される備考
本 PR のスコープ外(別タスク)
rescue_unified_usecase.go)user_usecase.go)参考
.golangci.ymlおよび.github/workflows/golangci-lint.ymlSummary by CodeRabbit
リリースノート
Chores
Documentation