← スキル一覧に戻る

review-security-rules
by hieupvXmasEve
⭐ 0🍴 0📅 2026年1月6日
SKILL.md
name: review-security-rules description: Reviews code for security vulnerabilities and adherence to the project's Gate vs Policy authorization rules. Use before committing changes involving permissions or routes. allowed-tools: Read, Grep, Glob
Review Security & Authorization
This skill audits code for common security issues and strict adherence to the project's Authorization Rules (docs/rules/authorization.md).
Instructions
-
Analyze Scope:
- Focus on
routes/,Controllers,Policies, andGates.
- Focus on
-
Check for Authorization Violations:
1. Controller Authorization
- Rule: Controllers must NEVER call
Gate::allows(). They must use$this->authorize()(Policy). - Check: Grep
Gate::inside*Controller.php. - Fix: Replace with
$this->authorize('action', $model).
2. Route Authorization
- Rule: Routes with IDs (e.g.,
/events/{event}) must NOT usecan:middleware. - Reason: Middleware cannot check specific object ownership; Policy must do it.
- Check: Look for
Route::...->middleware('can:...')on routes with parameters. - Fix: Remove middleware, add
$this->authorize()in the Controller method.
3. Gate Definitions
- Rule: Gates must NOT accept Models or query the DB.
- Check: Review
AuthServiceProvideror where Gates are defined. - Fix: Gates should only check permissions (e.g.,
$user->hasPermission(...)).
4. Policy Implementation
- Rule: Policies must check Data Rules (ownership, status), not just permissions.
- Check:
*Policy.phpmethods. - Fix: Ensure
$user->id === $model->user_idor similar logic exists.
- Rule: Controllers must NEVER call
-
Report:
- List violations with file paths and line numbers.
- Cite the specific rule from
docs/rules/authorization.md.
Example Checks
1. Controller using Gate (Forbidden):
grep -r "Gate::" app/Http/Controllers
2. Route with ID using Middleware (Forbidden):
# Manual check of route files
# Look for: Route::get('/{id}', ...)->middleware('can:...')
3. Policy missing Data Check (Suspicious):
// Suspicious: Only checks permission
public function update(User $user, Post $post) {
return $user->can('update_posts');
}
// Correct: Checks permission AND ownership
public function update(User $user, Post $post) {
return $user->can('update_posts') && $post->user_id === $user->id;
}
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です