Implements a comprehensive suite of AI SDK v6 tools across multiple categories: - Research (5): page-brief, compare-pages, source-credibility, claim-checklist, timeline-from-text - Web (10): fetch-text, links-catalog, extract-meta, extract-json-ld, redirect-trace, sitemap-read, rss-read, table-extract, robots-policy, url-normalize - Data (15): csv-parse, csv-stringify, json-repair, json-schema-validate, yaml-parse, yaml-stringify, text-chunk, normalize-whitespace, dedupe-by-key, pivot, rows-filter, rows-sort, rows-group-aggregate, rows-join, schema-infer - Doc (12): toc-generate, glossary-build, faq-from-text, executive-brief, decision-record-adr, prd-outline, acceptance-criteria, style-rewrite - Eng (12): diff-text-unified, env-var-docs-generate, dependency-audit-lite, conventional-commit-suggest, markdown-lint-basic, test-case-generate, stacktrace-parse, release-notes, changelog-entry, release-checklist - Security (7): redact-secrets, secret-scan-text, url-risk-heuristic, csp-compose, hardening-checklist-web, access-control-matrix, data-classification-heuristic - Stats (9): effect-size-suite, bootstrap-ci, permutation-test, multiple-testing-adjust, linear-regression-ols, logistic-regression, time-series-decompose-lite, anomaly-detect-mad - Ops (7): slo-draft, runbook-draft, postmortem-draft, postmortem-action-extractor, error-log-triage, coverage-tracker, monitoring-gap-analysis - Agent (15): prompt-to-workflow-skeleton, workflow-validate-io, workflow-explain, workflow-cost-estimate, tool-call-accuracy-score, eval-fixture-build, guardrail-policy-draft, workflow-auto-repair, tool-selection-plan, novelty-score-workflow, workflow-variant-generate, config-normalize, recipe-* - Utility (8): base64-encode, base64-decode, hash-text, regex-extract, template-render, date-parse, json-path-query, url-parse - HTML (3): html-sanitize, html-to-markdown, markdown-to-html All tools follow AI SDK v6 pattern with tool() and jsonSchema<T>(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.9 KiB
5.9 KiB
Access Control Matrix Tool
Generates access control matrices from roles, resources, and permissions for RBAC (Role-Based Access Control) compliance and documentation.
Installation
npm install @tpmjs/tools-access-control-matrix
Usage
import { accessControlMatrix } from '@tpmjs/tools-access-control-matrix';
const result = await accessControlMatrix.execute({
roles: ['admin', 'editor', 'viewer'],
resources: ['documents', 'reports', 'settings'],
permissions: {
admin: {
documents: ['read', 'write', 'delete'],
reports: ['read', 'write', 'delete'],
settings: ['read', 'write'],
},
editor: {
documents: ['read', 'write'],
reports: ['read', 'write'],
},
viewer: {
documents: ['read'],
reports: ['read'],
},
},
});
console.log(result.visualization);
// Output:
// | documents | reports | settings |
// ------+--------------------+--------------------+--------------------+
// admin | read,write,delete | read,write,delete | read,write |
// editor| read,write | read,write | - |
// viewer| read | read | - |
console.log(result.summary);
// {
// totalCells: 9,
// cellsWithAccess: 7,
// cellsWithoutAccess: 2,
// totalPermissions: 14,
// rolePermissionCounts: { admin: 8, editor: 4, viewer: 2 },
// resourceAccessCounts: { documents: 3, reports: 3, settings: 1 },
// mostPermissiveRole: 'admin',
// mostRestrictedResource: 'settings'
// }
Input Schema
{
roles: string[]; // Array of role names
resources: string[]; // Array of resource names
permissions: { // Nested mapping
[role: string]: {
[resource: string]: string[]; // Array of actions
}
}
}
Output Schema
interface AccessControlMatrix {
matrix: MatrixCell[][]; // 2D array of role-resource permissions
roles: string[]; // List of roles
resources: string[]; // List of resources
summary: {
totalCells: number;
cellsWithAccess: number;
cellsWithoutAccess: number;
totalPermissions: number;
rolePermissionCounts: Record<string, number>;
resourceAccessCounts: Record<string, number>;
mostPermissiveRole: string;
mostRestrictedResource: string;
};
visualization: string; // ASCII table representation
}
interface MatrixCell {
role: string;
resource: string;
actions: string[];
hasAccess: boolean;
}
Use Cases
- RBAC Documentation - Generate visual documentation of role permissions
- Security Audits - Review access control configurations
- Compliance Reports - Generate access matrix for SOC2, ISO 27001
- Onboarding - Help new team members understand access structure
- Access Reviews - Quarterly reviews of role permissions
- Least Privilege Analysis - Identify overly permissive roles
Common Actions
Standard CRUD operations:
read- View or retrieve resourceswrite- Create or update resourcesdelete- Remove resourcesexecute- Run or trigger resources
Extended actions:
approve- Approve changes or requestspublish- Make resources publicly availableshare- Share resources with othersexport- Download or export dataadmin- Administrative access
Validation
The tool validates:
- Roles and resources are non-empty string arrays
- No duplicate roles or resources (case-insensitive)
- All permission roles exist in the roles list
- All permission resources exist in the resources list
- Actions are arrays of non-empty strings
Example: Multi-Tier Application
const appMatrix = await accessControlMatrix.execute({
roles: ['superadmin', 'admin', 'developer', 'analyst', 'guest'],
resources: ['users', 'database', 'api', 'reports', 'logs'],
permissions: {
superadmin: {
users: ['read', 'write', 'delete'],
database: ['read', 'write', 'delete', 'backup'],
api: ['read', 'write', 'delete', 'deploy'],
reports: ['read', 'write', 'export'],
logs: ['read', 'delete'],
},
admin: {
users: ['read', 'write'],
database: ['read'],
api: ['read', 'deploy'],
reports: ['read', 'write', 'export'],
logs: ['read'],
},
developer: {
api: ['read', 'write'],
logs: ['read'],
},
analyst: {
reports: ['read', 'export'],
logs: ['read'],
},
guest: {
reports: ['read'],
},
},
});
Example: Healthcare System
const healthcareMatrix = await accessControlMatrix.execute({
roles: ['physician', 'nurse', 'receptionist', 'billing'],
resources: ['patient_records', 'prescriptions', 'appointments', 'billing_info'],
permissions: {
physician: {
patient_records: ['read', 'write'],
prescriptions: ['read', 'write', 'approve'],
appointments: ['read'],
},
nurse: {
patient_records: ['read', 'write'],
prescriptions: ['read'],
appointments: ['read', 'write'],
},
receptionist: {
patient_records: ['read'],
appointments: ['read', 'write'],
},
billing: {
patient_records: ['read'],
billing_info: ['read', 'write'],
},
},
});
Best Practices
- Least Privilege - Grant minimum necessary permissions
- Separation of Duties - Divide critical permissions across roles
- Regular Reviews - Audit the matrix quarterly
- Clear Naming - Use descriptive role and resource names
- Document Actions - Define what each action means in context
- Version Control - Track matrix changes over time
Limitations
- Does not enforce permissions (documentation/analysis only)
- Does not support attribute-based access control (ABAC)
- Does not handle permission inheritance or hierarchies
- Case-sensitive role and resource names in display
- No support for conditional permissions or time-based access
License
MIT