@csermet/multiprovider
Version:
cloud-graph provider plugin for AWS used to fetch AWS cloud data.
71 lines (70 loc) • 4.18 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sdk_1 = require("@cloudgraph/sdk");
const lodash_1 = require("lodash");
const translations_1 = __importDefault(require("../../properties/translations"));
const format_1 = require("../../utils/format");
exports.default = ({ service: rawData, region, account, }) => {
const { id, Name: name, S3BucketName: s3BucketName, S3KeyPrefix: s3KeyPrefix, IncludeGlobalServiceEvents: includeGlobalServiceEvents, IsMultiRegionTrail: isMultiRegionTrail, HomeRegion: homeRegion, TrailARN: arn, LogFileValidationEnabled: logFileValidationEnabled, CloudWatchLogsLogGroupArn: cloudWatchLogsLogGroupArn, CloudWatchLogsRoleArn: cloudWatchLogsRoleArn, KmsKeyId: kmsKeyId, HasCustomEventSelectors: hasCustomEventSelectors, HasInsightSelectors: hasInsightSelectors, IsOrganizationTrail: isOrganizationTrail, TrailStatus: { LatestCloudWatchLogsDeliveryTime: latestCloudWatchLogsDeliveryTime, IsLogging: isLogging, LatestDeliveryTime: latestDeliveryTime, LatestNotificationTime: latestNotificationTime, StartLoggingTime: startLoggingTime, LatestDigestDeliveryTime: latestDigestDeliveryTime, LatestDeliveryAttemptTime: latestDeliveryAttemptTime, LatestNotificationAttemptTime: latestNotificationAttemptTime, LatestNotificationAttemptSucceeded: latestNotificationAttemptSucceeded, LatestDeliveryAttemptSucceeded: latestDeliveryAttemptSucceeded, TimeLoggingStarted: timeLoggingStarted, TimeLoggingStopped: timeLoggingStopped, } = {}, EventSelectors, Tags, } = rawData;
let eventSelectors = [];
if (!lodash_1.isEmpty(EventSelectors)) {
eventSelectors = EventSelectors.map(({ ReadWriteType, IncludeManagementEvents, DataResources }) => ({
id: sdk_1.generateUniqueId({
arn,
ReadWriteType,
IncludeManagementEvents,
DataResources,
}),
readWriteType: ReadWriteType,
includeManagementEvents: IncludeManagementEvents,
dataResources: DataResources?.map(({ Type, Values }) => ({
id: sdk_1.generateUniqueId({
arn,
Type,
Values,
}),
type: Type,
values: Values,
})) || [],
}));
}
const cloudTrail = {
id,
arn,
accountId: account,
name,
s3BucketName,
s3KeyPrefix,
includeGlobalServiceEvents: includeGlobalServiceEvents ? translations_1.default.yes : translations_1.default.no,
isMultiRegionTrail: isMultiRegionTrail ? translations_1.default.yes : translations_1.default.no,
homeRegion,
logFileValidationEnabled: logFileValidationEnabled ? translations_1.default.yes : translations_1.default.no,
cloudWatchLogsLogGroupArn,
cloudWatchLogsRoleArn,
kmsKeyId,
hasCustomEventSelectors: hasCustomEventSelectors ? translations_1.default.yes : translations_1.default.no,
hasInsightSelectors: hasInsightSelectors ? translations_1.default.yes : translations_1.default.no,
isOrganizationTrail: isOrganizationTrail ? translations_1.default.yes : translations_1.default.no,
status: {
isLogging,
latestDeliveryTime: latestDeliveryTime?.toISOString() || '',
latestNotificationTime: latestNotificationTime?.toISOString() || '',
startLoggingTime: startLoggingTime?.toISOString() || '',
latestDigestDeliveryTime: latestDigestDeliveryTime?.toISOString() || '',
latestCloudWatchLogsDeliveryTime: latestCloudWatchLogsDeliveryTime?.toISOString() || '',
latestDeliveryAttemptTime,
latestNotificationAttemptTime,
latestNotificationAttemptSucceeded,
latestDeliveryAttemptSucceeded,
timeLoggingStarted,
timeLoggingStopped,
},
eventSelectors,
tags: format_1.formatTagsFromMap(Tags),
region,
};
return cloudTrail;
};