From 6d29b10dd4b42da83232dac35a37d373e42faaa6 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 22 Nov 2023 23:35:44 +0530 Subject: [PATCH 1/5] Enhanced the filter param of the table aws_ssm_inventory and fixed the error for the table aws_ssm_inventory_entry by type name --- aws/table_aws_ssm_inventory.go | 406 ++++++++++++++++++++++++++- aws/table_aws_ssm_inventory_entry.go | 15 +- go.mod | 14 +- go.sum | 33 +-- 4 files changed, 425 insertions(+), 43 deletions(-) diff --git a/aws/table_aws_ssm_inventory.go b/aws/table_aws_ssm_inventory.go index 57b2dba8f..6a9fa00fd 100644 --- a/aws/table_aws_ssm_inventory.go +++ b/aws/table_aws_ssm_inventory.go @@ -2,6 +2,7 @@ package aws import ( "context" + "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ssm" @@ -22,8 +23,40 @@ func tableAwsSSMInventory(_ context.Context) *plugin.Table { Hydrate: listAwsSSMInventories, Tags: map[string]string{"service": "ssm", "action": "GetInventory"}, KeyColumns: plugin.KeyColumnSlice{ - {Name: "id", Require: plugin.Optional, Operators: []string{"=", "<>"}}, + {Name: "id", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "filter_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "filter_value", Require: plugin.Optional, Operators: []string{"=", "<>", ">", "<", ">=", "<="}}, {Name: "type_name", Require: plugin.Optional}, + {Name: "component_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "component_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "instance_detailed_information_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "instance_detailed_information_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "network_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "network_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_role_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_role_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "service_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "service_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_registry_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_registry_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "compliance_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "compliance_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "file_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "file_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "instance_information_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "instance_information_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "patch_compliance_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "patch_compliance_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "patch_summary_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "patch_summary_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "application_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "application_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "tag_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "tag_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "resource_group_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "resource_group_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_update_attribute_key", Require: plugin.Optional, Operators: []string{"="}}, + {Name: "windows_update_attribute_value", Require: plugin.Optional, Operators: []string{"="}}, }, }, HydrateConfig: []plugin.HydrateConfig{ @@ -44,6 +77,198 @@ func tableAwsSSMInventory(_ context.Context) *plugin.Table { Description: "The type of inventory item returned by the request.", Type: proto.ColumnType_STRING, }, + { + Name: "filter_key", + Description: "The type of inventory item returned by the request.", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "filter_key"), + }, + { + Name: "filter_value", + Description: "The type of inventory item returned by the request.", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "filter_value"), + }, + { + Name: "component_attribute_key", + Description: "The attribute key that are supported for type name AWS:AWSComponent, Possible values are: Name,ApplicationType,Publisher,Version,InstalledTime,Architecture and URL.", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "component_attribute_key"), + }, + { + Name: "component_attribute_value", + Description: "The value for the component attribute key.", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "component_attribute_value"), + }, + { + Name: "application_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "application_attribute_key"), + }, + { + Name: "application_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "application_attribute_value"), + }, + { + Name: "compliance_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "compliance_attribute_key"), + }, + { + Name: "compliance_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "compliance_attribute_value"), + }, + { + Name: "file_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "file_attribute_key"), + }, + { + Name: "file_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "file_attribute_value"), + }, + { + Name: "instance_detailed_information_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "instance_detailed_information_attribute_key"), + }, + { + Name: "instance_detailed_information_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "instance_detailed_information_attribute_value"), + }, + { + Name: "instance_information_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "instance_information_attribute_key"), + }, + { + Name: "instance_information_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "instance_information_attribute_value"), + }, + { + Name: "network_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "network_attribute_key"), + }, + { + Name: "network_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "network_attribute_value"), + }, + { + Name: "windows_registry_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_registry_attribute_key"), + }, + { + Name: "windows_registry_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_registry_attribute_value"), + }, + { + Name: "patch_compliance_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "patch_compliance_attribute_key"), + }, + { + Name: "patch_compliance_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "patch_compliance_attribute_value"), + }, + { + Name: "patch_summary_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "patch_summary_attribute_key"), + }, + { + Name: "patch_summary_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "patch_summary_attribute_value"), + }, + { + Name: "resource_group_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "resource_group_attribute_key"), + }, + { + Name: "resource_group_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "resource_group_attribute_value"), + }, + { + Name: "service_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "service_attribute_key"), + }, + { + Name: "service_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "service_attribute_value"), + }, + { + Name: "tag_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "tag_attribute_key"), + }, + { + Name: "tag_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "tag_attribute_value"), + }, + { + Name: "windows_role_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_role_attribute_key"), + }, + { + Name: "windows_role_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_role_attribute_value"), + }, + { + Name: "windows_update_attribute_key", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_update_attribute_key"), + }, + { + Name: "windows_update_attribute_value", + Description: "", + Type: proto.ColumnType_STRING, + Transform: transform.FromP(getFilterKeyWithOperator, "windows_update_attribute_value"), + }, { Name: "capture_time", Description: "The time that inventory information was collected for the managed node(s).", @@ -102,8 +327,17 @@ func listAwsSSMInventories(ctx context.Context, d *plugin.QueryData, _ *plugin.H } maxItems := int32(50) - input := buildSSMInventoryFilter(ctx, d.Quals) - + input := buildSSMInventoryFilter(ctx, d) + // filter := types.InventoryFilter{ + // Key: aws.String("Custom:InspectorThirdPartyPackage.Message"), + // Values: []string{"SUCCESS"}, + // Type: types.InventoryQueryOperatorTypeEqual, + // } + // input.Filters = []types.InventoryFilter{ + // filter, + // } + + plugin.Logger(ctx).Error("Input filters ===>> ", input.Filters) // Reduce the basic request limit down if the user has only requested a small number of rows if d.QueryContext.Limit != nil { limit := int32(*d.QueryContext.Limit) @@ -199,19 +433,66 @@ func getAwsSSMInventorySchema(ctx context.Context, d *plugin.QueryData, h *plugi //// UTILITY FUNCTION // Build SSM inventory list call input filter -func buildSSMInventoryFilter(ctx context.Context, quals plugin.KeyColumnQualMap) ssm.GetInventoryInput { +func buildSSMInventoryFilter(ctx context.Context, quals *plugin.QueryData) ssm.GetInventoryInput { input := ssm.GetInventoryInput{ MaxResults: aws.Int32(50), } inventoryFilter := types.InventoryFilter{} - filterQuals := []string{"id", "type_name"} + shouldFilterKeyValueApplied := quals.EqualsQualString("filter_key") != "" && quals.EqualsQualString("filter_value") != "" + + var filterValue, filterOperator = "", "" + + if quals.EqualsQualString("filter_value") != "" { + for _, q := range quals.Quals["filter_value"].Quals { + filterValue = q.Value.GetStringValue() + filterOperator = q.Operator + } + } + + // Optimize query results by filtering with "instance_id" if provided as a query parameter in the child table "aws_ssm_inventory_entry". + if quals.EqualsQualString("instance_id") != "" { + for _, q := range quals.Quals["instance_id"].Quals { + input.Filters = []types.InventoryFilter{ + { + Key: aws.String("AWS:InstanceInformation.InstanceId"), + Values: []string{quals.EqualsQualString("instance_id")}, + }, + } + if q.Operator == "=" { + input.Filters[0].Type = types.InventoryQueryOperatorTypeEqual + } else if q.Operator == "<>" { + input.Filters[0].Type = types.InventoryQueryOperatorTypeNotEqual + } + } + } + + filterQuals := []string{"id", "type_name", "filter_key"} + + // Optional qulas for all supported type name along with their attribute key/value. + filterQualsByTypeName := map[string][]string{ + "AWS:AWSComponent": {"component_attribute_key", "component_attribute_value"}, + "AWS:Application": {"application_attribute_key", "application_attribute_value"}, + "AWS:ComplianceItem": {"compliance_attribute_key", "compliance_attribute_value"}, + "AWS:File": {"file_attribute_key", "file_attribute_value"}, + "AWS:InstanceDetailedInformation": {"instance_detailed_information_attribute_key", "instance_detailed_information_attribute_value"}, + "AWS:InstanceInformation": {"instance_information_attribute_key", "instance_information_attribute_value"}, + "AWS:Network": {"network_attribute_key", "network_attribute_value"}, + "AWS:PatchCompliance": {"patch_compliance_attribute_key", "patch_compliance_attribute_value"}, + "AWS:PatchSummary": {"patch_summary_attribute_key", "patch_summary_attribute_value"}, + "AWS:ResourceGroup": {"resource_group_attribute_key", "resource_group_attribute_value"}, + "AWS:Service": {"service_attribute_key", "service_attribute_value"}, + "AWS:Tag": {"tag_attribute_key", "tag_attribute_value"}, + "AWS:WindowsRegistry": {"windows_registry_attribute_key", "windows_registry_attribute_value"}, + "AWS:WindowsRole": {"windows_role_attribute_key", "windows_role_attribute_value"}, + "AWS:WindowsUpdate": {"windows_update_attribute_key", "windows_update_attribute_value"}, + } for _, columnName := range filterQuals { - if quals[columnName] != nil { - value := getQualsValueByColumn(quals, columnName, "string") - for _, q := range quals[columnName].Quals { + if quals.Quals[columnName] != nil { + value := getQualsValueByColumn(quals.Quals, columnName, "string") + for _, q := range quals.Quals[columnName].Quals { switch columnName { case "id": input.Filters = []types.InventoryFilter{ @@ -227,14 +508,119 @@ func buildSSMInventoryFilter(ctx context.Context, quals plugin.KeyColumnQualMap) } input.Filters = append(input.Filters, inventoryFilter) + // If we want to get the inventory details for a custom type name. + case "filter_key": + if shouldFilterKeyValueApplied { + inventoryFilter.Key = aws.String(value.(string)) + inventoryFilter.Values = []string{filterValue} + if filterOperator == "=" { + inventoryFilter.Type = types.InventoryQueryOperatorTypeEqual + } else if filterOperator == "<>" { + inventoryFilter.Type = types.InventoryQueryOperatorTypeNotEqual + } else if filterOperator == "<" || filterOperator == "<=" { + inventoryFilter.Type = types.InventoryQueryOperatorTypeLessThan + } else if filterOperator == ">" || filterOperator == ">=" { + inventoryFilter.Type = types.InventoryQueryOperatorTypeGreaterThan + } + input.Filters = append(input.Filters, inventoryFilter) + } + + // Supported type names are: AWS:InstanceInformation, AWS:PatchSummary. Default result type name is AWS:InstanceInformation.Supported pattern is ^(AWS|Custom):.*$ + // https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_ResultAttribute.html case "type_name": - if q.Operator == "=" { - input.ResultAttributes = []types.ResultAttribute{{TypeName: aws.String(value.(string))}} + if q.Operator == "=" && quals.Table.Name == "aws_ssm_inventory" { + if value.(string) == "AWS:InstanceInformation" || value.(string) == "AWS:PatchSummary" || strings.HasPrefix(value.(string), "Custom:") { + input.ResultAttributes = []types.ResultAttribute{{TypeName: aws.String(value.(string))}} + } + } + } + } + } + } + + // Build the filter as per the supported attributes for inventory type names. + // You can get the supported attributs by type name by running the command "aws ssm get-inventory-schema" + for typeName, typeNameQualsColumn := range filterQualsByTypeName { + f := types.InventoryFilter{} + + if typeName == "AWS:Tag" { + if quals.Quals[typeNameQualsColumn[0]] != nil { + f.Key = aws.String("AWS:Tag.Key") + if v, ok := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[0], "string").(string); ok { + f.Values = []string{v} + } else if v, ok := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[0], "string").([]*string); ok { + f.Values = getStringSliceWithoutPointer(v) + } + f.Type = types.InventoryQueryOperatorTypeEqual + input.Filters = append(input.Filters, f) + } + if quals.Quals[typeNameQualsColumn[1]] != nil { + f.Key = aws.String("AWS:Tag.Value") + if v, ok := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[1], "string").(string); ok { + f.Values = []string{v} + } else if v, ok := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[1], "string").([]*string); ok { + f.Values = getStringSliceWithoutPointer(v) + } + f.Type = types.InventoryQueryOperatorTypeEqual + input.Filters = append(input.Filters, f) + } + continue + } + + if quals.Quals[typeNameQualsColumn[0]] != nil && quals.Quals[typeNameQualsColumn[1]] != nil { + attKey := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[0], "string") + attValue := getQualsValueByColumn(quals.Quals, typeNameQualsColumn[1], "string") + + if k, ok := attKey.(string); ok { + f.Key = aws.String(typeName + "." + k) + if v, ok := attValue.(string); ok { + f.Values = []string{v} + } else if v, ok := attValue.([]*string); ok { + f.Values = getStringSliceWithoutPointer(v) + } + f.Type = types.InventoryQueryOperatorTypeEqual + input.Filters = append(input.Filters, f) + } else if k, ok := attKey.([]*string); ok { + for _, aK := range k { + f.Key = aws.String(typeName + "." + *aK) + if v, ok := attValue.(string); ok { + f.Values = []string{v} + } else if v, ok := attValue.([]*string); ok { + f.Values = getStringSliceWithoutPointer(v) } + f.Type = types.InventoryQueryOperatorTypeEqual + input.Filters = append(input.Filters, f) } } + } } return input } + +func getFilterKeyWithOperator(ctx context.Context, d *transform.TransformData) (interface{}, error) { + param := d.Param.(string) + data := d.KeyColumnQuals[param] + for _, q := range data { + plugin.Logger(ctx).Error("Operator ======>> ", q.Operator) + plugin.Logger(ctx).Error("Value String ======>> ", q.Value.GetStringValue()) + plugin.Logger(ctx).Error("Value List ======>> ", q.Value.GetListValue()) + if q.Operator == "=" { + return q.Value.GetStringValue(), nil + } + } + return "", nil +} + +//// UTILITY FUNCTION + +func getStringSliceWithoutPointer(originalSlice []*string) []string { + convertedSlice := make([]string, 0, len(originalSlice)) + for _, strPtr := range originalSlice { + if strPtr != nil { + convertedSlice = append(convertedSlice, *strPtr) + } + } + return convertedSlice +} diff --git a/aws/table_aws_ssm_inventory_entry.go b/aws/table_aws_ssm_inventory_entry.go index da7355633..0d4a56725 100644 --- a/aws/table_aws_ssm_inventory_entry.go +++ b/aws/table_aws_ssm_inventory_entry.go @@ -3,6 +3,7 @@ package aws import ( "context" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ssm" ssmv1 "github.com/aws/aws-sdk-go/service/ssm" @@ -21,7 +22,7 @@ func tableAwsSSMInventoryEntry(_ context.Context) *plugin.Table { Tags: map[string]string{"service": "ssm", "action": "ListInventoryEntries"}, KeyColumns: plugin.KeyColumnSlice{ {Name: "instance_id", Require: plugin.Optional}, - {Name: "type_name", Require: plugin.Optional}, + {Name: "type_name", Require: plugin.Required}, }, }, GetMatrixItemFunc: SupportedRegionMatrix(ssmv1.EndpointsID), @@ -92,11 +93,11 @@ func listAwsSSMInventoryEntries(ctx context.Context, d *plugin.QueryData, h *plu return nil, nil } } - if d.EqualsQualString("type_name") != "" { - if d.EqualsQualString("type_name") != *inventory.TypeName { - return nil, nil - } - } + // if d.EqualsQualString("entry_type_name") != "" { + // if d.EqualsQualString("entry_type_name") != *inventory.TypeName { + // return nil, nil + // } + // } maxItems := int32(50) @@ -110,7 +111,7 @@ func listAwsSSMInventoryEntries(ctx context.Context, d *plugin.QueryData, h *plu input := &ssm.ListInventoryEntriesInput{ InstanceId: inventory.Id, - TypeName: inventory.TypeName, + TypeName: aws.String(d.EqualsQualString("type_name")), MaxResults: &maxItems, } diff --git a/go.mod b/go.mod index 4d25d0459..ba0192b0b 100644 --- a/go.mod +++ b/go.mod @@ -128,8 +128,8 @@ require ( ) require ( - cloud.google.com/go v0.110.4 // indirect - cloud.google.com/go/compute v1.21.0 // indirect + cloud.google.com/go v0.110.7 // indirect + cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect @@ -165,14 +165,14 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gertd/go-pluralize v0.2.1 // indirect github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang/glog v1.1.0 // indirect + github.com/golang/glog v1.1.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect @@ -225,7 +225,7 @@ require ( golang.org/x/net v0.12.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.11.0 // indirect + golang.org/x/sys v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect diff --git a/go.sum b/go.sum index 8e1b3b1d6..f2e544d6e 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= -cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.7 h1:rJyC7nWRg2jWGZ4wSJ5nY65GTdYJkg0cd/uXb+ACI6o= +cloud.google.com/go v0.110.7/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -68,8 +68,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= -cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -212,7 +212,6 @@ github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3eP github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= @@ -229,7 +228,6 @@ github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv48 github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30/go.mod h1:LUBAO3zNXQjoONBKn/kR1y0Q4cj/D02Ts0uHYjcCQLM= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34/go.mod h1:wZpTEecJe0Btj3IYnDx/VlUzor9wm3fJHyvLpQF0VwY= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= @@ -238,7 +236,6 @@ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24/go.mod h1:gAuCezX/gob6BSMbItsSlMb6WZGV7K2+fWOvk8xBSto= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28/go.mod h1:7VRpKQQedkfIEXb4k52I7swUnZP0wohVajJMRn3vsUw= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= @@ -485,12 +482,8 @@ github.com/aws/aws-sdk-go-v2/service/wellarchitected v1.20.1/go.mod h1:Hb9paYQ+u github.com/aws/aws-sdk-go-v2/service/workspaces v1.28.0 h1:sjfoG4ahd0yE77sKiBokTlZHd9pk1k+vPGNJo6ct2QQ= github.com/aws/aws-sdk-go-v2/service/workspaces v1.28.0/go.mod h1:oudvE1/KOdqMDrq9PG1QjLpvQb8S5R3y2Fci+Vuc6To= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.14.1 h1:EFKMUmH/iHMqLiwoEDx2rRjRQpI1YCn5jTysoaDujFs= -github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -572,8 +565,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -583,8 +576,8 @@ github.com/gocarina/gocsv v0.0.0-20201208093247-67c824bc04d4 h1:Q7s2AN3DhFJKOnzO github.com/gocarina/gocsv v0.0.0-20201208093247-67c824bc04d4/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -636,8 +629,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -664,8 +658,9 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -1113,8 +1108,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= From 048fe728d583c10f1500d649ffee24e0a8c2d10d Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 23 Nov 2023 13:50:54 +0530 Subject: [PATCH 2/5] Updated the table aws_ssm_inventory_entry to use the type name provided by user if not fall back to parent table type name we are getting. --- aws/table_aws_ssm_inventory_entry.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/aws/table_aws_ssm_inventory_entry.go b/aws/table_aws_ssm_inventory_entry.go index 0d4a56725..c523cabe6 100644 --- a/aws/table_aws_ssm_inventory_entry.go +++ b/aws/table_aws_ssm_inventory_entry.go @@ -22,7 +22,7 @@ func tableAwsSSMInventoryEntry(_ context.Context) *plugin.Table { Tags: map[string]string{"service": "ssm", "action": "ListInventoryEntries"}, KeyColumns: plugin.KeyColumnSlice{ {Name: "instance_id", Require: plugin.Optional}, - {Name: "type_name", Require: plugin.Required}, + {Name: "type_name", Require: plugin.Optional}, }, }, GetMatrixItemFunc: SupportedRegionMatrix(ssmv1.EndpointsID), @@ -93,11 +93,13 @@ func listAwsSSMInventoryEntries(ctx context.Context, d *plugin.QueryData, h *plu return nil, nil } } - // if d.EqualsQualString("entry_type_name") != "" { - // if d.EqualsQualString("entry_type_name") != *inventory.TypeName { - // return nil, nil - // } - // } + + typeName := "" + if d.EqualsQualString("type_name") != "" { + typeName = d.EqualsQualString("type_name") + } else { + typeName = *inventory.TypeName + } maxItems := int32(50) @@ -111,7 +113,7 @@ func listAwsSSMInventoryEntries(ctx context.Context, d *plugin.QueryData, h *plu input := &ssm.ListInventoryEntriesInput{ InstanceId: inventory.Id, - TypeName: aws.String(d.EqualsQualString("type_name")), + TypeName: aws.String(typeName), MaxResults: &maxItems, } From a1e5fc2f5b156574d944d87bbc7f3e1f2d0aef80 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Tue, 16 Jan 2024 13:28:16 +0530 Subject: [PATCH 3/5] Updated the column description and did clean-up --- aws/table_aws_ssm_inventory.go | 70 ++++++++++++++-------------------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/aws/table_aws_ssm_inventory.go b/aws/table_aws_ssm_inventory.go index 6a9fa00fd..8ee2609fb 100644 --- a/aws/table_aws_ssm_inventory.go +++ b/aws/table_aws_ssm_inventory.go @@ -103,169 +103,169 @@ func tableAwsSSMInventory(_ context.Context) *plugin.Table { }, { Name: "application_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:Application.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "application_attribute_key"), }, { Name: "application_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:Application.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "application_attribute_value"), }, { Name: "compliance_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:ComplianceItem.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "compliance_attribute_key"), }, { Name: "compliance_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:ComplianceItem.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "compliance_attribute_value"), }, { Name: "file_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:File.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "file_attribute_key"), }, { Name: "file_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:File.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "file_attribute_value"), }, { Name: "instance_detailed_information_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:InstanceDetailedInformation.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "instance_detailed_information_attribute_key"), }, { Name: "instance_detailed_information_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:InstanceDetailedInformation.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "instance_detailed_information_attribute_value"), }, { Name: "instance_information_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:InstanceInformation.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "instance_information_attribute_key"), }, { Name: "instance_information_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:InstanceInformation.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "instance_information_attribute_value"), }, { Name: "network_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:Network.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "network_attribute_key"), }, { Name: "network_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:Network.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "network_attribute_value"), }, { Name: "windows_registry_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:WindowsRegistry.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_registry_attribute_key"), }, { Name: "windows_registry_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:WindowsRegistry.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_registry_attribute_value"), }, { Name: "patch_compliance_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:PatchCompliance.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "patch_compliance_attribute_key"), }, { Name: "patch_compliance_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:PatchCompliance.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "patch_compliance_attribute_value"), }, { Name: "patch_summary_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:PatchSummary.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "patch_summary_attribute_key"), }, { Name: "patch_summary_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:PatchSummary.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "patch_summary_attribute_value"), }, { Name: "resource_group_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:ResourceGroup.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "resource_group_attribute_key"), }, { Name: "resource_group_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:ResourceGroup.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "resource_group_attribute_value"), }, { Name: "service_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:Service.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "service_attribute_key"), }, { Name: "service_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:Service.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "service_attribute_value"), }, { Name: "tag_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:Tag.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "tag_attribute_key"), }, { Name: "tag_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:Tag.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "tag_attribute_value"), }, { Name: "windows_role_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:WindowsRole.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_role_attribute_key"), }, { Name: "windows_role_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:WindowsRole.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_role_attribute_value"), }, { Name: "windows_update_attribute_key", - Description: "", + Description: "The attribute key of the type name AWS:WindowsUpdate.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_update_attribute_key"), }, { Name: "windows_update_attribute_value", - Description: "", + Description: "The value for the attribute key of the type name AWS:WindowsUpdate.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "windows_update_attribute_value"), }, @@ -328,16 +328,7 @@ func listAwsSSMInventories(ctx context.Context, d *plugin.QueryData, _ *plugin.H maxItems := int32(50) input := buildSSMInventoryFilter(ctx, d) - // filter := types.InventoryFilter{ - // Key: aws.String("Custom:InspectorThirdPartyPackage.Message"), - // Values: []string{"SUCCESS"}, - // Type: types.InventoryQueryOperatorTypeEqual, - // } - // input.Filters = []types.InventoryFilter{ - // filter, - // } - - plugin.Logger(ctx).Error("Input filters ===>> ", input.Filters) + // Reduce the basic request limit down if the user has only requested a small number of rows if d.QueryContext.Limit != nil { limit := int32(*d.QueryContext.Limit) @@ -603,9 +594,6 @@ func getFilterKeyWithOperator(ctx context.Context, d *transform.TransformData) ( param := d.Param.(string) data := d.KeyColumnQuals[param] for _, q := range data { - plugin.Logger(ctx).Error("Operator ======>> ", q.Operator) - plugin.Logger(ctx).Error("Value String ======>> ", q.Value.GetStringValue()) - plugin.Logger(ctx).Error("Value List ======>> ", q.Value.GetListValue()) if q.Operator == "=" { return q.Value.GetStringValue(), nil } From 49c595dc6bcd70a7023f6424b682898ef1987cc4 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Tue, 16 Jan 2024 14:06:13 +0530 Subject: [PATCH 4/5] Updated the filter_key and filter_value column description --- aws/table_aws_ssm_inventory.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/table_aws_ssm_inventory.go b/aws/table_aws_ssm_inventory.go index 8ee2609fb..3feb21066 100644 --- a/aws/table_aws_ssm_inventory.go +++ b/aws/table_aws_ssm_inventory.go @@ -79,13 +79,13 @@ func tableAwsSSMInventory(_ context.Context) *plugin.Table { }, { Name: "filter_key", - Description: "The type of inventory item returned by the request.", + Description: "The name of the filter key. Example: inventory filter key where managed node ID 'AWS:InstanceInformation.InstanceId'", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "filter_key"), }, { Name: "filter_value", - Description: "The type of inventory item returned by the request.", + Description: "Inventory filter values. Example: inventory filter where managed node IDs are specified as values 'i-a12b3c4d5e6g'.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "filter_value"), }, From 6eece273262e8b5d531af930b9983b88c42f26fa Mon Sep 17 00:00:00 2001 From: souravTurbot <78197905+bigdatasourav@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:01:57 +0530 Subject: [PATCH 5/5] Update aws/table_aws_ssm_inventory.go Co-authored-by: Madhushree Ray --- aws/table_aws_ssm_inventory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/table_aws_ssm_inventory.go b/aws/table_aws_ssm_inventory.go index 3feb21066..5080229cd 100644 --- a/aws/table_aws_ssm_inventory.go +++ b/aws/table_aws_ssm_inventory.go @@ -79,7 +79,7 @@ func tableAwsSSMInventory(_ context.Context) *plugin.Table { }, { Name: "filter_key", - Description: "The name of the filter key. Example: inventory filter key where managed node ID 'AWS:InstanceInformation.InstanceId'", + Description: "The name of the filter key. Example: inventory filter key where managed node ID 'AWS:InstanceInformation.InstanceId'.", Type: proto.ColumnType_STRING, Transform: transform.FromP(getFilterKeyWithOperator, "filter_key"), },