Socket
Socket
Sign inDemoInstall

@cloudchipr/cloudchipr-engine

Package Overview
Dependencies
Maintainers
4
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudchipr/cloudchipr-engine - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

2

lib/adapters/aws/aws-shell-engine-adapter.js

@@ -391,3 +391,3 @@ "use strict";

.map(function (rdsResponseItemJson) {
return new rds_1.Rds(rdsResponseItemJson.DBInstanceIdentifier, rdsResponseItemJson.DBInstanceClass, rdsResponseItemJson.StorageType, metrics_helper_1.MetricsHelper.getDatabaseConnections(rdsResponseItemJson), metrics_helper_1.MetricsHelper.getDatabaseIOPS(rdsResponseItemJson), rdsResponseItemJson.Engine, rdsResponseItemJson.MultiAZ, rdsResponseItemJson.InstanceCreateTime, rdsResponseItemJson.AvailabilityZone, rdsResponseItemJson.DBInstanceStatus, true, '', undefined, tags_helper_1.TagsHelper.getNameTagValue(rdsResponseItemJson.Tags), [], rdsResponseItemJson.C8rAccount);
return new rds_1.Rds(rdsResponseItemJson.DBInstanceIdentifier, rdsResponseItemJson.DBInstanceClass, rdsResponseItemJson.StorageType, metrics_helper_1.MetricsHelper.getDatabaseConnections(rdsResponseItemJson), metrics_helper_1.MetricsHelper.getDatabaseIOPS(rdsResponseItemJson), rdsResponseItemJson.Engine, rdsResponseItemJson.MultiAZ, rdsResponseItemJson.InstanceCreateTime, rdsResponseItemJson.AvailabilityZone, rdsResponseItemJson.DBInstanceStatus, true, '', undefined, undefined, undefined, tags_helper_1.TagsHelper.getNameTagValue(rdsResponseItemJson.Tags), [], rdsResponseItemJson.C8rAccount);
});

@@ -394,0 +394,0 @@ response = new response_1.Response(rdsItems);

@@ -12,2 +12,4 @@ import { Rds } from '../../../domain/types/aws/rds';

private formatCollectResponse;
private formatInstancesResponse;
private formatClustersResponse;
private putAdditionalData;

@@ -18,4 +20,5 @@ private formatMetricsResponse;

private static getDescribeDBInstancesCommand;
private static getDescribeDBClustersCommand;
private static getPatchCommand;
private static getMetricStatisticsCommand;
}

@@ -17,2 +17,13 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -54,2 +65,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -109,2 +129,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

promises.push(this.getClient(region).send(AwsRdsClient.getDescribeDBInstancesCommand()));
promises.push(this.getClient(region).send(AwsRdsClient.getDescribeDBClustersCommand()));
}

@@ -134,3 +155,4 @@ return [4 /*yield*/, Promise.all(promises)];

return new Promise(function (resolve, reject) {
_this.getClient(resource.region).send(AwsRdsClient.getPatchCommand(resource.id, resource.action, !!metadata.snapshot))
// @ts-ignore
_this.getClient(resource.region).send(AwsRdsClient.getPatchCommand(resource.id, resource.action, !!metadata.snapshot, metadata.cluster))
.then(function () { return resolve(resource.id); })

@@ -146,16 +168,46 @@ .catch(function (e) {

var data = [];
var clusters = {};
response.forEach(function (res) {
if (!Array.isArray(res.DBInstances) || res.DBInstances.length === 0) {
if ('DBInstances' in res && Array.isArray(res.DBInstances)) {
data = __spreadArray(__spreadArray([], data, true), _this.formatInstancesResponse(res.DBInstances), true);
}
else if ('DBClusters' in res && Array.isArray(res.DBClusters)) {
clusters = __assign(__assign({}, clusters), _this.formatClustersResponse(res.DBClusters));
}
});
return data.reduce(function (pv, cv) {
if (!cv.cluster) {
pv.push(cv);
}
else if (cv.cluster in clusters && clusters[cv.cluster].primaryNode === cv.id) {
cv.nodesCount = clusters[cv.cluster].nodesCount;
pv.push(cv);
}
return pv;
}, []);
};
AwsRdsClient.prototype.formatInstancesResponse = function (response) {
var _this = this;
var data = [];
response.forEach(function (db) {
var _a;
if (!_this.ENGINE_WHITELIST.includes(db.Engine || '') || _this.STATUS_BLACKLIST.includes(db.DBInstanceStatus || '')) {
return;
}
res.DBInstances.forEach(function (db) {
var _a;
if (!_this.ENGINE_WHITELIST.includes(db.Engine || '') || _this.STATUS_BLACKLIST.includes(db.DBInstanceStatus || '')) {
return;
}
data.push(new rds_1.Rds(db.DBInstanceIdentifier || '', db.DBInstanceClass || '', db.StorageType || '', new metric_1.Metric(0, statistics_1.Statistics.Average, 'test'), new metric_1.Metric(0, statistics_1.Statistics.Average, 'test'), db.Engine || '', db.DBClusterIdentifier ? true : (db.MultiAZ || false), ((_a = db.InstanceCreateTime) === null || _a === void 0 ? void 0 : _a.toISOString()) || '', db.AvailabilityZone || '', db.DBInstanceStatus || '', db.DBInstanceStatus === 'stopped', db.DBClusterIdentifier ? 'Multi-AZ (readable standbys)' : (db.MultiAZ ? 'Multi-AZ' : 'Single-AZ'), undefined, tags_helper_1.TagsHelper.getNameTagValue(db.TagList || []), tags_helper_1.TagsHelper.formatTags(db.TagList)));
});
data.push(new rds_1.Rds(db.DBInstanceIdentifier || '', db.DBInstanceClass || '', db.StorageType || '', new metric_1.Metric(0, statistics_1.Statistics.Average, 'test'), new metric_1.Metric(0, statistics_1.Statistics.Average, 'test'), db.Engine || '', db.DBClusterIdentifier ? true : (db.MultiAZ || false), ((_a = db.InstanceCreateTime) === null || _a === void 0 ? void 0 : _a.toISOString()) || '', db.AvailabilityZone || '', db.DBInstanceStatus || '', db.DBInstanceStatus === 'stopped', db.DBClusterIdentifier ? 'Multi-AZ (readable standbys)' : (db.MultiAZ ? 'Multi-AZ' : 'Single-AZ'), db.DBClusterIdentifier, undefined, undefined, tags_helper_1.TagsHelper.getNameTagValue(db.TagList || []), tags_helper_1.TagsHelper.formatTags(db.TagList)));
});
return data;
};
AwsRdsClient.prototype.formatClustersResponse = function (response) {
return response.reduce(function (pv, cv) {
var _a;
var _b, _c;
return __assign(__assign({}, pv), (_a = {},
_a[cv.DBClusterIdentifier || ''] = {
primaryNode: ((_b = (cv.DBClusterMembers || []).filter(function (m) { return m.IsClusterWriter; })[0]) === null || _b === void 0 ? void 0 : _b.DBInstanceIdentifier) || '',
nodesCount: ((_c = cv.DBClusterMembers) === null || _c === void 0 ? void 0 : _c.length) || 0
},
_a));
}, {});
};
AwsRdsClient.prototype.putAdditionalData = function (data) {

@@ -213,17 +265,24 @@ return __awaiter(this, void 0, void 0, function () {

};
AwsRdsClient.getPatchCommand = function (instanceIdentifier, action, snapshot) {
var props = { DBInstanceIdentifier: instanceIdentifier };
AwsRdsClient.getDescribeDBClustersCommand = function () {
return new client_rds_1.DescribeDBClustersCommand({});
};
AwsRdsClient.getPatchCommand = function (instanceIdentifier, action, snapshot, cluster) {
if (action === constant_1.PatchAction.STOP) {
return new client_rds_1.StopDBInstanceCommand(props);
return cluster
? new client_rds_1.StopDBClusterCommand({ DBClusterIdentifier: cluster })
: new client_rds_1.StopDBInstanceCommand({ DBInstanceIdentifier: instanceIdentifier });
}
if (action === constant_1.PatchAction.START) {
return new client_rds_1.StartDBInstanceCommand(props);
return cluster
? new client_rds_1.StartDBClusterCommand({ DBClusterIdentifier: cluster })
: new client_rds_1.StartDBInstanceCommand({ DBInstanceIdentifier: instanceIdentifier });
}
if (!snapshot) {
props.SkipFinalSnapshot = true;
return cluster
? new client_rds_1.DeleteDBClusterCommand({ DBClusterIdentifier: cluster, SkipFinalSnapshot: true })
: new client_rds_1.DeleteDBInstanceCommand({ DBInstanceIdentifier: instanceIdentifier, SkipFinalSnapshot: true });
}
else {
props.FinalDBSnapshotIdentifier = "snapshot-".concat(instanceIdentifier, "-").concat((0, moment_1.default)().unix());
}
return new client_rds_1.DeleteDBInstanceCommand(props);
return cluster
? new client_rds_1.DeleteDBClusterCommand({ DBClusterIdentifier: cluster, FinalDBSnapshotIdentifier: "snapshot-".concat(cluster, "-").concat((0, moment_1.default)().unix()) })
: new client_rds_1.DeleteDBInstanceCommand({ DBInstanceIdentifier: instanceIdentifier, FinalDBSnapshotIdentifier: "snapshot-".concat(instanceIdentifier, "-").concat((0, moment_1.default)().unix()) });
};

@@ -230,0 +289,0 @@ AwsRdsClient.getMetricStatisticsCommand = function (instanceIdentifier, metricName, unit) {

@@ -18,2 +18,4 @@ import { ProviderResource } from '../provider-resource';

readonly deploymentOption: string;
readonly cluster?: string | undefined;
nodesCount?: number | undefined;
metrics?: AwsRdsMetric | undefined;

@@ -23,3 +25,3 @@ readonly nameTag?: string | undefined;

readonly _account?: string | undefined;
constructor(id: string, instanceType: string, storageType: string, averageConnections: Metric, averageIOPS: Metric, dbType: string, multiAZ: boolean, age: string, availabilityZone: string, status: string, isStopped: boolean, deploymentOption: string, metrics?: AwsRdsMetric | undefined, nameTag?: string | undefined, tags?: Tag[] | undefined, _account?: string | undefined);
constructor(id: string, instanceType: string, storageType: string, averageConnections: Metric, averageIOPS: Metric, dbType: string, multiAZ: boolean, age: string, availabilityZone: string, status: string, isStopped: boolean, deploymentOption: string, cluster?: string | undefined, nodesCount?: number | undefined, metrics?: AwsRdsMetric | undefined, nameTag?: string | undefined, tags?: Tag[] | undefined, _account?: string | undefined);
getRegion(): string;

@@ -26,0 +28,0 @@ getOwner(): string | undefined;

@@ -22,3 +22,3 @@ "use strict";

__extends(Rds, _super);
function Rds(id, instanceType, storageType, averageConnections, averageIOPS, dbType, multiAZ, age, availabilityZone, status, isStopped, deploymentOption, metrics, nameTag, tags, _account) {
function Rds(id, instanceType, storageType, averageConnections, averageIOPS, dbType, multiAZ, age, availabilityZone, status, isStopped, deploymentOption, cluster, nodesCount, metrics, nameTag, tags, _account) {
var _this = _super.call(this) || this;

@@ -37,2 +37,4 @@ _this.id = id;

_this.deploymentOption = deploymentOption;
_this.cluster = cluster;
_this.nodesCount = nodesCount;
_this.metrics = metrics;

@@ -39,0 +41,0 @@ _this.nameTag = nameTag;

@@ -15,2 +15,3 @@ export interface PatchAwsEbsMetadataInterface {

snapshot?: boolean;
cluster?: string;
}

@@ -17,0 +18,0 @@ export interface PatchAwsElcMetadataInterface {

{
"name": "@cloudchipr/cloudchipr-engine",
"version": "0.2.10",
"version": "0.2.11",
"description": "Cloudchipr engine",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc