mcpField
R
rbac-policy-tester

rbac-policy-tester

github.com/patricio0312revテスト・品質63260 回インストール41 週間前に更新
リポジトリ

rbac-policy-tester について

rbac-policy-testerは、ロールベースのアクセス制御テストを計画・確認するスキルです。権限マトリクス、各ロールの許可・拒否テスト、CIのゲート、カバレッジ監視を扱います。

主な機能

  1. 01ロールとリソースの権限マトリクス定義
  2. 02各ロールの許可・拒否テスト
  3. 03権限テストによるCIゲート
  4. 04テストカバレッジの監視

活用シーン

  1. 01users、orders、reportsのアクセス検証を計画
  2. 02ロールごとの許可・拒否操作を確認
  3. 03権限チェックをCIに追加

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/patricio0312rev/skills --skill rbac-policy-tester

インストール後、Claude Code で/rbac-policy-testerを入力して読み込まれたか確認します。

詳細

RBAC/ポリシーテスター

ロールベースのアクセス制御を包括的にテストします。

権限テストマトリックス

type Role = 'ADMIN' | 'MANAGER' | 'USER' | 'GUEST';
type Action = 'create' | 'read' | 'update' | 'delete';
type Resource = 'users' | 'orders' | 'reports';

const permissionMatrix: Record<Role, Record<Resource, Action[]>> = {
  ADMIN: {
    users: ['create', 'read', 'update', 'delete'],
    orders: ['create', 'read', 'update', 'delete'],
    reports: ['create', 'read', 'update', 'delete'],
  },
  MANAGER: {
    users: ['read', 'update'],
    orders: ['create', 'read', 'update'],
    reports: ['read', 'update'],
  },
  USER: {
    users: ['read'], // Only own profile
    orders: ['create', 'read'], // Only own orders
    reports: ['read'],
  },
  GUEST: {
    users: [],
    orders: [],
    reports: ['read'],
  },
};

describe('RBAC Tests', () => {
  Object.entries(permissionMatrix).forEach(([role, resources]) => {
    describe(\`Role: \${role}\`, () => {
      Object.entries(resources).forEach(([resource, actions]) => {
        actions.forEach(action => {
          it(\`should allow \${action} on \${resource}\`, async () => {
            const token = generateToken({ role });
            await request(app)
              .post(\`/api/\${resource}/\${action}\`)
              .set('Authorization', \`Bearer \${token}\`)
              .expect(200);
          });
        });

        // Test forbidden actions
        const allActions: Action[] = ['create', 'read', 'update', 'delete'];
        const forbidden = allActions.filter(a => !actions.includes(a));

        forbidden.forEach(action => {
          it(\`should deny \${action} on \${resource}\`, async () => {
            const token = generateToken({ role });
            await request(app)
              .post(\`/api/\${resource}/\${action}\`)
              .set('Authorization', \`Bearer \${token}\`)
              .expect(403);
          });
        });
      });
    });
  });
});

出力チェックリスト

  • 権限マトリックスを定義
  • すべてのロールを対象としたテストスイート
  • 肯定テストと否定テスト
  • CI ゲートを有効化
  • カバレッジを監視 ENDFILE

コメント