import { SecurityLevel } from "../types/cia";
import { StatusType } from "../types/common/StatusTypes";
/**
* Utility functions for handling security levels.
*
* ## Business Impact
* These functions play a crucial role in determining and normalizing security levels, which directly impacts the application's ability to manage and enforce security policies. 💼
*
* ## Compliance
* By providing consistent and accurate security level calculations, these functions help ensure that the application meets various compliance requirements and standards. 📜
*
* ## Risk Management
* The functions in this module contribute to risk management by providing a structured way to represent and analyze security levels, helping to identify and mitigate potential risks. ⚠️
*
* ## Value Creation
* The use of well-defined utility functions enhances the application's reliability and maintainability, leading to cost savings and efficiency improvements. 💡
*
* ## Stakeholder Benefits
* Clear and consistent utility functions benefit all stakeholders, including developers, security analysts, and business users, by providing a common understanding of key security concepts. 🤝
*/
/**
* Default security level used throughout the application
*/
export declare const DEFAULT_SECURITY_LEVEL: SecurityLevel;
/**
* Normalize any security level input to a valid SecurityLevel enum value
*
* Handles various input formats including case variations and null/undefined values.
* Provides a robust way to convert user input or API responses to valid SecurityLevel values.
*
* @param level - Input that might be a security level (can be string, SecurityLevel, null, or undefined)
* @returns A valid SecurityLevel enum value (defaults to 'Moderate' if invalid)
*
* @example
* ```typescript
* normalizeSecurityLevel('high') // 'High' (case normalization)
* normalizeSecurityLevel('VERY HIGH') // 'Very High' (case normalization)
* normalizeSecurityLevel(null) // 'Moderate' (default)
* normalizeSecurityLevel(undefined) // 'Moderate' (default)
* normalizeSecurityLevel('invalid') // 'Moderate' (default for invalid input)
* normalizeSecurityLevel('High') // 'High' (already valid)
* ```
*/
export declare function normalizeSecurityLevel(level?: string | SecurityLevel | null): SecurityLevel;
/**
* Get numeric value for a security level (0-4)
*
* Converts SecurityLevel enum values to numeric scores for comparison,
* calculation, and sorting operations. Returns 0 for invalid levels.
*
* @param level - Security level to convert (SecurityLevel or string)
* @returns Numeric value: None=0, Low=1, Moderate=2, High=3, Very High=4
*
* @example
* ```typescript
* getSecurityLevelValue('None') // 0
* getSecurityLevelValue('Low') // 1
* getSecurityLevelValue('Moderate') // 2
* getSecurityLevelValue('High') // 3
* getSecurityLevelValue('Very High') // 4
* getSecurityLevelValue('invalid') // 0 (invalid input)
*
* // Use for comparison
* const isHighEnough = getSecurityLevelValue(currentLevel) >= getSecurityLevelValue('High');
* ```
*/
export declare function getSecurityLevelValue(level: SecurityLevel | string): number;
/**
* Maps numeric values to security levels
*
* Converts numeric security scores back to SecurityLevel enum values.
* Useful for converting calculated scores or slider values to security levels.
* Values outside 0-4 range default to 'None'.
*
* @param value - Numeric value (0-4), where higher numbers indicate stronger security
* @returns The corresponding security level
*
* @example
* ```typescript
* getSecurityLevelFromValue(0) // 'None'
* getSecurityLevelFromValue(1) // 'Low'
* getSecurityLevelFromValue(2) // 'Moderate'
* getSecurityLevelFromValue(3) // 'High'
* getSecurityLevelFromValue(4) // 'Very High'
* getSecurityLevelFromValue(5) // 'None' (out of range)
* getSecurityLevelFromValue(-1) // 'None' (out of range)
*
* // Use with calculated average
* const avgValue = Math.round((val1 + val2 + val3) / 3);
* const overallLevel = getSecurityLevelFromValue(avgValue);
* ```
*/
export declare function getSecurityLevelFromValue(value: number): SecurityLevel;
/**
* Get risk level string from a security level
*
* Maps security levels to corresponding risk levels using an inverse relationship:
* higher security levels correlate with lower risk levels. Used for risk assessment
* and dashboard visualizations.
*
* @param level - Security level to assess
* @returns Corresponding risk level: Critical, High, Medium, Low, or Minimal
*
* @example
* ```typescript
* getRiskLevelFromSecurityLevel('None') // 'Critical'
* getRiskLevelFromSecurityLevel('Low') // 'High'
* getRiskLevelFromSecurityLevel('Moderate') // 'Medium'
* getRiskLevelFromSecurityLevel('High') // 'Low'
* getRiskLevelFromSecurityLevel('Very High') // 'Minimal'
*
* // Use in risk assessment
* const riskLevel = getRiskLevelFromSecurityLevel(currentSecurityLevel);
* const riskFormatted = formatRiskLevel(`${riskLevel} Risk`);
* ```
*/
export declare function getRiskLevelFromSecurityLevel(level: SecurityLevel): string;
/**
* Calculates the overall security level based on individual CIA components
*
* Computes a composite security level by averaging the numeric values of
* availability, integrity, and confidentiality levels, then rounding to
* the nearest security level. Provides a single metric for overall security posture.
*
* @param availabilityLevel - Availability security level
* @param integrityLevel - Integrity security level
* @param confidentialityLevel - Confidentiality security level
* @returns The overall security level (average of the three components, rounded)
*
* @example
* ```typescript
* // All equal - returns same level
* calculateOverallSecurityLevel('High', 'High', 'High') // 'High'
*
* // Mixed levels - returns average
* calculateOverallSecurityLevel('Low', 'Moderate', 'High') // 'Moderate'
* calculateOverallSecurityLevel('None', 'Low', 'Low') // 'Low'
*
* // Use for system-wide security assessment
* const overallLevel = calculateOverallSecurityLevel(
* availabilityLevel,
* integrityLevel,
* confidentialityLevel
* );
* console.log(`System security level: ${overallLevel}`);
* ```
*/
export declare function calculateOverallSecurityLevel(availabilityLevel: SecurityLevel, integrityLevel: SecurityLevel, confidentialityLevel: SecurityLevel): SecurityLevel;
/**
* Determine if a given set of security levels meets minimum requirements
*
* Validates that current security levels meet or exceed specified minimum
* requirements for all three CIA components. Returns true only if ALL
* requirements are met. Essential for compliance checking and gap analysis.
*
* @param availabilityLevel - Current availability security level
* @param integrityLevel - Current integrity security level
* @param confidentialityLevel - Current confidentiality security level
* @param minAvailability - Minimum required availability level
* @param minIntegrity - Minimum required integrity level
* @param minConfidentiality - Minimum required confidentiality level
* @returns true if all current levels meet or exceed minimum requirements
*
* @example
* ```typescript
* // All requirements met
* meetsSecurityRequirements(
* 'High', 'High', 'High', // Current levels
* 'Moderate', 'Moderate', 'Moderate' // Required levels
* ) // true
*
* // One requirement not met
* meetsSecurityRequirements(
* 'Low', 'High', 'High', // Current levels (availability too low)
* 'Moderate', 'Moderate', 'Moderate' // Required levels
* ) // false
*
* // Use for compliance validation
* const compliant = meetsSecurityRequirements(
* currentAvailability, currentIntegrity, currentConfidentiality,
* 'High', 'High', 'Moderate'
* );
* if (!compliant) {
* console.log('Security levels do not meet requirements');
* }
* ```
*/
export declare function meetsSecurityRequirements(availabilityLevel: SecurityLevel, integrityLevel: SecurityLevel, confidentialityLevel: SecurityLevel, minAvailability: SecurityLevel, minIntegrity: SecurityLevel, minConfidentiality: SecurityLevel): boolean;
/**
* Get the gap between current and required security levels
*
* Calculates the numeric difference between two security levels.
* Positive values indicate current level exceeds requirements,
* negative values indicate a gap that needs to be addressed.
*
* @param currentLevel - Current security level
* @param requiredLevel - Required/target security level
* @returns Number of levels gap (positive if current > required, negative if current < required)
*
* @example
* ```typescript
* getSecurityLevelGap('High', 'Moderate') // 1 (exceeds by 1 level)
* getSecurityLevelGap('Low', 'High') // -2 (falls short by 2 levels)
* getSecurityLevelGap('Moderate', 'Moderate') // 0 (meets exactly)
*
* // Use for gap analysis
* const gap = getSecurityLevelGap(currentLevel, requiredLevel);
* if (gap < 0) {
* console.log(`Need to increase security by ${Math.abs(gap)} level(s)`);
* } else if (gap > 0) {
* console.log(`Security exceeds requirements by ${gap} level(s)`);
* }
* ```
*/
export declare function getSecurityLevelGap(currentLevel: SecurityLevel, requiredLevel: SecurityLevel): number;
/**
* Get a set of recommended security levels that would meet compliance requirements
*
* @param currentAvailability - Current availability level
* @param currentIntegrity - Current integrity level
* @param currentConfidentiality - Current confidentiality level
* @param minAvailability - Minimum required availability level
* @param minIntegrity - Minimum required integrity level
* @param minConfidentiality - Minimum required confidentiality level
* @returns Recommended security levels
*/
export declare function getRecommendedSecurityLevels(currentAvailability: SecurityLevel, currentIntegrity: SecurityLevel, currentConfidentiality: SecurityLevel, minAvailability: SecurityLevel, minIntegrity: SecurityLevel, minConfidentiality: SecurityLevel): {
availability: SecurityLevel;
integrity: SecurityLevel;
confidentiality: SecurityLevel;
};
/**
* Provides a numerical representation of security levels for UI presentation
*
* Converts security levels to percentage strings for use in progress bars,
* gauges, and other visual indicators. Maps 0-4 scale to 0-100% range
* in 25% increments.
*
* @param level - The security level (string or SecurityLevel enum)
* @returns A percentage string (0%, 25%, 50%, 75%, or 100%)
*
* @example
* ```typescript
* getSecurityLevelPercentage('None') // "0%"
* getSecurityLevelPercentage('Low') // "25%"
* getSecurityLevelPercentage('Moderate') // "50%"
* getSecurityLevelPercentage('High') // "75%"
* getSecurityLevelPercentage('Very High') // "100%"
*
* // Use in UI components
*
* ```
*/
export declare function getSecurityLevelPercentage(level: SecurityLevel | string): string;
/**
* Determines the appropriate CSS classes for displaying a security level
*
* Returns Tailwind CSS classes with color coding that visually represents
* security level severity. Includes dark mode support. Red=None, Yellow=Low,
* Blue=Moderate, Green=High, Purple=Very High.
*
* @param level - The security level (string or SecurityLevel enum)
* @returns CSS class string for styling the security level badge/indicator
*
* @example
* ```typescript
* getSecurityLevelClass('None')
* // "bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-300"
*
* getSecurityLevelClass('High')
* // "bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-300"
*
* // Use in components
*
* {level}
*
* ```
*/
export declare function getSecurityLevelClass(level: string | SecurityLevel): string;
/**
* Map a security level to a status badge variant
* @param level The security level string
* @returns A status badge variant
*/
export declare function getSecurityLevelBadgeVariant(level: string): "info" | "success" | "warning" | "error" | "neutral" | "purple";
/**
* Check if a string is a valid security level
*
* Type guard function that validates whether a value is a valid SecurityLevel.
* Useful for runtime type checking and validation of user input or API responses.
*
* @param value - Value to check (can be any type)
* @returns Type predicate indicating if value is SecurityLevel
*
* @example
* ```typescript
* if (isSecurityLevel(userInput)) {
* // TypeScript knows userInput is SecurityLevel here
* const level: SecurityLevel = userInput;
* console.log(`Valid security level: ${level}`);
* }
*
* isSecurityLevel('High') // true
* isSecurityLevel('Invalid') // false
* isSecurityLevel(123) // false
* isSecurityLevel(null) // false
* ```
*/
export declare function isSecurityLevel(value: unknown): value is SecurityLevel;
/**
* Convert string to security level, with fallback
*
* @param value - Value to convert
* @param fallback - Fallback level if invalid
* @returns Valid security level
*/
export declare function asSecurityLevel(value: string, fallback?: SecurityLevel): SecurityLevel;
/**
* Get security level description
*
* @param level - Security level
* @returns Description of the security level
*/
export declare function getSecurityLevelDescription(level: SecurityLevel): string;
/**
* Determine if a security level meets compliance requirements for a specific framework
*
* Validates that a security level meets the minimum requirements defined for
* common compliance frameworks (SOC 2, ISO 27001, PCI-DSS, HIPAA, NIST, GDPR, CCPA).
* Returns true if the level meets or exceeds the framework's minimum requirement.
*
* @param level - Security level to validate
* @param framework - Compliance framework name (e.g., 'SOC2', 'PCI-DSS', 'HIPAA')
* @returns true if the security level meets the framework's minimum requirements
*
* @example
* ```typescript
* meetsComplianceRequirements('High', 'PCI-DSS') // true (PCI-DSS requires High)
* meetsComplianceRequirements('Moderate', 'PCI-DSS') // false (needs High)
* meetsComplianceRequirements('Moderate', 'SOC2') // true (SOC2 requires Moderate)
* meetsComplianceRequirements('High', 'GDPR') // true (exceeds Moderate requirement)
*
* // Validate against multiple frameworks
* const frameworks = ['SOC2', 'ISO27001', 'GDPR'];
* const allMet = frameworks.every(f =>
* meetsComplianceRequirements(currentLevel, f)
* );
* ```
*/
export declare function meetsComplianceRequirements(level: SecurityLevel, framework: string): boolean;
/**
* Get security icon for a security level
*
* @param level - Security level
* @returns Icon representing the security level
*/
export declare function getSecurityIcon(level: SecurityLevel): string;
/**
* Get recommended security level based on data sensitivity
*
* @param dataSensitivity - Data sensitivity level (1-5)
* @returns Recommended security level
*/
export declare function getRecommendedSecurityLevel(dataSensitivity: number): SecurityLevel;
/**
* Format a security level string consistently
*
* @param level - Level string to format
* @returns Formatted security level or original string
*/
export declare function formatSecurityLevel(level?: string): SecurityLevel | string;
/**
* Converts a security level or risk level string to the appropriate StatusType
*
* @param level - The security or risk level to convert
* @returns The appropriate StatusType for the given level
*/
export declare const getStatusVariant: (level: string) => StatusType;
//# sourceMappingURL=securityLevelUtils.d.ts.map