UNPKG

cloud-report

Version:

Collects and analyzes cloud resources

51 lines (50 loc) 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../../../types"); const base_1 = require("../../base"); class DeletionProtectionEnabledAnalyzer extends base_1.BaseAnalyzer { analyze(params, fullReport) { const allElbsAttributes = params.elb_attributes; if (!allElbsAttributes) { return undefined; } const deletion_protection_enabled = { type: types_1.CheckAnalysisType.Security }; deletion_protection_enabled.what = "Is deletion protection enabled for Load balancers?"; deletion_protection_enabled.why = `Deletion protection should be enabled otherwise if you delete load balancer accidentally then it gets deleted permanently`; deletion_protection_enabled.recommendation = "Recommended to enable deletion protection for all load balancers"; deletion_protection_enabled.benchmark = ['all']; const allRegionsAnalysis = {}; for (const region in allElbsAttributes) { const regionElbsAttributes = allElbsAttributes[region]; allRegionsAnalysis[region] = []; for (const elbName in regionElbsAttributes) { const elbAttributes = regionElbsAttributes[elbName]; const elb_analysis = {}; elb_analysis.resource = { name: elbName, attributes: elbAttributes }; elb_analysis.resourceSummary = { name: "LoadBalancer", value: elbName, }; if (this.isAccessLogsEnabled(elbAttributes)) { elb_analysis.severity = types_1.SeverityStatus.Good; elb_analysis.message = "Deletion protection is enabled"; } else { elb_analysis.severity = types_1.SeverityStatus.Failure; elb_analysis.message = "Deletion protection is not enabled"; elb_analysis.action = "Enable Deletion protection"; } allRegionsAnalysis[region].push(elb_analysis); } } deletion_protection_enabled.regions = allRegionsAnalysis; return { deletion_protection_enabled }; } isAccessLogsEnabled(elbAttributes) { return elbAttributes && elbAttributes.some((attribute) => { return attribute.Key === "deletion_protection.enabled" && attribute.Value === "true"; }); } } exports.DeletionProtectionEnabledAnalyzer = DeletionProtectionEnabledAnalyzer;