UNPKG

supa-seed

Version:

A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support

168 lines 4.73 kB
/** * RLS Compliance Engine * Analyzes and validates Row Level Security policies */ export interface ComplianceEngineConfig { strictMode: boolean; autoFix: boolean; autoFixEnabled?: boolean; enableAdvancedParsing?: boolean; enableConflictDetection?: boolean; enablePerformanceAnalysis?: boolean; enableSecurityAnalysis?: boolean; auditLevel?: 'basic' | 'comprehensive' | 'detailed'; generateReports?: boolean; frameworkSpecific?: boolean; maxConcurrentValidations?: number; reportFormat?: 'json' | 'markdown' | 'html'; includeTables?: string[]; excludeTables?: string[]; policies?: { enforceAuthentication: boolean; requireTenantIsolation: boolean; validateOwnership: boolean; }; } export interface ComplianceEngineResult { overallCompliance: { score: number; grade: 'A' | 'B' | 'C' | 'D' | 'F'; criticalIssues: number; } | number; tablesAnalyzed: number; policiesFound: number; violations: ComplianceViolation[]; recommendations: string[]; autoFixesApplied: AutoFix[]; autoFixResults?: AutoFixResult[]; isCompliant?: boolean; requiresUserContext?: boolean; suggestedFixes?: AutoFix[]; policyAnalysis?: { parsedPolicies: ParsedPolicy[]; securityDistribution: { strong: number; moderate: number; weak: number; }; }; executionMetrics?: { duration: number; tablesProcessed: number; policiesAnalyzed: number; }; summary: { compliant: number; nonCompliant: number; warnings: number; }; } export interface AutoFixResult extends AutoFix { status: 'applied' | 'failed' | 'skipped' | 'requires_manual_review'; error?: string; fixType?: string; originalIssue?: string; } export interface ParsedPolicy { name: string; table: string; command: string; parsed: { expression: string; hasUserContext: boolean; securityLevel: 'strong' | 'moderate' | 'weak'; }; } export interface ComplianceViolation { table: string; severity: 'high' | 'medium' | 'low'; type: 'missing_policy' | 'insecure_policy' | 'policy_conflict'; description: string; recommendation: string; autoFixAvailable: boolean; } export interface AutoFix { table: string; description: string; applied: boolean; sql?: string; } export type ComplianceStatus = 'compliant' | 'partial' | 'non_compliant'; export declare class RLSComplianceEngine { private client; private config; constructor(client: any, config?: Partial<ComplianceEngineConfig>); /** * Analyze RLS compliance across all tables */ analyzeCompliance(): Promise<ComplianceEngineResult>; /** * Analyze RLS compliance for a specific table */ private analyzeTableCompliance; /** * Check if RLS is enabled on a table */ private isRLSEnabled; /** * Get RLS policies for a table */ private getTablePolicies; /** * Analyze individual policy compliance */ private analyzePolicyCompliance; /** * Apply auto-fixes for RLS issues */ private applyAutoFixes; /** * Get list of tables to analyze */ private getTables; /** * Check if table should be skipped from analysis */ private shouldSkipTable; /** * Analyze and enforce compliance with auto-fixes */ analyzeAndEnforceCompliance(config?: Partial<ComplianceEngineConfig>): Promise<ComplianceEngineResult>; /** * Quick compliance check for a specific table and operation */ quickComplianceCheck(tableName: string, operation?: 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE', dataCount?: number): Promise<ComplianceEngineResult>; /** * Generate formatted report */ generateFormattedReport(result: ComplianceEngineResult, format?: 'json' | 'markdown' | 'html'): Promise<string>; /** * Generate markdown report */ private generateMarkdownReport; /** * Generate HTML report */ private generateHtmlReport; /** * Calculate letter grade from compliance score */ private calculateGrade; /** * Analyze policies for security patterns */ private analyzePolicies; /** * Assess security level of a policy expression */ private assessPolicySecurityLevel; /** * Get numeric score from compliance union type */ private getComplianceScore; /** * Generate recommendations based on violations */ private generateRecommendations; } //# sourceMappingURL=rls-compliance-engine.d.ts.map