メインコンテンツまでスキップ

audit rules

audit ルールを閲覧、有効化、無効化、カスタマイズします。

skillshare audit rules                          # インタラクティブ TUI ルールブラウザ
skillshare audit rules --no-tui # プレーンテキストのテーブル
skillshare audit rules --pattern credential-access # パターンでフィルタ
skillshare audit rules --severity high # 重大度でフィルタ
skillshare audit rules --disabled # 無効化されたルールのみ表示
skillshare audit rules --format json # JSON 出力

skillshare audit rules disable prompt-injection-0 # 単一ルールを無効化
skillshare audit rules disable --pattern credential-access # グループ全体を無効化
skillshare audit rules enable prompt-injection-0 # ルールを再有効化
skillshare audit rules enable --pattern credential-access # グループを再有効化

skillshare audit rules severity destructive-commands-2 medium # 単一ルールを引き下げ
skillshare audit rules severity --pattern destructive-commands low # グループ全体を引き下げ
skillshare audit rules reset # カスタムルールをすべて削除し、デフォルトに戻す

skillshare audit rules init # スターター用の audit-rules.yaml を作成
skillshare audit rules init -p # project レベルのルールファイルを作成

パターン単位のルール

audit-rules.yaml で、パターングループ全体を無効化またはオーバーライドできます。

rules:
# すべての credential-access ルールを無効化する
- pattern: credential-access
enabled: false

# ただし .env の検出は維持する
- id: credential-access-env-file
enabled: true

# すべての destructive-commands を MEDIUM に引き下げる
- pattern: destructive-commands
severity: MEDIUM

パターン単位のエントリは id なしで pattern を使用します。マージ順序: まずパターン単位のルールが適用され、その後 id 単位のルールが、無効化されたグループ内の個々のエントリを上書きできます。

カスタムルール

YAML ファイルを使って audit ルールを追加、オーバーライド、無効化できます。ルールは built-in → global user → project user の順にマージされます。

コメント付きの例を含むスターターファイルを作成するには --init-rules(または audit rules init)を使用します。

skillshare audit --init-rules         # グローバルなルールファイルを作成
skillshare audit -p --init-rules # project のルールファイルを作成

ファイルの場所

スコープパス
グローバル~/.config/skillshare/audit-rules.yaml
Project.skillshare/audit-rules.yaml

フォーマット

rules:
# 新しいルールを追加する
- id: my-custom-rule
severity: HIGH
pattern: custom-check
message: "Custom pattern detected"
regex: 'DANGEROUS_PATTERN'

# exclude 付きのルールを追加する(特定の行での一致を抑制する)
- id: url-check
severity: MEDIUM
pattern: url-usage
message: "External URL detected"
regex: 'https?://\S+'
exclude: 'https?://(localhost|127\.0\.0\.1)'

# 既存の built-in ルールをオーバーライドする(id で一致させる)
- id: destructive-commands-2
severity: MEDIUM
pattern: destructive-commands
message: "Sudo usage (downgraded to MEDIUM)"
regex: '(?i)\bsudo\s+'

# built-in ルールを無効化する
- id: insecure-http-0
enabled: false

# dangling-link 構造チェックを無効化する
- id: dangling-link
enabled: false

フィールド

フィールド必須説明
idはい安定した識別子。一致する ID は built-in ルールを上書きする。
severityはい*CRITICAL, HIGH, MEDIUM, LOW, または INFO
patternはい*ルールのカテゴリ名(例: prompt-injection
messageはい*findings に表示される人間可読な説明
regexはい*各行と照合する正規表現
excludeいいえ行が regexexclude の両方に一致した場合、finding は抑制される
enabledいいえfalse に設定するとルールを無効化する。無効化する場合は id のみが必要。

*enabled: false の場合を除き必須。

マージのセマンティクス

各レイヤー(global、次に project)は、前のレイヤーの上に適用されます。

  • 同じ id + enabled: false → ルールを無効化する
  • 同じ id + 他のフィールド → ルール全体を置き換える
  • 新しい id → カスタムルールとして追加する
  • pattern のみid なし)+ enabled: false → そのパターンに一致するすべてのルールを無効化する
  • pattern のみ + severity → 一致するすべてのルールの重大度を上書きする
  • パターンの後に id → id 単位のエントリは、無効化されたパターングループ内の個々のルールを再有効化できる

実用的なテンプレート

実際のポリシー調整のための出発点として、これを使用してください。

rules:
# 教育用/リファレンス用の Skill 向けに hardcoded-secret を MEDIUM に引き下げる
- pattern: hardcoded-secret
severity: MEDIUM

# 内部の許可リストで built-in の suspicious-fetch を上書きする
- id: suspicious-fetch-0
severity: MEDIUM
pattern: suspicious-fetch
message: "External URL used in command context"
regex: '(?i)(curl|wget|invoke-webrequest|iwr)\s+https?://'
exclude: '(?i)https?://(localhost|127\.0\.0\.1|artifacts\.company\.internal|registry\.company\.internal)'

# ガバナンス例外: ノイズの多い insecure-http のシグナルを無効化する
- id: insecure-http-0
enabled: false

init で始める

audit rules init(または audit --init-rules)は、コメントアウトされた例を含むスターター用の audit-rules.yaml を作成します。これをアンコメントして調整できます。

skillshare audit rules init          # → ~/.config/skillshare/audit-rules.yaml
skillshare audit rules init -p # → .skillshare/audit-rules.yaml

生成されるファイルは次のようになります。

# Custom audit rules for skillshare.
# Rules are merged on top of built-in rules in order:
# built-in → global (~/.config/skillshare/audit-rules.yaml)
# → project (.skillshare/audit-rules.yaml)
#
# Each rule needs: id, severity, pattern, message, regex.
# Optional: exclude (suppress match), enabled (false to disable).

rules:
# Example: flag TODO comments as informational
# - id: flag-todo
# severity: MEDIUM
# pattern: todo-comment
# message: "TODO comment found"
# regex: '(?i)\bTODO\b'

# Example: disable a built-in rule by id
# - id: insecure-http-0
# enabled: false

# Example: disable the dangling-link structural check
# - id: dangling-link
# enabled: false

# Example: override a built-in rule (match by id, change severity)
# - id: destructive-commands-2
# severity: MEDIUM
# pattern: destructive-commands
# message: "Sudo usage (downgraded)"
# regex: '(?i)\bsudo\s+'

ファイルが既に存在する場合、init はエラーで終了します — 既存のルールを上書きすることはありません。

ワークフロー: 誤検知の修正

ルールをカスタマイズする一般的な理由は、正当な Skill が built-in ルールに引っかかる場合です。ステップバイステップの例を示します。

1. audit を実行して誤検知を確認する:

$ skillshare audit ci-helper
[1/1] ! ci-helper 0.2s
└─ HIGH: Destructive command pattern (SKILL.md:42)
"sudo apt-get install -y jq"

2. built-in ルールのテーブルからルール ID を特定する:

sudo を含む destructive-commands パターンは、ルール destructive-commands-2 に一致します。

3. カスタムルールファイルを作成する(まだ作成していない場合):

skillshare audit rules init

4. ルールのオーバーライドを追加して抑制または引き下げる:

# ~/.config/skillshare/audit-rules.yaml
rules:
# CI 自動化用の Skill 向けに sudo を MEDIUM に引き下げる
- id: destructive-commands-2
severity: MEDIUM
pattern: destructive-commands
message: "Sudo usage (downgraded for CI automation)"
regex: '(?i)\bsudo\s+'

または完全に無効化する:

rules:
- id: destructive-commands-2
enabled: false

5. audit を再実行して確認する:

$ skillshare audit ci-helper
[1/1] ✓ ci-helper 0.1s # 合格になる(または HIGH の代わりに MEDIUM が表示される)

変更を検証する

ルールを編集した後、audit を再実行して確認してください。

skillshare audit                     # すべての Skill をチェック
skillshare audit <name> # 特定の Skill をチェック
skillshare audit --json | jq '.skills[].findings' # findings をプログラムから確認

サマリーの解釈:

  • Failed は、有効な閾値以上の findings を持つ Skill を数える。
  • Warning は、閾値未満だが clean より上の findings を持つ Skill を数える(例えば閾値が CRITICAL のときの HIGH/MEDIUM/LOW/INFO)。

Built-in ルール ID

id の値を使って、特定の built-in ルールをオーバーライドまたは無効化します。

正規表現ベースのルールの信頼できる情報源: internal/audit/rules.yaml

構造チェック、tier チェック、Skill 間チェック

dangling-linkcontent-tamperedcontent-oversizecontent-missingcontent-unexpected構造チェックです(正規表現ではなく、ファイルシステムの検索とハッシュ比較)。low-analyzabilityAnalyzability Score から生成される分析可能性の finding です。tier-stealthtier-destructive-networktier-network-heavytier-interpretertier-interpreter-network は、Command Safety Tiering プロファイルから生成されるティアの組み合わせの finding です。cross-skill-* の findings は、Cross-Skill Interaction Detection から生成されます。これらはすべて下記の表に記載されていますが、rules.yaml には定義されていません。

IDパターン重大度
prompt-injection-0prompt-injectionCRITICAL
prompt-injection-1prompt-injectionCRITICAL
prompt-injection-2prompt-injectionHIGH
prompt-injection-3prompt-injectionCRITICAL
prompt-injection-4prompt-injectionCRITICAL
hidden-unicode-1invisible-payloadCRITICAL
data-exfiltration-0data-exfiltrationCRITICAL
data-exfiltration-1data-exfiltrationCRITICAL
data-exfiltration-2data-exfiltrationMEDIUM
data-exfiltration-3data-exfiltrationHIGH
credential-access-ssh-private-keycredential-accessCRITICAL
credential-access-env-filecredential-accessCRITICAL
credential-access-aws-credentialscredential-accessCRITICAL
credential-access-etc-shadowcredential-accessCRITICAL
credential-access-git-credentialscredential-accessCRITICAL
credential-access-netrccredential-accessCRITICAL
credential-access-gnupgcredential-accessCRITICAL
credential-access-kube-configcredential-accessCRITICAL
credential-access-vault-tokencredential-accessCRITICAL
credential-access-terraform-credscredential-accessCRITICAL
credential-access-gnome-keyringcredential-accessCRITICAL
credential-access-npmrccredential-accessCRITICAL
credential-access-pypirccredential-accessCRITICAL
credential-access-gem-credentialscredential-accessCRITICAL
credential-access-ssl-privatecredential-accessCRITICAL
credential-access-ssh-host-keycredential-accessCRITICAL
credential-access-pgpasscredential-accessCRITICAL
credential-access-mysql-cnfcredential-accessCRITICAL
credential-access-etc-passwdcredential-accessMEDIUM
credential-access-azure-credscredential-accessHIGH
credential-access-gcloud-credscredential-accessHIGH
credential-access-docker-configcredential-accessHIGH
credential-access-gh-cli-tokencredential-accessHIGH
credential-access-password-storecredential-accessHIGH
credential-access-macos-keychain-usercredential-accessHIGH
credential-access-macos-keychain-syscredential-accessHIGH
credential-access-terraformrccredential-accessHIGH
credential-access-cargo-credentialscredential-accessHIGH
credential-access-op-clicredential-accessHIGH
credential-access-age-keyscredential-accessHIGH
credential-access-shell-historycredential-accessLOW
credential-access-openvpncredential-accessLOW
credential-access-auth-logcredential-accessINFO
credential-access-unknown-dotdircredential-accessINFO

注: 上記の各 credential エントリは、アクセス方法ごとに派生 ID も生成します: -copy-redirect-dd-exfil(例: credential-access-ssh-private-key-copy)。特定の派生バリアントを無効化するには、audit-rules.yaml でその完全な ID を使用してください。

IDパターン重大度
hidden-unicode-0hidden-unicodeHIGH
hidden-unicode-2hidden-unicodeHIGH
config-manipulation-0config-manipulationHIGH
hidden-comment-injection-1hidden-comment-injectionHIGH
self-propagation-0self-propagationHIGH
destructive-commands-0destructive-commandsHIGH
destructive-commands-1destructive-commandsHIGH
destructive-commands-2destructive-commandsHIGH
destructive-commands-3destructive-commandsHIGH
destructive-commands-4destructive-commandsHIGH
dynamic-code-exec-0dynamic-code-execHIGH
dynamic-code-exec-1dynamic-code-execHIGH
shell-execution-0shell-executionHIGH
hidden-comment-injection-0hidden-comment-injectionHIGH
obfuscation-0obfuscationHIGH
fetch-with-pipe-0fetch-with-pipeHIGH
fetch-with-pipe-1fetch-with-pipeHIGH
fetch-with-pipe-2fetch-with-pipeHIGH
hardcoded-secret-0hardcoded-secretHIGH
hardcoded-secret-1hardcoded-secretHIGH
hardcoded-secret-2hardcoded-secretHIGH
hardcoded-secret-3hardcoded-secretHIGH
hardcoded-secret-4hardcoded-secretHIGH
hardcoded-secret-5hardcoded-secretHIGH
hardcoded-secret-6hardcoded-secretHIGH
hardcoded-secret-7hardcoded-secretHIGH
hardcoded-secret-8hardcoded-secretHIGH
hardcoded-secret-9hardcoded-secretHIGH
data-uri-0data-uriMEDIUM
escape-obfuscation-0escape-obfuscationMEDIUM
suspicious-fetch-0suspicious-fetchMEDIUM
ip-address-url-0ip-address-urlMEDIUM
hidden-unicode-3hidden-unicodeMEDIUM
untrusted-install-0untrusted-installMEDIUM
untrusted-install-1untrusted-installMEDIUM
insecure-http-0insecure-httpLOW
external-link-0external-linkLOW
dangling-linkdangling-linkLOW
content-tamperedcontent-tamperedMEDIUM
content-oversizecontent-oversizeMEDIUM
content-missingcontent-missingLOW
content-unexpectedcontent-unexpectedLOW
shell-chain-0shell-chainINFO
low-analyzabilitylow-analyzabilityINFO
tier-stealthtier-stealthCRITICAL
tier-destructive-networktier-destructive-networkHIGH
tier-network-heavytier-network-heavyMEDIUM
tier-interpretertier-interpreterINFO
tier-interpreter-networktier-interpreter-networkMEDIUM
cross-skill-exfiltrationcross-skill-exfiltrationHIGH
cross-skill-privilege-networkcross-skill-privilege-networkMEDIUM
cross-skill-stealthcross-skill-stealthHIGH
cross-skill-cred-interpretercross-skill-cred-interpreterMEDIUM

サブコマンド

サブコマンド説明
rulesaudit ルールの閲覧、有効化、無効化
rules disable <id>ID で単一ルールを無効化
rules disable --pattern <p>パターンに一致するすべてのルールを無効化
rules enable <id>ID で単一ルールを再有効化
rules enable --pattern <p>パターンに一致するすべてのルールを再有効化
rules severity <id> <level>単一ルールの重大度を上書き
rules severity --pattern <p> <level>パターングループ内のすべてのルールの重大度を上書き
rules resetすべてのカスタムルールを削除(built-in のデフォルトに戻す)
rules initスターター用の audit-rules.yaml を作成(audit --init-rules と同じ)

関連項目

  • audit — メインの audit コマンドリファレンス
  • Audit Engine — エンジンの仕組み(脅威モデル、リスクスコアリング、ティア分類)
  • Securing Your Skills — チーム向けセキュリティガイド
  • CI/CD Skill Validation — パイプライン自動化のレシピ