原文(日本語訳)
Bash(*) のような権限ルールを受け入れ、Bash と同等として扱うように変更しました
原文(英語)
Changed permission rules like Bash(*) to be accepted and treated as equivalent to Bash
概要
権限ルールの記法が統一され、Bash(*) というワイルドカード付きの記法も Bash と同じ意味として認識されるようになりました。これにより、直感的な記法で権限設定ができます。
基本的な使い方
以下の記法はすべて同じ意味として扱われます:
json
{
"permissions": {
"allow": [
"Bash",
"Bash(*)",
"Bash(*:*)"
]
}
}実践例
基本的な権限設定
すべての Bash コマンドを許可:
json
{
"permissions": {
"allow": [
"Bash(*)"
]
}
}これは以下と同じ:
json
{
"permissions": {
"allow": [
"Bash"
]
}
}特定のコマンドパターンの許可
npm コマンドのすべてのサブコマンドを許可:
json
{
"permissions": {
"allow": [
"Bash(npm *)"
]
}
}これにより、npm install, npm test, npm run build などすべてが許可されます。
ワイルドカードの位置
ワイルドカードは任意の位置に配置できます:
json
{
"permissions": {
"allow": [
"Bash(* --help)", // すべてのコマンドの --help
"Bash(git * main)", // git の main ブランチに関するすべての操作
"Bash(npm run test:*)" // test: で始まるすべての npm スクリプト
]
}
}空白の重要性
空白の有無で意味が変わります:
json
{
"permissions": {
"allow": [
"Bash(ls *)", // ls コマンドとその引数(例: ls -la)
"Bash(ls*)" // ls で始まるすべてのコマンド(例: ls, lsof, lsblk)
]
}
}注意点
- 記法の統一:
Bash(*)は単にBashと書くことを推奨しますが、どちらも有効です - ワイルドカードの柔軟性: パターンマッチングにより、細かい権限制御が可能です
- 空白の扱い:
*の前後の空白で意味が変わるため注意してください - セキュリティ: ワイルドカードを使う場合、意図した範囲のみが許可されることを確認してください
推奨される設定例
開発環境の標準設定
json
{
"permissions": {
"allow": [
"Bash(npm *)",
"Bash(git *)",
"Bash(node *)",
"Bash(npx *)",
"Read",
"Write"
]
}
}CI/CD パイプライン用設定
json
{
"permissions": {
"allow": [
"Bash(npm ci)",
"Bash(npm test)",
"Bash(npm run build)",
"Read",
"Write(dist/**)",
"Write(coverage/**)"
]
}
}セキュアな設定(明示的な許可のみ)
json
{
"permissions": {
"allow": [
"Bash(npm install --dry-run)",
"Bash(npm run lint)",
"Bash(npm run type-check)",
"Read"
],
"deny": [
"Bash(rm *)",
"Bash(sudo *)",
"Write(/etc/**)"
]
}
}