forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from accuknox/accuknox_head_changes
Accuknox head changes
- Loading branch information
Showing
1,915 changed files
with
64,642 additions
and
3,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var ROAClient = require('@alicloud/pop-core').ROAClient; | ||
|
||
var apiVersion = '2015-12-15'; | ||
var httpMethod = 'GET'; | ||
var uriPathClusterDetail = '/clusters/'; | ||
var body = '{}'; | ||
var headers = { | ||
'Content-Type': 'application/json' | ||
}; | ||
var requestOption = {timeout: 30000}; | ||
|
||
module.exports = function(AlibabaConfig, collection, region, callback) { | ||
let localConfig = { ...AlibabaConfig }; | ||
localConfig['endpoint'] = `https://cs.${region}.aliyuncs.com`; | ||
localConfig['apiVersion'] = apiVersion; | ||
var client = new ROAClient(localConfig); | ||
|
||
var clusters = collection.ack.describeClustersV1[region].data; | ||
var totalClusters = clusters.length; | ||
var completedRequests = 0; | ||
var allRequestsCompleted = function() { | ||
callback(); | ||
}; | ||
|
||
var executeSingleClusterDetail = function(cluster) { | ||
var clusterId = cluster.cluster_id; | ||
var uriPath = `${uriPathClusterDetail}${clusterId}`; | ||
client.request(httpMethod, uriPath, {}, body, headers, requestOption).then((res) => { | ||
collection.ack.describeClusterDetail[region][clusterId] = {}; | ||
collection.ack.describeClusterDetail[region][clusterId].data = res; | ||
completedRequests++; | ||
if (completedRequests === totalClusters) { | ||
allRequestsCompleted(); | ||
} | ||
}, (err) => { | ||
collection.ack.describeClusterDetail[region][clusterId] = { err: err }; | ||
completedRequests++; | ||
if (completedRequests === totalClusters) { | ||
allRequestsCompleted(); | ||
} | ||
}); | ||
}; | ||
|
||
for (var i = 0; i < totalClusters; i++) { | ||
executeSingleClusterDetail(clusters[i]); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require('../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var cloudwatch = new AWS.CloudWatch(AWSConfig); | ||
|
||
async.eachLimit(collection.ec2.describeInstances[AWSConfig.region].data, 10, function(reservation, cb) { | ||
reservation.Instances.forEach(instance => { | ||
collection.cloudwatch.getEc2MetricStatistics[AWSConfig.region][instance.InstanceId] = {}; | ||
var endTime = new Date(); | ||
var startTime = new Date(); | ||
startTime.setDate(startTime.getDate() - 1); | ||
var params = { | ||
'MetricName': 'CPUUtilization', | ||
'Namespace': 'AWS/EC2', | ||
'StartTime': startTime.toISOString(), | ||
'EndTime': endTime.toISOString(), | ||
'Period': 3600, | ||
'Statistics': ['Average'], | ||
'Dimensions': [ | ||
{ | ||
Name: 'InstanceId', | ||
Value: instance.InstanceId | ||
} | ||
] | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(cloudwatch, 'getMetricStatistics', params,retries, null, null, null, function(err, data) { | ||
if (err) collection.cloudwatch.getEc2MetricStatistics[AWSConfig.region][instance.InstanceId].err = err; | ||
if (data) collection.cloudwatch.getEc2MetricStatistics[AWSConfig.region][instance.InstanceId].data = data; | ||
}); | ||
}); | ||
cb(); | ||
}, function() { | ||
callback(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var cloudwatch = new AWS.CloudWatch(AWSConfig); | ||
|
||
async.eachLimit(collection.rds.describeDBInstances[AWSConfig.region].data, 10, function(instance, cb){ | ||
collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier] = {}; | ||
var endTime = new Date(); | ||
var startTime = new Date(); | ||
startTime.setDate(startTime.getDate() - 7); | ||
var params = { | ||
'MetricName': 'CPUUtilization', | ||
'Namespace':'AWS/RDS', | ||
'StartTime': startTime.toISOString(), | ||
'EndTime': endTime.toISOString(), | ||
'Period': 86400, | ||
'Statistics': ['Average'], | ||
'Dimensions' : [ | ||
{ | ||
Name: 'DBInstanceIdentifier', | ||
Value: instance.DBInstanceIdentifier | ||
} | ||
] | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(cloudwatch, 'getMetricStatistics', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err; | ||
} | ||
collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data; | ||
cb(); | ||
}); | ||
|
||
}, function(){ | ||
callback(); | ||
}); | ||
}; |
39 changes: 39 additions & 0 deletions
39
collectors/aws/cloudwatch/getRdsReadIOPSMetricStatistics.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var cloudwatch = new AWS.CloudWatch(AWSConfig); | ||
|
||
async.eachLimit(collection.rds.describeDBInstances[AWSConfig.region].data, 10, function(instance, cb){ | ||
collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier] = {}; | ||
var endTime = new Date(); | ||
var startTime = new Date(); | ||
startTime.setDate(startTime.getDate() - 7); | ||
var params = { | ||
'MetricName': 'ReadIOPS', | ||
'Namespace':'AWS/RDS', | ||
'StartTime': startTime.toISOString(), | ||
'EndTime': endTime.toISOString(), | ||
'Period': 86400, | ||
'Statistics': ['Sum'], | ||
'Dimensions' : [ | ||
{ | ||
Name: 'DBInstanceIdentifier', | ||
Value: instance.DBInstanceIdentifier | ||
} | ||
] | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(cloudwatch, 'getMetricStatistics', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err; | ||
} | ||
collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data; | ||
cb(); | ||
}); | ||
|
||
}, function(){ | ||
callback(); | ||
}); | ||
}; |
39 changes: 39 additions & 0 deletions
39
collectors/aws/cloudwatch/getRdsWriteIOPSMetricStatistics.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var cloudwatch = new AWS.CloudWatch(AWSConfig); | ||
|
||
async.eachLimit(collection.rds.describeDBInstances[AWSConfig.region].data, 10, function(instance, cb){ | ||
collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier] = {}; | ||
var endTime = new Date(); | ||
var startTime = new Date(); | ||
startTime.setDate(startTime.getDate() - 7); | ||
var params = { | ||
'MetricName': 'WriteIOPS', | ||
'Namespace':'AWS/RDS', | ||
'StartTime': startTime.toISOString(), | ||
'EndTime': endTime.toISOString(), | ||
'Period': 86400, | ||
'Statistics': ['Sum'], | ||
'Dimensions' : [ | ||
{ | ||
Name: 'DBInstanceIdentifier', | ||
Value: instance.DBInstanceIdentifier | ||
} | ||
] | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(cloudwatch, 'getMetricStatistics', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err; | ||
} | ||
collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data; | ||
cb(); | ||
}); | ||
|
||
}, function(){ | ||
callback(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var cloudwatch = new AWS.CloudWatch(AWSConfig); | ||
|
||
async.eachLimit(collection.redshift.describeClusters[AWSConfig.region].data, 10, function(cluster, cb){ | ||
collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier] = {}; | ||
var endTime = new Date(); | ||
var startTime = new Date(); | ||
startTime.setDate(startTime.getDate() - 7); | ||
var params = { | ||
'MetricName': 'CPUUtilization', | ||
'Namespace':'AWS/Redshift', | ||
'StartTime': startTime.toISOString(), | ||
'EndTime': endTime.toISOString(), | ||
'Period': 3600, | ||
'Statistics': ['Average'], | ||
'Dimensions' : [ | ||
{ | ||
Name: 'ClusterIdentifier', | ||
Value: cluster.ClusterIdentifier | ||
} | ||
] | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(cloudwatch, 'getMetricStatistics', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier].err = err; | ||
} | ||
collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier].data = data; | ||
cb(); | ||
}); | ||
|
||
}, function(){ | ||
callback(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var elasticache = new AWS.ElastiCache(AWSConfig); | ||
|
||
async.eachLimit(collection.elasticache.describeCacheClusters[AWSConfig.region].data, 15, function(cluster, cb){ | ||
collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName] = {}; | ||
var params = { | ||
CacheSubnetGroupName: cluster.CacheSubnetGroupName | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(elasticache, 'describeCacheSubnetGroups', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName].err = err; | ||
} | ||
collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName].data = data; | ||
cb(); | ||
}); | ||
}, function(){ | ||
callback(); | ||
}); | ||
}; |
Oops, something went wrong.