Skip to content

Commit

Permalink
Add discovery for aws-rds-dbcluster (#3027)
Browse files Browse the repository at this point in the history
RDS clusters are very important and should be scanned as their own
assets with checks applied to those assets. This starts that process.

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 authored Jan 21, 2024
1 parent 18e12ca commit b076090
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions providers/aws/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var Config = plugin.Provider{
resources.DiscoveryS3Buckets,
resources.DiscoveryCloudtrailTrails,
resources.DiscoveryRdsDbInstances,
resources.DiscoveryRdsDbClusters,
resources.DiscoveryVPCs,
resources.DiscoverySecurityGroups,
resources.DiscoveryIAMUsers,
Expand Down
2 changes: 2 additions & 0 deletions providers/aws/connection/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func getTitleForPlatformName(name string) string {
return "AWS CloudTrail Trail"
case "aws-rds-dbinstance":
return "AWS RDS DB Instance"
case "aws-rds-dbcluster":
return "AWS RDS DB Cluster"
case "aws-dynamodb-table":
return "AWS DynamoDB Table"
case "aws-redshift-cluster":
Expand Down
28 changes: 28 additions & 0 deletions providers/aws/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
DiscoveryS3Buckets = "s3-buckets"
DiscoveryCloudtrailTrails = "cloudtrail-trails"
DiscoveryRdsDbInstances = "rds-dbinstances"
DiscoveryRdsDbClusters = "rds-dbclusters"
DiscoveryVPCs = "vpcs"
DiscoverySecurityGroups = "security-groups"
DiscoveryIAMUsers = "iam-users"
Expand Down Expand Up @@ -71,6 +72,7 @@ var AllAPIResources = []string{
DiscoveryS3Buckets,
DiscoveryCloudtrailTrails,
DiscoveryRdsDbInstances,
DiscoveryRdsDbClusters,
DiscoveryVPCs,
DiscoverySecurityGroups,
DiscoveryIAMUsers,
Expand Down Expand Up @@ -525,6 +527,32 @@ func discover(runtime *plugin.Runtime, awsAccount *mqlAwsAccount, target string,
}
assetList = append(assetList, MqlObjectToAsset(accountId, m, conn))
}
case DiscoveryRdsDbClusters:
res, err := NewResource(runtime, "aws.rds", map[string]*llx.RawData{})
if err != nil {
return nil, err
}

r := res.(*mqlAwsRds)

clusters := r.GetDbClusters()
if clusters == nil {
return assetList, nil
}

for i := range clusters.Data {
f := clusters.Data[i].(*mqlAwsRdsDbcluster)

tags := mapStringInterfaceToStringString(f.Tags.Data)
m := mqlObject{
name: f.Id.Data, labels: tags,
awsObject: awsObject{
account: accountId, region: f.Region.Data, arn: f.Arn.Data,
id: f.Id.Data, service: "rds", objectType: "dbcluster",
},
}
assetList = append(assetList, MqlObjectToAsset(accountId, m, conn))
}
case DiscoveryVPCs:
res, err := NewResource(runtime, "aws", map[string]*llx.RawData{})
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions providers/aws/resources/discovery_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func getPlatformName(awsObject awsObject) string {
if awsObject.objectType == "dbinstance" {
return "aws-rds-dbinstance"
}
if awsObject.objectType == "dbcluster" {
return "aws-rds-dbcluster"
}
case "dynamodb":
if awsObject.objectType == "table" {
return "aws-dynamodb-table"
Expand Down

0 comments on commit b076090

Please sign in to comment.