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 | 13x 13x 13x 13x 13x 10x 13x 5x 13x 13x 13x 13x 13x 13x 13x 6x 6x 6x 5x 4x 2x 1x 13x 6x 6x 13x 13x | /**
* Central export of utility functions for CIA Compliance Manager
*
* This index file provides organized exports of all utility functions
* to ensure they're properly accessible throughout the application.
*
* @packageDocumentation
*/
import {
BUSINESS_IMPACT_CATEGORIES,
RISK_LEVELS,
} from "../constants/riskConstants";
import { calculateRiskLevel } from "../types/cia.utility";
import { SecurityLevel } from "../types/cia";
import * as colorUtils from "./colorUtils";
import * as costUtils from "./costCalculationUtils";
import * as errorUtils from "./errorUtils";
import * as formatUtils from "./formatUtils";
import * as levelUtils from "./levelValuesUtils";
import * as riskUtils from "./riskUtils";
import * as securityUtils from "./securityLevelUtils";
import * as typeGuards from "./typeGuards";
import * as widgetUtils from "./widgetHelpers";
import * as accessibilityUtils from "./accessibility";
export const {
ARIA_ROLES,
ARIA_LIVE,
getSecurityLevelAriaLabel,
getWidgetAriaDescription,
getTabAriaProps,
getTabPanelAriaProps,
getButtonAriaProps,
getSelectAriaProps,
getProgressAriaProps,
getStatusAriaProps,
getChartAriaProps,
getTabIndex,
handleArrowKeyNavigation,
getMetricAccessibleName,
announceToScreenReader,
meetsContrastRequirement,
} = accessibilityUtils;
export const { getSecurityLevelColorClass } = colorUtils;
export const getColorForRiskLevel =
colorUtils.getSecurityLevelColorClass ||
((_level: string) => `text-gray-600`);
export const getComplianceStatusColor =
colorUtils.getSecurityLevelColorClass ||
((_status: string) => `text-gray-600`);
export const getProgressColor = (progress: number) =>
progress > 75
? "text-green-500"
: progress > 50
? "text-blue-500"
: progress > 25
? "text-yellow-500"
: "text-red-500";
export const getSeverityColor = (severity: string) =>
severity === "high"
? "text-red-500"
: severity === "medium"
? "text-yellow-500"
: "text-green-500";
export const {
calculateImplementationCost,
calculateTotalSecurityCost,
calculateSecurityROI,
getRecommendedBudgetAllocation,
} = costUtils;
export type { CostResult } from "./costCalculationUtils";
export const {
formatBudgetPercentage,
formatCurrency,
formatDate,
formatLargeNumber,
formatNumber,
formatNumberWithDecimals,
formatPercentage,
formatRiskLevel,
formatTimeframe,
formatUptime,
toTitleCase,
} = formatUtils;
export const {
calculateOverallSecurityLevel: calculateOverallSecurityLevelFromValues,
compareSecurityLevels,
getNormalizedSecurityValue,
getSecurityLevelValue: getNumericSecurityLevelValue,
getSecurityLevelFromValue,
SECURITY_LEVEL_VALUES,
} = levelUtils;
export const {
calculateCombinedRiskLevel,
calculateRiskScore,
getFormattedRiskLevel,
getRiskBadgeVariant,
getRiskLevelFromSecurityLevel,
getRiskScoreFromSecurityLevel,
getRiskSeverityDescription,
getStatusBadgeForRiskLevel,
parseRiskLevel,
} = riskUtils;
export const {
calculateOverallSecurityLevel,
asSecurityLevel,
formatSecurityLevel: formatSecurityLevelString,
getRecommendedSecurityLevel,
getSecurityIcon,
getSecurityLevelBadgeVariant,
getSecurityLevelClass,
getSecurityLevelDescription,
getSecurityLevelPercentage,
getSecurityLevelValue,
isSecurityLevel,
meetsComplianceRequirements,
normalizeSecurityLevel,
} = securityUtils;
export const {
formatSecurityLevel: formatSecurityLevelFromWidget,
getWidgetColumnSpan,
getWidgetRowSpan,
handleWidgetError,
KeyValuePair,
RiskLevelKeyValue,
sanitizeWidgetId,
SecurityLevelBadge,
WidgetEmptyState,
WidgetError,
WidgetLoading,
} = widgetUtils;
export const calculateWidgetRiskLevel = (
availabilityLevel: SecurityLevel,
integrityLevel: SecurityLevel,
confidentialityLevel: SecurityLevel
) => {
const levels: Record<string, number> = {
None: 0,
Low: 1,
Moderate: 2,
High: 3,
"Very High": 4,
};
const avgLevel =
(levels[availabilityLevel] +
levels[integrityLevel] +
levels[confidentialityLevel]) /
3;
if (avgLevel < 1) return "Critical";
if (avgLevel < 2) return "High";
if (avgLevel < 3) return "Medium";
if (avgLevel < 4) return "Low";
return "Minimal";
};
export const formatSecurityMetric = (
value: number,
prefix = "",
suffix = ""
): string => {
const formattedValue = new Intl.NumberFormat().format(value);
return `${prefix}${formattedValue}${suffix}`;
};
export const {
ensureArray,
extractSecurityLevels,
hasProperty,
hasTagValue,
isBusinessImpactCategory,
isBusinessImpactDetails,
isComplianceFramework,
isComplianceFrameworkName,
isComplianceFrameworkObject,
isComplianceStatus,
isNumber,
isObject,
isRiskLevel,
isROIEstimate,
isROIMetricDetails,
isROIMetrics,
isSecurityProfile,
isSecurityResource,
isString,
isWidget,
isWidgetConfig,
isWidgetProps,
isWidgetType,
safeAccess,
safeNumberConversion,
hasWidgetProps,
} = typeGuards;
export const { toErrorObject, formatError } = errorUtils;
export { BUSINESS_IMPACT_CATEGORIES, calculateRiskLevel, RISK_LEVELS };
export * from "./keyboardUtils";
export { cn, WidgetClasses } from "./tailwindClassHelpers";
export type { WidgetClassKey } from "./tailwindClassHelpers";
|