Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | 1x 1x 1x 1x 1832x 1832x 1832x 1832x 1832x 86x 86x 86x 86x 86x 86x 86x 1x 1x 1x 1x 1x 1x 86x 1832x 100x 100x 100x 100x 42x 100x 28x 100x 29x 100x 1x 100x 100x 1832x 5x 5x 1832x 6923x 6923x 1832x 3x 3x 1832x 11x 5x 5x 6x 11x 1x 11x 1x 11x 1x 11x 1x 11x 1x 11x 1x 11x 11x 1832x 7x 7x 7x 7x 4x 4x 7x 1x 1x 7x 3x 7x 1832x 3x 3x 3x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1832x | import { SecurityLevel } from "../types/cia"; import { CIAComponentType, CIADataProvider, CIADetails, } from "../types/cia-services"; import { getSecurityLevelValue } from "../utils/levelValuesUtils"; import logger from "../utils/logger"; import { getRiskLevelFromSecurityLevel } from "../utils/riskUtils"; /** * Base service class that provides common functionality * for security-related services */ export class BaseService { /** * Data provider used by the service */ protected dataProvider: CIADataProvider; /** * Create a new service instance * * @param dataProvider - Data provider for security information */ constructor(dataProvider: CIADataProvider) { this.dataProvider = dataProvider; } /** * Get component details for a specific security level */ protected getComponentDetails( component: CIAComponentType, level: SecurityLevel ): CIADetails | undefined { try { const options = this.getCIAOptions(component); return options[level]; } catch (error) { logger.warn( `Failed to get component details for ${component} at level ${level}`, error ); return undefined; } } /** * Get options for a CIA component */ protected getCIAOptions( component: CIAComponentType ): Record<string, CIADetails> { switch (component) { case "availability": return this.dataProvider.availabilityOptions; case "integrity": return this.dataProvider.integrityOptions; case "confidentiality": return this.dataProvider.confidentialityOptions; default: return {}; } } /** * Get risk level from security level */ protected getRiskLevelFromSecurityLevel(level: SecurityLevel): string { return getRiskLevelFromSecurityLevel(level); } /** * Calculate security level value from level string */ protected getSecurityLevelValue(level: SecurityLevel): number { return getSecurityLevelValue(level); } /** * Capitalize first letter of a string */ protected capitalizeFirstLetter(string: string): string { return string.charAt(0).toUpperCase() + string.slice(1); } /** * Get default security icon for a level */ protected getDefaultSecurityIcon(level: SecurityLevel): string { if (typeof this.dataProvider.getDefaultSecurityIcon === "function") { return this.dataProvider.getDefaultSecurityIcon(level); } // Default icons switch (level) { case "None": return "⚠️"; case "Low": return "🔑"; case "Moderate": return "🔓"; case "High": return "🔒"; case "Very High": return "🔐"; default: return "❓"; } } /** * Get value points for a security level */ protected getValuePoints(level: SecurityLevel): string[] { if (typeof this.dataProvider.getDefaultValuePoints === "function") { try { const customPoints = this.dataProvider.getDefaultValuePoints(level); if (customPoints && customPoints.length > 0) { return customPoints; } } catch (error) { logger.warn("Error fetching custom value points:", error); } } return this.getDefaultValuePoints(level); } /** * Default implementation of value points */ private getDefaultValuePoints(level: SecurityLevel): string[] { switch (level) { case "Very High": return [ "Maximum security value with comprehensive protection", "Enables business in highly regulated industries", "Provides competitive advantage through superior security posture", "Minimizes risk of data breaches and associated costs", "Ensures regulatory compliance across major frameworks", ]; case "High": return [ "Strong security value with robust protection", "Supports business in moderately regulated industries", "Reduces risk of security incidents significantly", "Protects sensitive data and critical operations", "Meets requirements for most compliance frameworks", ]; case "Moderate": return [ "Balanced security value with standard protection", "Suitable for most business applications", "Reduces common security risks", "Protects important business data", "Meets basic compliance requirements", ]; case "Low": return [ "Basic security value with minimal protection", "Suitable for non-critical systems", "Addresses obvious security vulnerabilities", "Provides foundation for security program", "May not meet regulatory requirements", ]; case "None": default: return [ "No security value", "Suitable only for non-sensitive public information", "High vulnerability to security incidents", "No protection against threats", "Does not meet any compliance requirements", ]; } } } |