forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/gcp-documentation-update
- Loading branch information
Showing
1,548 changed files
with
126,009 additions
and
17,133 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
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,49 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var accessanalyzer = new AWS.AccessAnalyzer(AWSConfig); | ||
async.eachLimit(collection.accessanalyzer.listAnalyzers[AWSConfig.region].data, 15, function(analyzer, cb) { | ||
collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn] = {}; | ||
var params = { | ||
analyzerArn: analyzer.arn | ||
}; | ||
|
||
var paginating = false; | ||
var paginateCb = function(err, data) { | ||
if (err) collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].err = err; | ||
|
||
if (!data) return cb(); | ||
|
||
if (paginating && data.findings && data.findings.length && | ||
collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].data.findings && | ||
collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].data.findings.length) { | ||
collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].data.findings = collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].data.findings.concat(data.findings); | ||
} else { | ||
collection.accessanalyzer.listFindings[AWSConfig.region][analyzer.arn].data = data; | ||
} | ||
|
||
if (data.nextToken && data.nextToken.length) { | ||
paginating = true; | ||
return execute(data.nextToken); | ||
} | ||
|
||
cb(); | ||
}; | ||
|
||
function execute(nextToken) { // eslint-disable-line no-inner-declarations | ||
var localParams = JSON.parse(JSON.stringify(params || {})); | ||
if (nextToken) localParams['nextToken'] = nextToken; | ||
if (nextToken) { | ||
helpers.makeCustomCollectorCall(accessanalyzer, 'listFindings', localParams, retries, null, null, null, paginateCb); | ||
} else { | ||
helpers.makeCustomCollectorCall(accessanalyzer, 'listFindings', params, retries, null, null, null, paginateCb); | ||
} | ||
} | ||
|
||
execute(); | ||
}, 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,52 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var apigateway = new AWS.APIGateway(AWSConfig); | ||
|
||
async.eachLimit(collection.apigateway.getRestApis[AWSConfig.region].data, 5, function(api, cb){ | ||
if (!collection.apigateway.getResources || | ||
!collection.apigateway.getResources[AWSConfig.region] || | ||
!collection.apigateway.getResources[AWSConfig.region][api.id] || | ||
!collection.apigateway.getResources[AWSConfig.region][api.id].data || | ||
!collection.apigateway.getResources[AWSConfig.region][api.id].data.items) { | ||
return cb(); | ||
} | ||
|
||
collection.apigateway.getIntegration[AWSConfig.region][api.id] = {}; | ||
async.eachLimit(collection.apigateway.getResources[AWSConfig.region][api.id].data.items, 3, function(resource, pCb){ | ||
|
||
collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id] = {}; | ||
|
||
async.eachOfLimit(resource.resourceMethods, 3, function(methodVal,methodKey, mCb){ | ||
|
||
collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id][methodKey] = {}; | ||
|
||
let params = { | ||
resourceId: resource.id, | ||
httpMethod: methodKey, | ||
restApiId : api.id, | ||
}; | ||
|
||
helpers.makeCustomCollectorCall(apigateway, 'getIntegration', params, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id][methodKey].err = err; | ||
return mCb(); | ||
} | ||
|
||
collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id][methodKey].data = data; | ||
mCb(); | ||
}); | ||
}, function(){ | ||
pCb(); | ||
}); | ||
|
||
}, function(){ | ||
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,42 @@ | ||
var AWS = require('aws-sdk'); | ||
var async = require('async'); | ||
var helpers = require(__dirname + '/../../../helpers/aws'); | ||
|
||
module.exports = function(AWSConfig, collection, retries, callback) { | ||
var appmesh = new AWS.AppMesh(AWSConfig); | ||
|
||
if (!collection.appmesh || | ||
!collection.appmesh.listMeshes || | ||
!collection.appmesh.listMeshes[AWSConfig.region] || | ||
!collection.appmesh.listMeshes[AWSConfig.region].data) return callback(); | ||
async.eachLimit(collection.appmesh.listMeshes[AWSConfig.region].data, 5, function(mesh, cb){ | ||
|
||
if (!mesh.meshName || !collection.appmesh || | ||
!collection.appmesh.listVirtualGateways || | ||
!collection.appmesh.listVirtualGateways[AWSConfig.region] || | ||
!collection.appmesh.listVirtualGateways[AWSConfig.region][mesh.meshName] || | ||
!collection.appmesh.listVirtualGateways[AWSConfig.region][mesh.meshName].data || | ||
!collection.appmesh.listVirtualGateways[AWSConfig.region][mesh.meshName].data.virtualGateways || | ||
!collection.appmesh.listVirtualGateways[AWSConfig.region][mesh.meshName].data.virtualGateways.length) { | ||
return cb(); | ||
} | ||
|
||
async.eachLimit(collection.appmesh.listVirtualGateways[AWSConfig.region][mesh.meshName].data.virtualGateways, 3, function(gateway, pCb){ | ||
collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName] = {}; | ||
|
||
helpers.makeCustomCollectorCall(appmesh, 'describeVirtualGateway', {virtualGatewayName: gateway.virtualGatewayName,meshName: mesh.meshName}, retries, null, null, null, function(err, data) { | ||
if (err) { | ||
collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName].err = err; | ||
} | ||
|
||
collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName].data = data; | ||
pCb(); | ||
}); | ||
|
||
}, function() { | ||
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,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
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(); | ||
}); | ||
}; |
Oops, something went wrong.