Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:35:44 +08:00
commit 621a26d0bd
5 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"name": "security",
"description": "セキュリティとワークフロー制御のためのフック集(ファイル編集制限、通知)",
"version": "1.0.0",
"author": {
"name": "korosuke613",
"url": "https://github.com/korosuke613"
},
"hooks": [
"./hooks"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# security
セキュリティとワークフロー制御のためのフック集(ファイル編集制限、通知)

37
hooks/block-file-edits.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# 特定ファイルの編集を禁止する制限フック
# CI 環境変数が true でない場合は GitHub Actionsの実行ではないため、スクリプトを終了
if [[ "$CI" != "true" ]]; then
exit 0
fi
# 標準入力からJSONデータを読み取り
input=$(cat)
# jqを使ってfile_pathを抽出jqが利用できない場合の代替手段も含む
if command -v jq >/dev/null 2>&1; then
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
else
# jqが利用できない場合のpython代替
file_path=$(echo "$input" | python3 -c "import json, sys; data=json.load(sys.stdin); print(data.get('tool_input', {}).get('file_path', ''))")
fi
# .github/workflows ディレクトリ以下のファイル編集はブロック
if [[ "$file_path" == *".github/workflows"* ]]; then
echo "❌ エラー: .github/workflows ディレクトリ以下のファイルは編集できません。"
echo "GitHub Actionsワークフローファイルを変更したコミットを push するには workflow:write 権限が必要ですが、あなたはその権限を持っていません。"
echo "ユーザーにはワークフローの変更差分をテキストで提示するようにしてください。"
exit 2 # 操作をブロックするために非ゼロで終了
fi
# .claude/hooks および .claude/settings.json の編集はブロック
if [[ "$file_path" == *".claude/hooks"* ]] || [[ "$file_path" == *".claude/settings.json"* ]]; then
echo "❌ エラー: .claude/hooks または .claude/settings.json ディレクトリ以下のファイルは編集できません。"
echo "ユーザーには変更差分をテキストで提示するようにしてください。"
exit 2 # 操作をブロックするために非ゼロで終了
fi
# その他のファイルは編集を許可
exit 0

16
hooks/hooks.json Normal file
View File

@@ -0,0 +1,16 @@
{
"description": "ClaudeCodeの行動を制限するセキュリティフック集",
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/block-file-edits.sh"
}
]
}
]
}
}

49
plugin.lock.json Normal file
View File

@@ -0,0 +1,49 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:korosuke613/coding-agent-recipe:claude-plugins/security",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "e1aaf6010f78ad6de52f80dca0f936ceaa1bf92a",
"treeHash": "a5fc8e8607cccbca8696b7809ca3d86da4b2be6e5134f87ed0ad9fad81ef02f7",
"generatedAt": "2025-11-28T10:19:57.003584Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "security",
"description": "セキュリティとワークフロー制御のためのフック集(ファイル編集制限、通知)",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "49cb118d06612a6dc35e1ba0d2f07f4376c5b0cd0244a855353b5f0218e67b16"
},
{
"path": "hooks/block-file-edits.sh",
"sha256": "f2e1e0fd61376148c871d5f15b7a16b9c32035d47d911377d3a22de535b9de13"
},
{
"path": "hooks/hooks.json",
"sha256": "e32c931241a22904881ce0633e68aaa3a6fdaa043e5ac0caead3934871431739"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "42a77f8e2dd971e9ae5e74abc4f5315668b95be5b3df7d738e047410449c88e4"
}
],
"dirSha256": "a5fc8e8607cccbca8696b7809ca3d86da4b2be6e5134f87ed0ad9fad81ef02f7"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}