Skip to content

Commit

Permalink
Merge pull request #160 from opengovern/fix-audit
Browse files Browse the repository at this point in the history
fix: set integrationID instead of accountID
  • Loading branch information
artaasadi authored Dec 5, 2024
2 parents a516e35 + a12c949 commit f5d9f23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 5 additions & 15 deletions pkg/opengovernance-es-sdk/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,12 @@ type BoolFilter interface {
}

func BuildFilter(ctx context.Context, queryContext *plugin.QueryContext,
filtersQuals map[string]string,
accountProvider string, accountID *string, encodedResourceGroupFilters *string, clientType *string) []BoolFilter {
return BuildFilterWithDefaultFieldName(ctx, queryContext, filtersQuals,
accountProvider, accountID, encodedResourceGroupFilters, clientType, false)
filtersQuals map[string]string, integrationID *string, encodedResourceGroupFilters *string, clientType *string) []BoolFilter {
return BuildFilterWithDefaultFieldName(ctx, queryContext, filtersQuals, integrationID, encodedResourceGroupFilters, clientType, false)
}

func BuildFilterWithDefaultFieldName(ctx context.Context, queryContext *plugin.QueryContext,
filtersQuals map[string]string,
accountProvider string, accountID *string, encodedResourceGroupFilters *string, clientType *string,
filtersQuals map[string]string, integrationID *string, encodedResourceGroupFilters *string, clientType *string,
useDefaultFieldName bool) []BoolFilter {
var filters []BoolFilter
plugin.Logger(ctx).Trace("BuildFilter", "queryContext.UnsafeQuals", queryContext.UnsafeQuals)
Expand Down Expand Up @@ -187,15 +184,8 @@ func BuildFilterWithDefaultFieldName(ctx context.Context, queryContext *plugin.Q
}
}

if accountID != nil && len(*accountID) > 0 && *accountID != "all" {
var accountFieldName string
switch accountProvider {
case "aws":
accountFieldName = "AccountID"
case "azure":
accountFieldName = "SubscriptionID"
}
filters = append(filters, NewTermFilter("metadata."+accountFieldName, *accountID))
if integrationID != nil && len(*integrationID) > 0 && *integrationID != "all" {
filters = append(filters, NewTermFilter("integration_id", *integrationID))
}

if encodedResourceGroupFilters != nil && len(*encodedResourceGroupFilters) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/steampipe/live-context.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type OpenGovernanceConfigKey string

const (
OpenGovernanceConfigKeyAccountID OpenGovernanceConfigKey = "account_id"
OpenGovernanceConfigKeyIntegrationID OpenGovernanceConfigKey = "integration_id"
OpenGovernanceConfigKeyResourceCollectionFilters OpenGovernanceConfigKey = "resource_collection_filters"
OpenGovernanceConfigKeyClientType OpenGovernanceConfigKey = "client_type"
)
Expand Down

0 comments on commit f5d9f23

Please sign in to comment.