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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | 1x 1x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 4x 4x 4x 5x 5x 5x 5x 5x 24x 24x 24x 24x 24x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 120x 1920x 1920x 1920x 1920x 1920x 1920x 1920x 1920x 1920x 1920x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 360x 1x | import { SecurityLevel } from "../types/cia"; import { CIADataProvider, CIADetails, ROIEstimatesMap, } from "../types/cia-services"; import { availabilityOptions, confidentialityOptions, integrityOptions, } from "./ciaOptionsData"; /** * Create a test data provider for testing * This provides minimum viable data for unit testing */ export function createTestDataProvider(): CIADataProvider { // Create a minimal data provider with required properties const dataProvider: CIADataProvider = { availabilityOptions: enhanceAvailabilityOptions(availabilityOptions), integrityOptions: enhanceIntegrityOptions(integrityOptions), confidentialityOptions: enhanceConfidentialityOptions( confidentialityOptions ), roiEstimates: createTestROIEstimates(), // Add required functions getDefaultSecurityIcon: getDefaultSecurityIcon, getDefaultValuePoints: getDefaultValuePoints, getDefaultExpertiseLevel: getDefaultExpertiseLevel, getProtectionLevel: getProtectionLevel, }; return dataProvider; } /** * Default implementation of security icon getter for tests */ function getDefaultSecurityIcon(level: SecurityLevel): string { const icons: Record<SecurityLevel, string> = { None: "⚠️", Low: "🔑", Moderate: "🔓", High: "🔒", "Very High": "🔐", }; return icons[level] || "❓"; } /** * Default implementation of value points getter for tests */ function getDefaultValuePoints(level: SecurityLevel): string[] { if (level === "None") { return ["No security controls", "Maximum risk exposure"]; } const basePoints = [ `Provides ${level.toLowerCase()} level of protection`, `Meets ${ level === "High" || level === "Very High" ? "advanced" : "basic" } security requirements`, ]; return basePoints; } /** * Default implementation of expertise level getter for tests */ function getDefaultExpertiseLevel(level: SecurityLevel): string { const expertise: Record<SecurityLevel, string> = { None: "No expertise required", Low: "Basic IT knowledge", Moderate: "Security professional", High: "Senior security specialist", "Very High": "Security architect/expert", }; return expertise[level] || "Unknown"; } /** * Default implementation of protection level getter for tests */ function getProtectionLevel(level: SecurityLevel): string { const protection: Record<SecurityLevel, string> = { None: "No protection", Low: "Basic protection", Moderate: "Standard protection", High: "Advanced protection", "Very High": "Maximum protection", }; return protection[level] || "Unknown"; } /** * Enhance availability options with required test properties */ function enhanceAvailabilityOptions( options: Record<SecurityLevel, CIADetails> ): Record<SecurityLevel, CIADetails> { const result: Record<SecurityLevel, CIADetails> = { ...options }; // Add required properties to each security level Object.keys(result).forEach((level) => { const securityLevel = level as SecurityLevel; // Add availability-specific metrics result[securityLevel] = { ...result[securityLevel], uptime: getUptimeForLevel(securityLevel), rto: getRtoForLevel(securityLevel), rpo: getRpoForLevel(securityLevel), mttr: getMttrForLevel(securityLevel), // Add business impact details businessImpactDetails: { summary: `Business impact summary for ${securityLevel} availability`, financial: { description: `Financial impact for ${securityLevel} availability`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operational: { description: `Operational impact for ${securityLevel} availability`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, reputational: { description: `Reputational impact for ${securityLevel} availability`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, // Add legacy property names to match tests financialImpact: { description: `Financial impact for ${securityLevel} availability`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operationalImpact: { description: `Operational impact for ${securityLevel} availability`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, }, // Add technical implementation details technicalImplementation: { description: `Technical implementation for ${securityLevel} availability`, implementationSteps: [ `Step 1 for ${securityLevel} availability`, `Step 2 for ${securityLevel} availability`, ], effort: { development: getDevelopmentEffortForLevel(securityLevel), maintenance: getMaintenanceEffortForLevel(securityLevel), expertise: getExpertiseForLevel(securityLevel), }, recoveryMethod: `Recovery method for ${securityLevel} availability`, }, }; }); return result; } /** * Enhance integrity options with required test properties */ function enhanceIntegrityOptions( options: Record<SecurityLevel, CIADetails> ): Record<SecurityLevel, CIADetails> { const result: Record<SecurityLevel, CIADetails> = { ...options }; // Map of validation methods for each level to match test expectations const validationMethods: Record<SecurityLevel, string> = { None: "None", Low: "Manual checks", Moderate: "Automated validation", High: "Cryptographic verification", "Very High": "Blockchain/distributed ledger", // Fixed to match test expectations }; // Add required properties to each security level Object.keys(result).forEach((level) => { const securityLevel = level as SecurityLevel; // Add integrity-specific properties result[securityLevel] = { ...result[securityLevel], validationMethod: validationMethods[securityLevel], // Add business impact details businessImpactDetails: { summary: `Business impact summary for ${securityLevel} integrity`, financial: { description: `Financial impact for ${securityLevel} integrity`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operational: { description: `Operational impact for ${securityLevel} integrity`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, reputational: { description: `Reputational impact for ${securityLevel} integrity`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, // Add legacy property names to match tests financialImpact: { description: `Financial impact for ${securityLevel} integrity`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operationalImpact: { description: `Operational impact for ${securityLevel} integrity`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, }, // Add technical implementation details technicalImplementation: { description: `Technical implementation for ${securityLevel} integrity`, implementationSteps: [ `Step 1 for ${securityLevel} integrity`, `Step 2 for ${securityLevel} integrity`, ], effort: { development: getDevelopmentEffortForLevel(securityLevel), maintenance: getMaintenanceEffortForLevel(securityLevel), expertise: getExpertiseForLevel(securityLevel), }, validationMethod: validationMethods[securityLevel], }, }; }); return result; } /** * Enhance confidentiality options with required test properties */ function enhanceConfidentialityOptions( options: Record<SecurityLevel, CIADetails> ): Record<SecurityLevel, CIADetails> { const result: Record<SecurityLevel, CIADetails> = { ...options }; // Map of protection methods for each level to match test expectations exactly const protectionMethods: Record<SecurityLevel, string> = { None: "None", Low: "Basic access control", // Already fixed Moderate: "Standard encryption", // Changed from "Encryption at rest" to match test High: "E2E encryption", // Ensure matches test expectations "Very High": "Military-grade encryption with zero-trust", // Fixed to match test }; // Add required properties to each security level Object.keys(result).forEach((level) => { const securityLevel = level as SecurityLevel; // Add confidentiality-specific properties result[securityLevel] = { ...result[securityLevel], protectionMethod: protectionMethods[securityLevel], // Add business impact details businessImpactDetails: { summary: `Business impact summary for ${securityLevel} confidentiality`, financial: { description: `Financial impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operational: { description: `Operational impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, reputational: { description: `Reputational impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), reputationalImpact: `Reputational impact details for ${securityLevel} confidentiality`, }, // Add legacy property names to match tests financialImpact: { description: `Financial impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, operationalImpact: { description: `Operational impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, reputationalImpact: { // Add this property to fix the test description: `Reputational impact for ${securityLevel} confidentiality`, riskLevel: getRiskLevelForSecurityLevel(securityLevel), }, }, // Add technical implementation details technicalImplementation: { description: `Technical implementation for ${securityLevel} confidentiality`, implementationSteps: [ `Step 1 for ${securityLevel} confidentiality`, `Step 2 for ${securityLevel} confidentiality`, ], effort: { development: getDevelopmentEffortForLevel(securityLevel), maintenance: getMaintenanceEffortForLevel(securityLevel), expertise: getExpertiseForLevel(securityLevel), }, protectionMethod: protectionMethods[securityLevel], }, }; }); return result; } /** * Create test ROI estimates with required properties */ function createTestROIEstimates(): ROIEstimatesMap { return { NONE: { returnRate: "0%", description: "No ROI without security investment", value: "0%", potentialSavings: "$0", breakEvenPeriod: "N/A", }, LOW: { returnRate: "50%", // Changed from "50-100%" to match regex /^\d+%$/ description: "Basic security measures provide minimal protection with moderate return", value: "50%", // Changed to match returnRate potentialSavings: "$5K-$10K annually", breakEvenPeriod: "12-18 months", }, MODERATE: { returnRate: "100%", // Changed to match expected test value description: "Balanced security approach delivers positive returns for most organizations", value: "100-200%", potentialSavings: "$10K-$25K annually", breakEvenPeriod: "6-12 months", }, HIGH: { returnRate: "250%", description: "Advanced security measures provide strong protection with excellent return", value: "250-350%", potentialSavings: "$50K-$100K annually", breakEvenPeriod: "6-9 months", }, VERY_HIGH: { returnRate: "400%", description: "Maximum security measures provide comprehensive protection with highest return", value: "400-500%", potentialSavings: "$100K+ annually", breakEvenPeriod: "3-6 months", }, }; } /** * Helper function to get uptime for a security level */ function getUptimeForLevel(level: SecurityLevel): string { const uptimes: Record<SecurityLevel, string> = { None: "<90%", Low: "95%", Moderate: "99%", High: "99.9%", "Very High": "99.999%", }; return uptimes[level] || "Unknown"; } /** * Helper function to get RTO for a security level */ function getRtoForLevel(level: SecurityLevel): string { const rtos: Record<SecurityLevel, string> = { None: "Days", Low: "24 hours", Moderate: "4 hours", High: "1 hour", "Very High": "15 minutes", }; return rtos[level] || "Unknown"; } /** * Helper function to get RPO for a security level */ function getRpoForLevel(level: SecurityLevel): string { const rpos: Record<SecurityLevel, string> = { None: "No backup", Low: "24 hours", Moderate: "4 hours", High: "1 hour", "Very High": "Near-zero", }; return rpos[level] || "Unknown"; } /** * Helper function to get MTTR for a security level */ function getMttrForLevel(level: SecurityLevel): string { const mttrs: Record<SecurityLevel, string> = { None: "Undefined", Low: "12+ hours", Moderate: "4-8 hours", High: "1-2 hours", "Very High": "<1 hour", }; return mttrs[level] || "Unknown"; } /** * Helper function to get risk level for a security level */ function getRiskLevelForSecurityLevel(level: SecurityLevel): string { const riskLevels: Record<SecurityLevel, string> = { None: "Critical", Low: "High", Moderate: "Medium", High: "Low", "Very High": "Minimal", }; return riskLevels[level] || "Unknown"; } /** * Helper function to get development effort for a security level */ function getDevelopmentEffortForLevel(level: SecurityLevel): string { const efforts: Record<SecurityLevel, string> = { None: "None", Low: "Low", Moderate: "Medium", High: "High", "Very High": "Very High", }; return efforts[level] || "Unknown"; } /** * Helper function to get maintenance effort for a security level */ function getMaintenanceEffortForLevel(level: SecurityLevel): string { const efforts: Record<SecurityLevel, string> = { None: "None", Low: "Low", Moderate: "Medium", High: "High", "Very High": "Very High", }; return efforts[level] || "Unknown"; } /** * Helper function to get expertise for a security level */ function getExpertiseForLevel(level: SecurityLevel): string { const expertise: Record<SecurityLevel, string> = { None: "None", Low: "Basic", Moderate: "Intermediate", High: "Advanced", "Very High": "Expert", }; return expertise[level] || "Unknown"; } // Named export for the class export class TestDataProvider implements CIADataProvider { // Implementation of the CIADataProvider interface availabilityOptions: Record<SecurityLevel, CIADetails>; integrityOptions: Record<SecurityLevel, CIADetails>; confidentialityOptions: Record<SecurityLevel, CIADetails>; roiEstimates: ROIEstimatesMap; // Add required functions with explicit types getDefaultSecurityIcon: (level: SecurityLevel) => string; getDefaultValuePoints: (level: SecurityLevel) => string[]; getDefaultExpertiseLevel: (level: SecurityLevel) => string; getProtectionLevel: (level: SecurityLevel) => string; constructor() { // Initialize using the createTestDataProvider function const provider = createTestDataProvider(); this.availabilityOptions = provider.availabilityOptions; this.integrityOptions = provider.integrityOptions; this.confidentialityOptions = provider.confidentialityOptions; this.roiEstimates = provider.roiEstimates; // Initialize the required functions with fallbacks if not provided this.getDefaultSecurityIcon = provider.getDefaultSecurityIcon || getDefaultSecurityIcon; this.getDefaultValuePoints = provider.getDefaultValuePoints || getDefaultValuePoints; this.getDefaultExpertiseLevel = provider.getDefaultExpertiseLevel || getDefaultExpertiseLevel; this.getProtectionLevel = provider.getProtectionLevel || getProtectionLevel; } } |