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 | 233x 233x 233x 233x 3495x 24x 24x 24x 24x 24x 24x 24x 456x 456x 127x 329x 128x 201x 263x 263x 263x 614x 263x 263x 127x 263x 263x 15x 15x 15x 15x 15x 13x 2x 2x 2x 2x | import defaultResources from "../data/securityResources";
import { SecurityLevel } from "../types/cia";
import { CIAComponentType, CIADataProvider } from "../types/cia-services";
import { EnhancedSecurityResource, SecurityResource } from "../types/securityResources";
import { ISecurityResourceService } from "../types/services";
import { BaseService } from "./BaseService";
/**
* Service for security resource recommendations
*
* ## Business Perspective
*
* Provides curated security resources, best practices, and implementation
* guidance tailored to specific security levels and CIA components. Helps
* organizations find relevant documentation, tools, and frameworks to
* implement effective security controls. 📚
*
* @implements {ISecurityResourceService}
*/
export class SecurityResourceService extends BaseService implements ISecurityResourceService {
/**
* Service name for identification
*/
public readonly name: string = 'SecurityResourceService';
/**
* Processed and enhanced security resources
*/
private resources: EnhancedSecurityResource[];
/**
* Create a new SecurityResourceService instance
*
* @param dataProvider - Data provider for CIA options and security data
* @throws {ServiceError} If dataProvider is not provided
*/
constructor(dataProvider: CIADataProvider) {
super(dataProvider);
this.resources = this.processResources(defaultResources);
}
/**
* Process resources to add score and ensure required properties
*
* @param resources - Raw security resources to process
* @returns Enhanced security resources with relevance scores
*/
private processResources(
resources: SecurityResource[]
): EnhancedSecurityResource[] {
return resources.map(
(resource) =>
({
...resource,
relevance: resource.priority || 50,
score: resource.priority || 50,
} as EnhancedSecurityResource)
);
}
/**
* Get security resources based on component and level
*
* Returns a curated list of security resources tailored to the specific
* CIA component and security level, including documentation, tools,
* frameworks, and best practices.
*
* @param component - CIA component type or 'general' for general resources
* @param level - Security level
* @returns Array of relevant security resources sorted by relevance
* @throws {ServiceError} If component or level is invalid
*
* @example
* ```typescript
* const resources = service.getSecurityResources('confidentiality', 'High');
* console.log(`Found ${resources.length} resources`);
* resources.forEach(r => console.log(`- ${r.title}: ${r.url}`));
* ```
*/
public getSecurityResources(
component: CIAComponentType | "general" | "all",
level: SecurityLevel
): EnhancedSecurityResource[] {
Eif (component !== "general" && component !== "all") {
this.validateComponent(component as CIAComponentType);
}
this.validateSecurityLevel(level);
const fallbackResource: EnhancedSecurityResource = {
id: `fallback-${component}`,
title: `Basic security guidance for ${component}`,
description: `Start with these resources to implement ${component} security controls`,
url: "https://www.nist.gov/cyberframework",
type: component === "all" ? "general" : (component as CIAComponentType),
relevance: 100,
score: 100,
tags: ["beginner", "basics"],
category: "documentation",
source: "NIST",
};
const componentSpecificResources: Record<string, EnhancedSecurityResource> =
{
availability: {
id: "avail-resource",
title: "Availability Best Practices",
description: "Guidance for implementing availability controls",
url: "https://example.com/availability",
type: "availability",
relevance: 90,
score: 90,
tags: ["availability", "uptime"],
category: "best_practices",
source: "NIST",
},
integrity: {
id: "integrity-resource",
title: "Integrity Guidelines",
description: "Guidance for implementing integrity controls",
url: "https://example.com/integrity",
type: "integrity",
relevance: 90,
score: 90,
tags: ["integrity", "validation"],
category: "best_practices",
source: "NIST",
},
confidentiality: {
id: "confidentiality-resource",
title: "Confidentiality Controls",
description: "Guidance for implementing confidentiality controls",
url: "https://example.com/confidentiality",
type: "confidentiality",
relevance: 90,
score: 90,
tags: ["confidentiality", "encryption"],
category: "best_practices",
source: "NIST",
},
};
const allResources = [
...this.resources,
fallbackResource,
...Object.values(componentSpecificResources),
];
return allResources
.filter((resource) => {
Iif (component === "all") {
return true;
}
if (resource.type === component) {
return true;
}
if (resource.components && resource.components.includes(component)) {
return true;
}
return resource.type === "general";
})
.filter((resource) => {
Eif (!resource.relevantLevels || resource.relevantLevels.length === 0) {
return true;
}
return resource.relevantLevels.includes(level);
})
.map((resource) => ({
...resource,
relevance: this.calculateRelevance(resource, component, level),
}))
.sort((a, b) => b.relevance - a.relevance);
}
/**
* Calculate resource relevance score
*/
private calculateRelevance(
resource: EnhancedSecurityResource,
component: CIAComponentType | "general" | "all",
level: SecurityLevel
): number {
let score = resource.priority || 50;
if (resource.type === component) {
score += 20;
}
Iif (resource.relevantLevels && resource.relevantLevels.includes(level)) {
score += 20;
}
return score;
}
/**
* Get value points for a security level
*
* Returns a list of key value propositions and benefits for implementing
* security controls at the specified security level. Helps justify
* security investments to stakeholders.
*
* @param level - Security level
* @returns Array of value point strings describing the benefits and characteristics
* @throws {ServiceError} If level is invalid
*
* @example
* ```typescript
* const valuePoints = service.getValuePoints('High');
* console.log('Benefits of High security:');
* valuePoints.forEach(point => console.log(`- ${point}`));
* ```
*/
public getValuePoints(level: SecurityLevel): string[] {
this.validateSecurityLevel(level);
Eif (this.dataProvider.getDefaultValuePoints) {
try {
const valuePoints = this.dataProvider.getDefaultValuePoints(level);
if (valuePoints && valuePoints.length > 0) {
return valuePoints;
}
} catch (error) {
this.logOperation('warn', 'Error fetching custom value points', {
method: 'getValuePoints',
level,
error: error instanceof Error ? error.message : String(error)
});
}
}
Eif (level === "None") {
return [
"No security value",
"Suitable only for non-sensitive public information",
"High vulnerability to security incidents",
"No protection against threats",
"Does not meet any compliance requirements",
];
}
return [
`Provides ${level.toLowerCase()} level of protection`,
`Meets ${
level === "High" || level === "Very High" ? "advanced" : "basic"
} security requirements`,
];
}
}
/**
* Create SecurityResourceService with the provided data provider
*/
export function createSecurityResourceService(
dataProvider: CIADataProvider
): SecurityResourceService {
Iif (!dataProvider) {
const defaultProvider: CIADataProvider = {
availabilityOptions: {},
integrityOptions: {},
confidentialityOptions: {},
roiEstimates: {
NONE: { returnRate: "0%", description: "No ROI", value: "0%" },
LOW: { returnRate: "50%", description: "Low ROI", value: "50%" },
MODERATE: {
returnRate: "150%",
description: "Moderate ROI",
value: "150%",
},
HIGH: { returnRate: "250%", description: "High ROI", value: "250%" },
VERY_HIGH: {
returnRate: "400%",
description: "Very High ROI",
value: "400%",
},
},
} as CIADataProvider;
return new SecurityResourceService(defaultProvider);
}
return new SecurityResourceService(dataProvider);
}
|