Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
added in docdb adapters (#1171)
Browse files Browse the repository at this point in the history
* added in docdb adapters

* add changes
  • Loading branch information
SanaaYousaf authored Mar 10, 2023
1 parent 9e985f9 commit 8377682
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
13 changes: 7 additions & 6 deletions internal/adapters/cloud/aws/documentdb/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ func (a *adapter) adaptCluster(cluster types.DBCluster) (*documentdb.Cluster, er
}

return &documentdb.Cluster{
Metadata: metadata,
Identifier: defsecTypes.String(identifier, metadata),
EnabledLogExports: logExports,
Instances: instances,
StorageEncrypted: defsecTypes.Bool(cluster.StorageEncrypted, metadata),
KMSKeyID: defsecTypes.String(kmsKeyId, metadata),
Metadata: metadata,
Identifier: defsecTypes.String(identifier, metadata),
EnabledLogExports: logExports,
Instances: instances,
StorageEncrypted: defsecTypes.Bool(cluster.StorageEncrypted, metadata),
KMSKeyID: defsecTypes.String(kmsKeyId, metadata),
BackupRetentionPeriod: defsecTypes.Int(int(*cluster.BackupRetentionPeriod), metadata),
}, nil
}
13 changes: 7 additions & 6 deletions internal/adapters/cloudformation/aws/documentdb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ func getClusters(ctx parser.FileContext) (clusters []documentdb.Cluster) {

for _, r := range clusterResources {
cluster := documentdb.Cluster{
Metadata: r.Metadata(),
Identifier: r.GetStringProperty("DBClusterIdentifier"),
EnabledLogExports: getLogExports(r),
Instances: nil,
StorageEncrypted: r.GetBoolProperty("StorageEncrypted"),
KMSKeyID: r.GetStringProperty("KmsKeyId"),
Metadata: r.Metadata(),
Identifier: r.GetStringProperty("DBClusterIdentifier"),
EnabledLogExports: getLogExports(r),
Instances: nil,
BackupRetentionPeriod: r.GetIntProperty("BackupRetentionPeriod"),
StorageEncrypted: r.GetBoolProperty("StorageEncrypted"),
KMSKeyID: r.GetStringProperty("KmsKeyId"),
}

updateInstancesOnCluster(&cluster, ctx)
Expand Down
13 changes: 7 additions & 6 deletions internal/adapters/terraform/aws/documentdb/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ func adaptCluster(resource *terraform.Block, module *terraform.Module) documentd
KMSKeyIDVal := KMSKeyIDAttr.AsStringValueOrDefault("", resource)

return documentdb.Cluster{
Metadata: resource.GetMetadata(),
Identifier: identifierVal,
EnabledLogExports: enabledLogExports,
Instances: instances,
StorageEncrypted: storageEncryptedVal,
KMSKeyID: KMSKeyIDVal,
Metadata: resource.GetMetadata(),
Identifier: identifierVal,
EnabledLogExports: enabledLogExports,
BackupRetentionPeriod: resource.GetAttribute("backup_retention_period").AsIntValueOrDefault(0, resource),
Instances: instances,
StorageEncrypted: storageEncryptedVal,
KMSKeyID: KMSKeyIDVal,
}
}
13 changes: 7 additions & 6 deletions pkg/providers/aws/documentdb/documentdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const (
)

type Cluster struct {
Metadata defsecTypes.Metadata
Identifier defsecTypes.StringValue
EnabledLogExports []defsecTypes.StringValue
Instances []Instance
StorageEncrypted defsecTypes.BoolValue
KMSKeyID defsecTypes.StringValue
Metadata defsecTypes.Metadata
Identifier defsecTypes.StringValue
EnabledLogExports []defsecTypes.StringValue
BackupRetentionPeriod defsecTypes.IntValue
Instances []Instance
StorageEncrypted defsecTypes.BoolValue
KMSKeyID defsecTypes.StringValue
}

type Instance struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/rego/schemas/cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,10 @@
"github.com.aquasecurity.defsec.pkg.providers.aws.documentdb.Cluster": {
"type": "object",
"properties": {
"backupretentionperiod": {
"type": "object",
"$ref": "#/definitions/github.com.aquasecurity.defsec.pkg.types.IntValue"
},
"enabledlogexports": {
"type": "array",
"items": {
Expand Down

0 comments on commit 8377682

Please sign in to comment.