Skip to content

Commit

Permalink
#1074 Multi Project Gcp support
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh2253 committed May 10, 2023
1 parent fecf360 commit ded6112
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion deepfence_server/handler/cloud_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ func (h *Handler) RegisterCloudNodeAccountHandler(w http.ResponseWriter, r *http
}
monitoredAccountIds[req.CloudAccount] = nodeId
orgNodeId := fmt.Sprintf("%s-%s-cloud-org", req.CloudProvider, orgAccountId)
orgCloudProvider := model.PostureProviderGCPOrg
if req.CloudProvider == model.PostureProviderAWS {
orgCloudProvider = model.PostureProviderAWSOrg
}
node := map[string]interface{}{
"node_id": orgNodeId,
"cloud_provider": model.PostureProviderAWSOrg,
"cloud_provider": orgCloudProvider,
"node_name": orgAccountId,
}
err = model.UpsertCloudComplianceNode(ctx, node, "")
Expand Down
13 changes: 10 additions & 3 deletions deepfence_server/model/cloud_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
const PostureProviderAWS = "aws"
const PostureProviderAWSOrg = "aws_org"
const PostureProviderGCP = "gcp"
const PostureProviderGCPOrg = "gcp_org"
const PostureProviderAzure = "azure"
const PostureProviderLinux = "linux"
const PostureProviderKubernetes = "kubernetes"

var SupportedPostureProviders = []string{PostureProviderAWS, PostureProviderAWSOrg, PostureProviderGCP,
var SupportedPostureProviders = []string{PostureProviderAWS, PostureProviderAWSOrg, PostureProviderGCP, PostureProviderGCPOrg,
PostureProviderAzure, PostureProviderLinux, PostureProviderKubernetes}

type CloudNodeAccountRegisterReq struct {
Expand Down Expand Up @@ -257,8 +258,11 @@ func GetCloudProvidersList(ctx context.Context) ([]PostureProvider, error) {
postureProvider.ScanCount = int(nodeRec.Values[1].(int64))
postureProvider.CompliancePercentage = nodeRec.Values[2].(float64)
}
} else if postureProviderName == PostureProviderAWSOrg {
cloudProvider := PostureProviderAWS
} else if postureProviderName == PostureProviderAWSOrg || postureProviderName == PostureProviderGCPOrg {
cloudProvider := PostureProviderGCP
if postureProviderName == PostureProviderAWSOrg {
cloudProvider = PostureProviderAWS
}
postureProvider.NodeLabel = "Organizations"
nodeRes, err := tx.Run(fmt.Sprintf(`
MATCH (o:%s{cloud_provider:$cloud_provider+'_org'})
Expand Down Expand Up @@ -349,6 +353,9 @@ func GetCloudComplianceNodesList(ctx context.Context, cloudProvider string, fw F
if cloudProvider == PostureProviderAWSOrg {
cloudProvider = PostureProviderAWS
isOrgListing = true
} else if cloudProvider == PostureProviderGCPOrg {
cloudProvider = PostureProviderGCP
isOrgListing = true
} else if cloudProvider == PostureProviderKubernetes {
neo4jNodeType = "KubernetesCluster"
} else if cloudProvider == PostureProviderLinux {
Expand Down

0 comments on commit ded6112

Please sign in to comment.