All files / src/utils technicalDetailsDefaults.ts

46.76% Statements 65/139
46.96% Branches 62/132
100% Functions 7/7
46.76% Lines 65/139

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 496 497 498 499 500 501 502 503                                  63x                                   63x 21x           21x                   42x 21x           21x                     21x           21x                                         78x 32x   1x       29x   1x   1x           46x 24x           23x       1x             22x           22x                                         64x 22x                     22x                                                       42x 21x                   21x                                                         21x                   21x                                                                             15x 11x   1x       8x   1x   1x           4x 3x           2x       1x             1x           1x                                         15x 11x   1x       8x   1x   1x           4x 3x           2x       1x             1x           1x                                         15x 11x   1x       8x           1x             1x                       4x 3x           2x                         1x                       1x           1x                                        
import { SecurityLevel } from "../types/cia";
 
/**
 * Gets default technical details when service isn't available
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Default technical details object
 */
export function getDefaultTechnicalDetails(
  component: string,
  level: SecurityLevel
): {
  description: string;
  technical: string;
  recommendations: string[];
} {
  return {
    description: getDefaultDescription(component, level),
    technical: getDefaultTechDescription(component, level),
    recommendations: getDefaultRequirements(component, level),
  };
}
 
/**
 * Gets default description for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Default description text
 */
export function getDefaultDescription(
  component: string,
  level: SecurityLevel
): string {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return "No confidentiality controls implemented, allowing unrestricted access to data.";
      case "Low":
        return "Basic confidentiality controls to prevent casual unauthorized access to data.";
      case "Moderate":
        return "Standard confidentiality controls with defined access privileges and protections.";
      case "High":
        return "Advanced confidentiality controls with strong encryption and strict access management.";
      case "Very High":
        return "Comprehensive confidentiality controls with the highest level of protection.";
      default:
        return "Standard confidentiality controls.";
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return "No integrity controls implemented, data can be modified without detection.";
      case "Low":
        return "Basic integrity controls that provide minimal protection against unauthorized changes.";
      case "Moderate":
        return "Standard integrity controls that detect unauthorized modifications to data.";
      case "High":
        return "Advanced integrity controls with cryptographic verification of data.";
      case "Very High":
        return "Comprehensive integrity controls with immutable audit trails.";
      default:
        return "Standard integrity controls.";
    }
  }
 
  // Default to availability
  switch (level) {
    case "None":
      return "No availability controls implemented, no guarantees for system uptime.";
    case "Low":
      return "Basic availability controls providing minimal resilience to disruptions.";
    case "Moderate":
      return "Standard availability controls ensuring reasonable system uptime.";
    case "High":
      return "Advanced availability controls with redundancy and quick recovery capabilities.";
    case "Very High":
      return "Comprehensive availability controls with maximum fault tolerance.";
    default:
      return "Standard availability controls.";
  }
}
 
/**
 * Gets default technical description for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Default technical description text
 */
export function getDefaultTechDescription(
  component: string,
  level: SecurityLevel
): string {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return "No specific technical controls for protecting data confidentiality.";
      case "Low":
        return "Basic access controls and password protection for sensitive resources.";
      case "Moderate":
        return "Role-based access control (RBAC), data encryption at rest and in transit, and proper authentication mechanisms.";
      case "High":
        return "Granular access control, strong encryption with proper key management, DLP controls, and multi-factor authentication.";
      case "Very High":
        return "Zero-trust architecture, advanced encryption with hardware security modules, comprehensive DLP, and context-aware access controls.";
      default:
        return "Standard confidentiality technical controls.";
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return "No specific technical controls for ensuring data integrity.";
      case "Low":
        return "Basic input validation and error detection mechanisms.";
      case "Moderate":
        return "Comprehensive input validation, checksums, access controls, and error detection.";
      case "High":
        return "Digital signatures, cryptographic hashing, strong change control, and comprehensive logging.";
      case "Very High":
        return "Blockchain or similar technologies for critical data, immutable audit logs, and formal verification methods.";
      default:
        return "Standard integrity technical controls.";
    }
  }
 
  // Default to availability
  switch (level) {
    case "None":
      return "No specific technical controls for ensuring system availability.";
    case "Low":
      return "Basic monitoring and manual recovery procedures.";
    case "Moderate":
      return "Redundant components, scheduled backups, load balancing, and defined recovery procedures.";
    case "High":
      return "Automatic failover, real-time monitoring, comprehensive disaster recovery, and advanced load balancing.";
    case "Very High":
      return "Multi-site active-active configurations, continuous data protection, and fully automated recovery with zero data loss.";
    default:
      return "Standard availability technical controls.";
  }
}
 
/**
 * Gets default technical requirements for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Array of default technical requirements
 */
export function getDefaultRequirements(
  component: string,
  level: SecurityLevel
): string[] {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return ["No specific requirements."];
      case "Low":
        return [
          "Implement user authentication",
          "Use basic password policies",
          "Apply simple access controls",
          "Secure sensitive data storage",
        ];
      case "Moderate":
        return [
          "Implement role-based access control",
          "Use standard TLS for data in transit",
          "Encrypt sensitive data at rest",
          "Enforce strong password policies",
          "Implement session management",
        ];
      case "High":
        return [
          "Implement multi-factor authentication",
          "Deploy data loss prevention solutions",
          "Use strong encryption for all data",
          "Implement privileged access management",
          "Conduct regular access reviews",
        ];
      case "Very High":
        return [
          "Implement zero-trust network architecture",
          "Use hardware security modules for encryption",
          "Deploy advanced data loss prevention",
          "Implement just-in-time access",
          "Use behavioral analytics for access monitoring",
        ];
      default:
        return ["Standard confidentiality requirements."];
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return ["No specific requirements."];
      case "Low":
        return [
          "Implement basic input validation",
          "Use simple error detection",
          "Apply basic data quality checks",
        ];
      case "Moderate":
        return [
          "Implement comprehensive input validation",
          "Use checksums for data verification",
          "Implement change detection mechanisms",
          "Maintain data validation logs",
          "Use database constraints",
        ];
      case "High":
        return [
          "Implement digital signatures",
          "Use cryptographic hash verification",
          "Deploy comprehensive audit logging",
          "Implement strict change controls",
          "Use data integrity monitoring",
        ];
      case "Very High":
        return [
          "Implement blockchain for critical data",
          "Use immutable audit trails",
          "Deploy formal verification methods",
          "Implement hardware-based integrity controls",
          "Use zero-knowledge proofs where applicable",
        ];
      default:
        return ["Standard integrity requirements."];
    }
  }
 
  // Default to availability
  switch (level) {
    case "None":
      return ["No specific requirements."];
    case "Low":
      return [
        "Set up basic system monitoring",
        "Implement manual backup procedures",
        "Create simple incident response plan",
      ];
    case "Moderate":
      return [
        "Implement redundant components",
        "Set up scheduled backup routines",
        "Deploy basic load balancing",
        "Create disaster recovery procedures",
        "Implement health checks and alerts",
      ];
    case "High":
      return [
        "Implement automatic failover mechanisms",
        "Deploy real-time monitoring and alerting",
        "Set up geographically distributed backups",
        "Implement advanced load balancing",
        "Create comprehensive disaster recovery plan",
      ];
    case "Very High":
      return [
        "Implement multi-site active-active configuration",
        "Deploy continuous data protection",
        "Use fully automated recovery mechanisms",
        "Implement zero-downtime deployment processes",
        "Deploy dedicated site reliability engineering",
      ];
    default:
      return ["Standard availability requirements."];
  }
}
 
/**
 * Gets default technologies for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Default technologies description
 */
export function getDefaultTechnologies(
  component: string,
  level: SecurityLevel
): string {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return "No specific technologies";
      case "Low":
        return "Password managers, basic access control lists";
      case "Moderate":
        return "LDAP, Active Directory, TLS 1.2+, AES-128";
      case "High":
        return "MFA solutions, DLP tools, AES-256, Key Management Systems";
      case "Very High":
        return "HSMs, Zero-trust frameworks, Advanced DLP, AES-256-GCM, Behavioral analytics";
      default:
        return "Standard encryption and access control tools";
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return "No specific technologies";
      case "Low":
        return "Basic input validation libraries, simple checksums";
      case "Moderate":
        return "SHA-256, input validation frameworks, database constraints";
      case "High":
        return "Digital signature systems, cryptographic hashing, SIEM tools";
      case "Very High":
        return "Blockchain platforms, immutable logging systems, formal verification tools";
      default:
        return "Standard integrity verification tools";
    }
  }
 
  // Default to availability
  switch (level) {
    case "None":
      return "No specific technologies";
    case "Low":
      return "Basic monitoring tools, manual backup scripts";
    case "Moderate":
      return "Load balancers, backup solutions, monitoring systems";
    case "High":
      return "HA clusters, advanced monitoring, automated failover systems";
    case "Very High":
      return "Global load balancers, CDP solutions, site reliability platforms, chaos engineering tools";
    default:
      return "Standard availability tools";
  }
}
 
/**
 * Gets default configurations for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Default configurations description
 */
export function getDefaultConfigurations(
  component: string,
  level: SecurityLevel
): string {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return "No specific configurations";
      case "Low":
        return "Password complexity rules, basic session timeouts";
      case "Moderate":
        return "RBAC policies, TLS 1.2+, encryption keys rotation every 180 days";
      case "High":
        return "MFA required, encryption key rotation every 90 days, privileged access controls";
      case "Very High":
        return "Zero-trust policies, HSM-managed keys, continuous authentication, behavioral monitoring";
      default:
        return "Standard security configurations";
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return "No specific configurations";
      case "Low":
        return "Basic input validation rules, error logging";
      case "Moderate":
        return "Comprehensive validation rules, checksums for critical data, change logs";
      case "High":
        return "Digital signature verification, cryptographic hashing, immutable audit logs";
      case "Very High":
        return "Blockchain consensus rules, formal verification policies, hardware integrity checks";
      default:
        return "Standard integrity configurations";
    }
  }
 
  // Default to availability
  switch (level) {
    case "None":
      return "No specific configurations";
    case "Low":
      return "Basic monitoring alerts, manual backup schedules";
    case "Moderate":
      return "Load balancer rules, daily backups, health check intervals";
    case "High":
      return "Automatic failover policies, real-time replication, RPO < 1 hour";
    case "Very High":
      return "Multi-site active-active configuration, continuous replication, RPO near-zero, RTO < 5 minutes";
    default:
      return "Standard availability configurations";
  }
}
 
/**
 * Gets default expertise requirements for a CIA component at a specific security level
 *
 * @param component - The CIA component
 * @param level - The security level
 * @returns Array of default expertise requirements
 */
export function getDefaultExpertise(
  component: string,
  level: SecurityLevel
): string[] {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return ["No specific expertise required"];
      case "Low":
        return ["Basic security knowledge", "Access control fundamentals"];
      case "Moderate":
        return [
          "Identity management",
          "Encryption technologies",
          "Authentication systems",
        ];
      case "High":
        return [
          "Advanced cryptography",
          "Identity and access management",
          "Security architecture",
          "Data protection",
        ];
      case "Very High":
        return [
          "Security architecture",
          "Advanced cryptography",
          "Zero-trust implementation",
          "Data protection specialization",
          "Hardware security",
        ];
      default:
        return ["General security knowledge"];
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return ["No specific expertise required"];
      case "Low":
        return ["Basic data validation", "Error handling"];
      case "Moderate":
        return [
          "Data validation techniques",
          "Database integrity",
          "Error handling",
        ];
      case "High":
        return [
          "Cryptographic verification",
          "Digital signatures",
          "Secure logging",
          "Change management",
        ];
      case "Very High":
        return [
          "Advanced cryptography",
          "Formal verification",
          "Distributed ledger technologies",
          "Immutable logging systems",
        ];
      default:
        return ["Data integrity fundamentals"];
    }
  }
 
  // Default to availability expertise
  switch (level) {
    case "None":
      return ["No specific expertise required"];
    case "Low":
      return ["Basic system monitoring", "Manual recovery procedures"];
    case "Moderate":
      return ["System redundancy", "Backup management", "Basic load balancing"];
    case "High":
      return [
        "High availability architecture",
        "Disaster recovery",
        "Advanced monitoring",
        "Automated failover",
      ];
    case "Very High":
      return [
        "Distributed systems",
        "Site reliability engineering",
        "Global load balancing",
        "Chaos engineering",
        "Real-time recovery systems",
      ];
    default:
      return ["System reliability fundamentals"];
  }
}