UNPKG

cloud-report

Version:

Collects and analyzes cloud resources

53 lines (52 loc) 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../../../types"); const base_1 = require("../../base"); class FlowLogsEnabledAnalyzer extends base_1.BaseAnalyzer { analyze(params, fullReport) { const allFlowLogs = params.flow_logs; const allVpcs = params.vpcs; if (!allFlowLogs || !allVpcs) { return undefined; } const flow_logs_enabled = { type: types_1.CheckAnalysisType.Security }; flow_logs_enabled.what = "Is flow logs enabled for vpc?"; flow_logs_enabled.why = "VPC flow logs tells about the request patterns and helps to detect security threats."; flow_logs_enabled.recommendation = "Recommended to enable flow logs for vpcs."; flow_logs_enabled.benchmark = ['all']; const allRegionsAnalysis = {}; for (const region in allVpcs) { const regionVpcs = allVpcs[region]; const regionFlowLogs = allFlowLogs[region]; allRegionsAnalysis[region] = []; for (const vpc of regionVpcs) { if (vpc.IsDefault) { continue; } const flow_log_analysis = {}; flow_log_analysis.resource = this.getVpcFlowLogs(regionFlowLogs, vpc.VpcId); flow_log_analysis.resourceSummary = { name: "Vpc", value: vpc.VpcId, }; if (flow_log_analysis.resource.length) { flow_log_analysis.severity = types_1.SeverityStatus.Good; flow_log_analysis.message = "VPC flow logs are enabled."; } else { flow_log_analysis.severity = types_1.SeverityStatus.Failure; flow_log_analysis.message = "VPC flow logs are not enabled."; flow_log_analysis.action = "Enable vpc flow logs for debugging access requests to the VPC."; } allRegionsAnalysis[region].push(flow_log_analysis); } } flow_logs_enabled.regions = allRegionsAnalysis; return { flow_logs_enabled }; } getVpcFlowLogs(flowLogs, vpcId) { return flowLogs.filter((flowLog) => { return flowLog.ResourceId === vpcId && flowLog.FlowLogStatus === "ACTIVE"; }); } } exports.FlowLogsEnabledAnalyzer = FlowLogsEnabledAnalyzer;