All files / src/utils implementationUtils.ts

75.67% Statements 28/37
73.52% Branches 25/34
100% Functions 3/3
75.67% Lines 28/37

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                                                                                                                                      57x 19x   1x       16x   1x   1x           38x 19x   1x       15x   2x   1x             19x   1x   1x   15x   1x   1x                         29x   2x       25x   1x   1x                         29x   2x       24x   2x   1x          
import { SecurityLevel } from "../types/cia";
 
/**
 * Implementation planning and guidance utilities for security controls
 * 
 * Provides human-readable implementation descriptions, validation levels,
 * and uptime targets for different security levels across CIA components.
 * Helps stakeholders understand practical implementation requirements.
 * 
 * @example
 * ```typescript
 * import { 
 *   getImplementationDescription,
 *   getIntegrityValidationLevel,
 *   getAvailabilityUptimeTarget
 * } from './implementationUtils';
 * 
 * // Get implementation guidance
 * const desc = getImplementationDescription('confidentiality', 'High');
 * // 'Comprehensive encryption and access controls'
 * 
 * // Get validation level
 * const validation = getIntegrityValidationLevel('High');
 * // 'Strongly Validated'
 * 
 * // Get uptime target
 * const uptime = getAvailabilityUptimeTarget('Very High');
 * // '99.99%'
 * ```
 */
 
/**
 * Gets implementation description for a CIA component at a specific security level
 * 
 * Provides actionable implementation guidance tailored to each security level
 * and CIA component. Helps teams understand what controls to implement.
 *
 * @param component - The CIA component (confidentiality, integrity, availability)
 * @param level - The security level
 * @returns Human-readable implementation description
 * 
 * @example
 * ```typescript
 * // Confidentiality implementations
 * getImplementationDescription('confidentiality', 'None')
 * // 'No data protection controls needed'
 * 
 * getImplementationDescription('confidentiality', 'High')
 * // 'Comprehensive encryption and access controls'
 * 
 * // Integrity implementations
 * getImplementationDescription('integrity', 'Moderate')
 * // 'Data validation and cryptographic checksums'
 * 
 * // Availability implementations
 * getImplementationDescription('availability', 'Very High')
 * // 'Multi-site redundancy and continuous availability'
 * 
 * // Usage in widget display
 * const description = getImplementationDescription(component, selectedLevel);
 * <ImplementationGuide description={description} />
 * ```
 */
export function getImplementationDescription(
  component: "confidentiality" | "integrity" | "availability",
  level: SecurityLevel
): string {
  if (component === "confidentiality") {
    switch (level) {
      case "None":
        return "No data protection controls needed";
      case "Low":
        return "Basic access controls and authentication";
      case "Moderate":
        return "Role-based access and encryption for sensitive data";
      case "High":
        return "Comprehensive encryption and access controls";
      case "Very High":
        return "Maximum protection with advanced encryption and zero-trust";
      default:
        return "Standard data protection controls";
    }
  }
 
  if (component === "integrity") {
    switch (level) {
      case "None":
        return "No data validation controls needed";
      case "Low":
        return "Basic input validation and error checking";
      case "Moderate":
        return "Data validation and cryptographic checksums";
      case "High":
        return "Digital signatures and strong validation";
      case "Very High":
        return "Formal verification and immutable audit trails";
      default:
        return "Standard data integrity controls";
    }
  }
 
  // availability
  switch (level) {
    case "None":
      return "No uptime guarantees or redundancy";
    case "Low":
      return "Basic backup and recovery procedures";
    case "Moderate":
      return "Redundant components and standard backups";
    case "High":
      return "High availability clustering and failover";
    case "Very High":
      return "Multi-site redundancy and continuous availability";
    default:
      return "Standard availability controls";
  }
}
 
/**
 * Gets validation level text for integrity security level
 *
 * @param level - The security level
 * @returns Human-readable validation level
 */
export function getIntegrityValidationLevel(level: SecurityLevel): string {
  switch (level) {
    case "None":
      return "Unverified";
    case "Low":
      return "Basic Validation";
    case "Moderate":
      return "Validated";
    case "High":
      return "Strongly Validated";
    case "Very High":
      return "Formally Verified";
    default:
      return "Unknown";
  }
}
 
/**
 * Gets uptime target text for availability security level
 *
 * @param level - The security level
 * @returns Human-readable uptime target
 */
export function getAvailabilityUptimeTarget(level: SecurityLevel): string {
  switch (level) {
    case "None":
      return "No guarantee";
    case "Low":
      return "95%";
    case "Moderate":
      return "99%";
    case "High":
      return "99.9%";
    case "Very High":
      return "99.999%";
    default:
      return "Unknown";
  }
}