UNPKG

@flamesshield/rules-engine

Version:

Independent rules engine for security analysis of Firebase

207 lines 6.31 kB
export interface AnalysisResult { status: 'started' | 'finished' | 'error'; scanId: string; project_id: string; timestamp: string; total_rules: number; triggered_rules: number; results: RuleResult[]; sarif?: Record<string, unknown>; } export interface RuleResult { rule_id: string; rule_name: string; rule?: Record<string, unknown>; severity: string; category: string; message: string; triggered: boolean; facts_used: Record<string, unknown>; event_params?: Record<string, unknown>; } export interface FirebaseFunction { name: string; location: string; trigger: string; environment_variables: Record<string, string>; service_account_email: string; } export interface DatabaseInfo { id: string; location: string; } export interface StorageBucket { name: string; location?: string; storageClass?: string; [key: string]: any; } export interface AuthSettings { auth_enabled: boolean; email_enabled: boolean; min_length: number; max_password_length: number; special_chars: boolean; upper_case: boolean; lower_case: boolean; number_required: boolean; enforced: boolean; anonymous_auth_enabled: boolean; phone_auth_enabled: boolean; email_auth_configured: boolean; mfa_enabled: boolean; mfa_state: string; authorized_domains: string[]; authorized_domains_count: number; email_verification_enabled: boolean; email_enumeration_protection: boolean; password_policy_enforcement: string; sms_region_configured: boolean; sms_template_configured: boolean; } export interface SecretScanResult { id: string; secretsCount: number; } export interface AppCheckSettings { app_check_enabled: boolean; services: Array<{ name: string; display_name?: string; enforcement_mode: string; last_updated?: string; is_enforced: boolean; }>; apps: Array<{ app_id: string; display_name?: string; platform: 'ios' | 'android' | 'web'; attestation_providers: string[]; token_ttl?: string; }>; total_services: number; enforced_services: number; unenforced_services: number; total_apps: number; security_summary: { overall_status: 'secure' | 'partially_secure' | 'insecure' | 'not_configured'; risk_level: 'low' | 'medium' | 'high'; recommendations: string[]; }; } export interface ProjectInformation { project_id: string; databases: DatabaseInfo[]; functionsv1: FirebaseFunction[]; functionsv2: FirebaseFunction[]; storage_buckets: StorageBucket[]; auth: AuthSettings; app_check: AppCheckSettings; function_secrets: SecretScanResult[]; firestore_rules?: string; database_rules?: string; storage_rules?: string; } /** * Rules engine specific types * Imports shared types from the shared package */ export interface StaticRule { id: string; name: string; description: string; severity?: 'low' | 'medium' | 'high' | 'critical'; category?: string; conditions: Record<string, unknown>; event: { type: string; params: { message: string; [key: string]: unknown; }; }; created_at: string; updated_at: string; } export interface RuleExecutionContext { project_information: ProjectInformation; configured_rules: StaticRule[]; execution_timestamp: string; } export interface Scanner { scan(projectInformation: ProjectInformation): Promise<any[]>; } export interface ScannerRegistry { registerScanner(name: string, scanner: Scanner): void; getScanner(name: string): Scanner | undefined; getAllScanners(): Map<string, Scanner>; } export type Rule = StaticRule; export interface RuleExecutionResult extends RuleResult { } export interface ComputedFacts { hasPublicFunctions: boolean; functionCount: number; totalSecrets: number; hasDatabases: boolean; hasStorage: boolean; hasAuth: boolean; averageSecretsPerFunction: number; functionsByLocation: Record<string, number>; maxSecretsInSingleFunction: number; [key: string]: any; } export interface FactTransformationOptions { includeComputedFacts?: boolean; includeMetadata?: boolean; customFactTransformers?: Array<(facts: Record<string, any>) => Record<string, any>>; } import { AnalysisFinding } from '../api/SecurityAnalysisClient'; export interface ComputedProperties { firestore_vulnerabilities?: AnalysisFinding[]; fails_rule: Record<string, boolean>; enforcement_ratio: number; apps_without_attestation_providers: number; security_score: number; has_secrets: boolean; multi_region_deployment: boolean; has_http_triggered_functions: boolean; total_services: number; enforced_services: number; unenforced_services: number; total_apps: number; apps_with_attestation_providers: number; auth_service_unenforced: boolean; functions_service_unenforced: boolean; dataconnect_service_unenforced: boolean; ailogic_service_unenforced: boolean; google_identity_ios_service_unenforced: boolean; maps_js_service_unenforced: boolean; places_api_service_unenforced: boolean; rtdb_service_unenforced: boolean; storage_service_unenforced: boolean; } export interface EnrichedProjectInformation extends ProjectInformation { firestore_vulnerabilities?: AnalysisFinding[]; fails_rule: Record<string, boolean>; computed: ComputedProperties; total_apps: number; total_services: number; unenforced_services: number; enforcement_coverage_ratio: number; security_summary: any; apps_without_attestation_providers: number; has_http_triggered_functions: boolean; auth_service_unenforced: boolean; functions_service_unenforced: boolean; dataconnect_service_unenforced: boolean; ailogic_service_unenforced: boolean; google_identity_ios_service_unenforced: boolean; maps_js_service_unenforced: boolean; places_api_service_unenforced: boolean; rtdb_service_unenforced: boolean; storage_service_unenforced: boolean; has_secrets: boolean; } export * from './validation.js'; //# sourceMappingURL=index.d.ts.map