Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure multi-subscription cloud scanner support #2201

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions deepfence_server/model/cloud_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const (
PostureProviderGCP = "gcp"
PostureProviderGCPOrg = "gcp_org"
PostureProviderAzure = "azure"
PostureProviderAzureOrg = "azure_org"
PostureProviderLinux = "linux"
PostureProviderKubernetes = "kubernetes"
)

var (
PostureProviderOrgMap = map[string]string{
PostureProviderAWS: PostureProviderAWSOrg,
PostureProviderGCP: PostureProviderGCPOrg,
PostureProviderAWS: PostureProviderAWSOrg,
PostureProviderGCP: PostureProviderGCPOrg,
PostureProviderAzure: PostureProviderAzureOrg,
}
)

Expand Down Expand Up @@ -94,7 +96,7 @@ func (CloudNodeAccountInfo) ExtendedField() string {

func (v CloudNodeAccountInfo) ScanType() utils.Neo4jScanType {
switch v.CloudProvider {
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg:
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg, PostureProviderGCPOrg, PostureProviderAzureOrg:
return utils.NEO4JCloudComplianceScan
case PostureProviderKubernetes, PostureProviderLinux:
return utils.NEO4JComplianceScan
Expand All @@ -109,7 +111,7 @@ func (v CloudNodeAccountInfo) LatestScanIDField() string {

func (v CloudNodeAccountInfo) ScanResultType() string {
switch v.CloudProvider {
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg:
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg, PostureProviderGCPOrg, PostureProviderAzureOrg:
return "CloudCompliance"
case PostureProviderKubernetes, PostureProviderLinux:
return "Compliance"
Expand All @@ -120,7 +122,7 @@ func (v CloudNodeAccountInfo) ScanResultType() string {

func (v CloudNodeAccountInfo) GetPassStatus() []string {
switch v.CloudProvider {
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg, PostureProviderKubernetes:
case PostureProviderAWS, PostureProviderGCP, PostureProviderAzure, PostureProviderAWSOrg, PostureProviderGCPOrg, PostureProviderAzureOrg, PostureProviderKubernetes:
return []string{"ok", "info", "skip"}
case PostureProviderLinux:
return []string{"warn", "pass"}
Expand Down Expand Up @@ -292,6 +294,7 @@ func GetCloudProvidersList(ctx context.Context) ([]PostureProvider, error) {
{Name: PostureProviderGCP, NodeLabel: "Accounts"},
// {Name: PostureProviderGCPOrg, NodeLabel: "Organizations"},
{Name: PostureProviderAzure, NodeLabel: "Accounts"},
// {Name: PostureProviderAzureOrg, NodeLabel: "Organizations"},
{Name: PostureProviderLinux, NodeLabel: "Hosts"},
{Name: PostureProviderKubernetes, NodeLabel: "Clusters"},
}
Expand Down Expand Up @@ -352,7 +355,7 @@ func GetCloudProvidersList(ctx context.Context) ([]PostureProvider, error) {
if err == nil {
for _, record := range records {
provider := record.Values[0].(string)
if slices.Contains([]string{PostureProviderAWSOrg, PostureProviderGCPOrg}, provider) {
if slices.Contains([]string{PostureProviderAWSOrg, PostureProviderGCPOrg, PostureProviderAzureOrg}, provider) {
continue
}
if record.Values[1].(bool) {
Expand Down Expand Up @@ -397,6 +400,9 @@ func GetCloudComplianceNodesList(ctx context.Context, cloudProvider string, fw F
case PostureProviderGCPOrg:
cloudProvider = PostureProviderGCP
isOrgListing = true
case PostureProviderAzureOrg:
cloudProvider = PostureProviderAzure
isOrgListing = true
case PostureProviderKubernetes:
neo4jNodeType = "KubernetesCluster"
case PostureProviderLinux:
Expand Down
2 changes: 1 addition & 1 deletion deepfence_server/reporters/scan/scan_reporters.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func GetCloudAccountIDs(ctx context.Context, cloudProviderIds []model.NodeIdenti
orgNodeIds := []string{}
for _, rec := range recs {
cloudProvider := rec.Values[1].(string)
if cloudProvider == model.PostureProviderAWSOrg || cloudProvider == model.PostureProviderGCPOrg {
if cloudProvider == model.PostureProviderAWSOrg || cloudProvider == model.PostureProviderGCPOrg || cloudProvider == model.PostureProviderAzureOrg {
orgNodeIds = append(orgNodeIds, rec.Values[0].(string))
continue
}
Expand Down
2 changes: 1 addition & 1 deletion deepfence_server/reporters/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func searchCloudNode(ctx context.Context, filter SearchFilter, fw model.FetchWin
}
var node model.CloudNodeAccountInfo
utils.FromMap(nodeMap, &node)
if node.CloudProvider == model.PostureProviderAWSOrg || node.CloudProvider == model.PostureProviderGCPOrg {
if node.CloudProvider == model.PostureProviderAWSOrg || node.CloudProvider == model.PostureProviderGCPOrg || node.CloudProvider == model.PostureProviderAzureOrg {
node.ScanStatusMap, err = getScanStatusMap(ctx, node.NodeID, node.CloudProvider)
if err != nil {
log.Error().Msgf("Error in populating status of org %v", err)
Expand Down
2 changes: 1 addition & 1 deletion deepfence_worker/cronjobs/cloud_compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func CachePostureProviders(ctx context.Context, task *asynq.Task) error {
MATCH (m) -[:DETECTED] -> (c:Compliance)
RETURN count(distinct c)`

} else if postureProviderName == model.PostureProviderAWSOrg || postureProviderName == model.PostureProviderGCPOrg {
} else if postureProviderName == model.PostureProviderAWSOrg || postureProviderName == model.PostureProviderGCPOrg || postureProviderName == model.PostureProviderAzureOrg {
postureProvider.NodeLabel = "Organizations"

account_count_query = `
Expand Down
2 changes: 1 addition & 1 deletion deepfence_worker/tasks/scans/delete_cloud_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func isOrgAccount(ctx context.Context, accountID string) (bool, error) {
}

switch cp.(string) {
case model.PostureProviderAWSOrg, model.PostureProviderGCPOrg:
case model.PostureProviderAWSOrg, model.PostureProviderGCPOrg, model.PostureProviderAzureOrg:
return true, nil
default:
return false, nil
Expand Down
Loading