diff --git a/pkg/dashboard/dashboardexecute/leaf_run.go b/pkg/dashboard/dashboardexecute/leaf_run.go index cc42ea8ca2..51398c4043 100644 --- a/pkg/dashboard/dashboardexecute/leaf_run.go +++ b/pkg/dashboard/dashboardexecute/leaf_run.go @@ -134,7 +134,10 @@ func (r *LeafRun) addRuntimeDependencies() { return } runtimeDependencies := queryProvider.GetRuntimeDependencies() - for name, dep := range runtimeDependencies { + for n, d := range runtimeDependencies { + // read name and dep into local loop vars to ensure correct value used when getValueFunc is invoked + name := n + dep := d // determine the function to use to retrieve the runtime dependency value var getValueFunc func(string) (any, error) switch dep.PropertyPath.ItemType { @@ -563,6 +566,7 @@ func (r *LeafRun) combineChildData() { func (r *LeafRun) getWithValue(name string, path *modconfig.ParsedPropertyPath) (any, error) { r.withValueMutex.Lock() defer r.withValueMutex.Unlock() + val, ok := r.withValues[name] if !ok { return nil, nil @@ -637,7 +641,6 @@ func (r *LeafRun) getWithValue(name string, path *modconfig.ParsedPropertyPath) } func columnValuesFromRows(column string, rows []map[string]interface{}) (any, error) { - var res = make([]any, len(rows)) for i, row := range rows { var ok bool diff --git a/pkg/steampipeconfig/modconfig/query_args.go b/pkg/steampipeconfig/modconfig/query_args.go index 06586c2a49..78e933b8ca 100644 --- a/pkg/steampipeconfig/modconfig/query_args.go +++ b/pkg/steampipeconfig/modconfig/query_args.go @@ -1,6 +1,7 @@ package modconfig import ( + "encoding/json" "fmt" "strings" @@ -48,14 +49,19 @@ func (q *QueryArgs) ArgsStringList() []string { return argsStringList } -// TODO RENAME -// SafeArgsList convert ArgLists into list of strings but return as an interface slice -func (q *QueryArgs) SafeArgsList() []any { - var argsStringList = make([]any, len(q.ArgList)) +// ConvertArgsList convert ArgList into list of interface{} by unmarshalling +func (q *QueryArgs) ConvertArgsList() ([]any, error) { + var argList = make([]any, len(q.ArgList)) + for i, a := range q.ArgList { - argsStringList[i] = typehelpers.SafeString(a) + if a != nil { + err := json.Unmarshal([]byte(*a), &argList[i]) + if err != nil { + return nil, err + } + } } - return argsStringList + return argList, nil } func NewQueryArgs() *QueryArgs { diff --git a/pkg/steampipeconfig/modconfig/query_args_helpers.go b/pkg/steampipeconfig/modconfig/query_args_helpers.go index c6886c05af..1eab575cd8 100644 --- a/pkg/steampipeconfig/modconfig/query_args_helpers.go +++ b/pkg/steampipeconfig/modconfig/query_args_helpers.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/turbot/steampipe/pkg/type_conversion" "github.com/turbot/steampipe/pkg/utils" ) @@ -69,6 +70,11 @@ func ResolveArgs(source QueryProvider, runtimeArgs *QueryArgs) ([]any, error) { return nil, nil } + // convert any array args into a strongly typed array + for i, v := range paramVals { + paramVals[i] = type_conversion.AnySliceToTypedSlice(v) + } + // success! return paramVals, nil } @@ -135,7 +141,10 @@ func resolvePositionalParameters(queryProvider QueryProvider, args *QueryArgs) ( if len(params) == 0 { // no params defined, so we return as many args as are provided // (convert from *string to string) - argValues = args.SafeArgsList() + argValues, err = args.ConvertArgsList() + if err != nil { + return nil, nil, err + } return argValues, nil, nil } @@ -173,7 +182,6 @@ func resolvePositionalParameters(queryProvider QueryProvider, args *QueryArgs) ( if err != nil { return nil, nil, err } - argValues[i] = argVal } else if defaultValue != nil { // so we have run out of provided params - is there a default? diff --git a/pkg/steampipeconfig/testdata/manual testing /report/.mod.cache.json b/pkg/steampipeconfig/testdata/manual testing /report/.mod.cache.json deleted file mode 100644 index c98437726b..0000000000 --- a/pkg/steampipeconfig/testdata/manual testing /report/.mod.cache.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "m1": { - "github.com/turbot/steampipe-mod-aws-compliance": { - "Name": "github.com/turbot/steampipe-mod-aws-compliance", - "Version": "0.23.0", - "Constraint": "0" - } - } -} \ No newline at end of file diff --git a/pkg/steampipeconfig/testdata/manual testing /report/manual_control.sql b/pkg/steampipeconfig/testdata/manual testing /report/manual_control.sql deleted file mode 100644 index 23e70c2f78..0000000000 --- a/pkg/steampipeconfig/testdata/manual testing /report/manual_control.sql +++ /dev/null @@ -1,9 +0,0 @@ -select - -- Required Columns - 'arn:' || partition || ':::' || account_id as resource, - 'info' as status, - 'Manual verification required.' as reason, - -- Additional Dimensions - account_id -from - aws_account; diff --git a/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/queries/aws_iam_entities.sql b/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/queries/aws_iam_entities.sql deleted file mode 100644 index 17914f0268..0000000000 --- a/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/queries/aws_iam_entities.sql +++ /dev/null @@ -1 +0,0 @@ -select * from foo \ No newline at end of file diff --git a/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/reports.sp b/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/reports.sp deleted file mode 100644 index 146e5f0821..0000000000 --- a/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/reports.sp +++ /dev/null @@ -1,41 +0,0 @@ -report simple { - title = "Simple" - - panel header { - source = "steampipe.panel.markdown_" - text = "# Hello World" - } -} - -report two_panel { - title = "Two Panel" - - panel hello { - source = "steampipe.panel.markdown" - text = "# Hello World" - width = 6 - height = 1 - } - - panel goodbye { - source = "steampipe.panel.markdown" - text = "# Goodbye Universe" - width = 6 - height = 2 - } -} - -report barchart { - title = "Bar Chart" - - panel header { - source = "steampipe.panel.markdown" - text = "# Simple Bar Chart" - } - - panel barchart { - title = "AWS IAM Entities" - source = "steampipe.panel.barchart" - sql = query.aws_iam_entities.sql - } -} diff --git a/pkg/steampipeconfig/testdata/manual_testing/args/with1/dashboard.sp b/pkg/steampipeconfig/testdata/manual_testing/args/with1/dashboard.sp new file mode 100644 index 0000000000..f8274b61c1 --- /dev/null +++ b/pkg/steampipeconfig/testdata/manual_testing/args/with1/dashboard.sp @@ -0,0 +1,188 @@ + +dashboard "bug_column_does_not_exist" { + title = "column does not exist" + + + input "policy_arn" { + title = "Select a policy:" + query = query.test1_aws_iam_policy_input + width = 4 + } + + + container { + + graph { + title = "Relationships" + type = "graph" + direction = "left_right" //"TD" + + with "attached_users" { + sql = <<-EOQ + select + u.arn as user_arn + --,policy_arn + from + aws_iam_user as u, + jsonb_array_elements_text(attached_policy_arns) as policy_arn + where + policy_arn = $1; + --policy_arn = 'arn:aws:iam::aws:policy/AdministratorAccess' + EOQ + + param policy_arn { + // commented out becuase input not working here yet.. + // default = self.input.policy_arn.value + default = "arn:aws:iam::aws:policy/AdministratorAccess" + } + + } + + with "attached_roles" { + sql = <<-EOQ + select + arn as role_arn + from + aws_iam_role, + jsonb_array_elements_text(attached_policy_arns) as policy_arn + where + policy_arn = $1; + EOQ + + #args = [self.input.policy_arn.value] + #args = ["arn:aws:iam::aws:policy/AdministratorAccess"] + + param policy_arn { + //default = self.input.policy_arn.value + default = "arn:aws:iam::aws:policy/AdministratorAccess" + } + } + + + nodes = [ + node.test1_aws_iam_policy_node, + node.test1_aws_iam_user_nodes, + ] + + edges = [ + edge.test1_aws_iam_policy_from_iam_user_edges, + ] + + args = { + policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" //self.input.policy_arn.value + + //// works if you hardcode the list + policy_arns = ["arn:aws:iam::aws:policy/AdministratorAccess"] + + // this causes cannot serialize unknown values + //policy_arns = [self.input.policy_arn.value] + + user_arns = with.attached_users.rows[*].user_arn + role_arns = with.attached_roles.rows[*].role_arn + + } + } + + } +} + +query "test1_aws_iam_policy_input" { + sql = <<-EOQ + with policies as ( + select + title as label, + arn as value, + json_build_object( + 'account_id', account_id + ) as tags + from + aws_iam_policy + where + not is_aws_managed + + union all select + distinct on (arn) + title as label, + arn as value, + json_build_object( + 'account_id', 'AWS Managed' + ) as tags + from + aws_iam_policy + where + is_aws_managed + ) + select + * + from + policies + order by + label; + EOQ +} + + + +node "test1_aws_iam_policy_node" { + sql = <<-EOQ + select + distinct on (arn) + arn as id, + name as title, + jsonb_build_object( + 'ARN', arn, + 'AWS Managed', is_aws_managed::text, + 'Attached', is_attached::text, + 'Create Date', create_date, + 'Account ID', account_id + ) as properties + from + aws_iam_policy + where + arn = $1; + EOQ + + param "policy_arn" {} +} + + +node "test1_aws_iam_user_nodes" { + + sql = <<-EOQ + select + arn as id, + name as title, + jsonb_build_object( + 'ARN', arn, + 'Path', path, + 'Create Date', create_date, + 'MFA Enabled', mfa_enabled::text, + 'Account ID', account_id + ) as properties + from + aws_iam_user + where + arn = any($1::text[]); + EOQ + + param "user_arns" {} +} + + + +edge "test1_aws_iam_policy_from_iam_user_edges" { + title = "attaches" + + sql = <<-EOQ + select + policy_arns as to_id, + user_arns as from_id + from + unnest($1::text[]) as policy_arns, + unnest($2::text[]) as user_arns + EOQ + + param "policy_arns" {} + param "user_arns" {} + +} diff --git a/pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/args/with1/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /steampipe-mod-reports-poc/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/args/with1/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual_testing/args/with1/query.sp b/pkg/steampipeconfig/testdata/manual_testing/args/with1/query.sp new file mode 100644 index 0000000000..98f2417fe4 --- /dev/null +++ b/pkg/steampipeconfig/testdata/manual_testing/args/with1/query.sp @@ -0,0 +1,19 @@ +query "q1" { + description = "test array argument" + sql = <<-EOQ + select + name + from + aws_iam_user + where + arn = any($1::text[]); + + EOQ + + param arns{ + default = [ + "arn:aws:iam::876515858155:user/lalit", + "arn:aws:iam::876515858155:user/mike" + ] + } +} \ No newline at end of file diff --git a/pkg/steampipeconfig/testdata/manual testing /dashboard_container_inputs/inputs.sp b/pkg/steampipeconfig/testdata/manual_testing/dashboard_container_inputs/inputs.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /dashboard_container_inputs/inputs.sp rename to pkg/steampipeconfig/testdata/manual_testing/dashboard_container_inputs/inputs.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /dashboard_container_inputs/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/dashboard_container_inputs/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /dashboard_container_inputs/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/dashboard_container_inputs/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /dashboard_global_and_dashboard_inputs/inputs.sp b/pkg/steampipeconfig/testdata/manual_testing/dashboard_global_and_dashboard_inputs/inputs.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /dashboard_global_and_dashboard_inputs/inputs.sp rename to pkg/steampipeconfig/testdata/manual_testing/dashboard_global_and_dashboard_inputs/inputs.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /dashboard_global_and_dashboard_inputs/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/dashboard_global_and_dashboard_inputs/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /dashboard_global_and_dashboard_inputs/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/dashboard_global_and_dashboard_inputs/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /report_test/dashboard.sp b/pkg/steampipeconfig/testdata/manual_testing/demo/variables_demo/vars.spvars similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_test/dashboard.sp rename to pkg/steampipeconfig/testdata/manual_testing/demo/variables_demo/vars.spvars diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control10.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control10.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control10.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control10.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control11.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control11.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control11.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control11.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control12.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control12.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control12.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control12.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control13.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control13.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control13.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control13.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control14.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control14.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control14.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control14.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control2.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control2.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control2.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control2.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control3.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control3.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control3.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control3.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control4.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control4.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control4.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control4.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control5.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control5.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control5.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control5.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control6.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control6.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control6.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control6.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control7.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control7.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control7.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control7.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control8.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control8.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control8.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control8.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c1/control9.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control9.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c1/control9.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c1/control9.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control10.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control10.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control10.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control10.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control11.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control11.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control11.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control11.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control12.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control12.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control12.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control12.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control13.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control13.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control13.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control13.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control14.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control14.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control14.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control14.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control2.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control2.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control2.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control2.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control3.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control3.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control3.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control3.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control4.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control4.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control4.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control4.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control5.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control5.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control5.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control5.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control6.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control6.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control6.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control6.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control7.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control7.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control7.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control7.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control8.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control8.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control8.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control8.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c2/control9.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control9.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c2/control9.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c2/control9.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control10.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control10.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control10.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control10.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control11.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control11.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control11.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control11.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control12.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control12.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control12.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control12.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control13.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control13.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control13.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control13.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control14.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control14.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control14.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control14.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control2.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control2.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control2.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control2.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control3.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control3.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control3.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control3.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control4.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control4.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control4.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control4.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control5.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control5.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control5.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control5.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control6.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control6.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control6.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control6.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control7.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control7.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control7.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control7.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control8.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control8.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control8.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control8.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c3/control9.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control9.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c3/control9.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c3/control9.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control10.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control10.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control10.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control10.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control11.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control11.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control11.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control11.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control12.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control12.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control12.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control12.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control13.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control13.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control13.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control13.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control14.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control14.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control14.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control14.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control2.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control2.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control2.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control2.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control3.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control3.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control3.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control3.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control4.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control4.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control4.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control4.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control5.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control5.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control5.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control5.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control6.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control6.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control6.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control6.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control7.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control7.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control7.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control7.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control8.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control8.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control8.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control8.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/c4/control9.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control9.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/c4/control9.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/c4/control9.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/many controls/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/many controls/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q1.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q1.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q1.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q1.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q10.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q10.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q10.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q10.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q11.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q11.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q11.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q11.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q12.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q12.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q12.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q12.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q13.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q13.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q13.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q13.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q14.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q14.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q14.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q14.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q15.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q15.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q15.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q15.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q16.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q16.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q16.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q16.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q17.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q17.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q17.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q17.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q18.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q18.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q18.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q18.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q19.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q19.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q19.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q19.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q2.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q2.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q2.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q2.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q20.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q20.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q20.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q20.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q3.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q3.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q3.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q3.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q4.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q4.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q4.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q4.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q5.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q5.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q5.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q5.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q6.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q6.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q6.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q6.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q7.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q7.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q7.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q7.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q8.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q8.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q8.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q8.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /many controls/queries/q9.sql b/pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q9.sql similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /many controls/queries/q9.sql rename to pkg/steampipeconfig/testdata/manual_testing/many controls/queries/q9.sql diff --git a/pkg/steampipeconfig/testdata/manual testing /report_dep_control/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/report_dep_control/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_dep_control/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_dep_control/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /report_dep_control/report.sp b/pkg/steampipeconfig/testdata/manual_testing/report_dep_control/report.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_dep_control/report.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_dep_control/report.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /report_dupe_test/report.sp b/pkg/steampipeconfig/testdata/manual_testing/report_dupe_test/report.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_dupe_test/report.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_dupe_test/report.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /report_ref_test/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/report_ref_test/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_ref_test/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_ref_test/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /report_ref_test/report.sp b/pkg/steampipeconfig/testdata/manual_testing/report_ref_test/report.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_ref_test/report.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_ref_test/report.sp diff --git a/pkg/steampipeconfig/testdata/manual_testing/report_test/dashboard.sp b/pkg/steampipeconfig/testdata/manual_testing/report_test/dashboard.sp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pkg/steampipeconfig/testdata/manual testing /report_test/inputs.md b/pkg/steampipeconfig/testdata/manual_testing/report_test/inputs.md similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_test/inputs.md rename to pkg/steampipeconfig/testdata/manual_testing/report_test/inputs.md diff --git a/pkg/steampipeconfig/testdata/manual testing /report_test/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/report_test/mod.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /report_test/mod.sp rename to pkg/steampipeconfig/testdata/manual_testing/report_test/mod.sp diff --git a/pkg/steampipeconfig/testdata/manual_testing/steampipe-mod-reports-poc/mod.sp b/pkg/steampipeconfig/testdata/manual_testing/steampipe-mod-reports-poc/mod.sp new file mode 100644 index 0000000000..5cf8b03823 --- /dev/null +++ b/pkg/steampipeconfig/testdata/manual_testing/steampipe-mod-reports-poc/mod.sp @@ -0,0 +1,3 @@ +mod reports_poc { + title = "Reports POC" +} \ No newline at end of file diff --git a/pkg/steampipeconfig/testdata/manual testing /variables/query.sp b/pkg/steampipeconfig/testdata/manual_testing/variables/query.sp similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /variables/query.sp rename to pkg/steampipeconfig/testdata/manual_testing/variables/query.sp diff --git a/pkg/steampipeconfig/testdata/manual testing /variables/steampipe.spvars b/pkg/steampipeconfig/testdata/manual_testing/variables/steampipe.spvars similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /variables/steampipe.spvars rename to pkg/steampipeconfig/testdata/manual_testing/variables/steampipe.spvars diff --git a/pkg/steampipeconfig/testdata/manual testing /variables/v1.spvars b/pkg/steampipeconfig/testdata/manual_testing/variables/v1.spvars similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /variables/v1.spvars rename to pkg/steampipeconfig/testdata/manual_testing/variables/v1.spvars diff --git a/pkg/steampipeconfig/testdata/manual testing /variables/vars2.auto.spvars b/pkg/steampipeconfig/testdata/manual_testing/variables/vars2.auto.spvars similarity index 100% rename from pkg/steampipeconfig/testdata/manual testing /variables/vars2.auto.spvars rename to pkg/steampipeconfig/testdata/manual_testing/variables/vars2.auto.spvars diff --git a/pkg/type_conversion/slice.go b/pkg/type_conversion/slice.go new file mode 100644 index 0000000000..2a71b1123c --- /dev/null +++ b/pkg/type_conversion/slice.go @@ -0,0 +1,46 @@ +package type_conversion + +import ( + "reflect" + "time" +) + +// AnySliceToTypedSlice determines whether input is []any and if so converts to an array of the underlying type +func AnySliceToTypedSlice(input any) any { + result := input + switch result.(type) { + case []any: + val := reflect.ValueOf(result) + if val.Kind() == reflect.Slice { + if val.Len() > 0 { + elem := val.Index(0).Interface() + switch elem.(type) { + case int16: + result = ToTypedSlice[int16](result.([]any)) + case int32: + result = ToTypedSlice[int32](result.([]any)) + case int64: + result = ToTypedSlice[int64](result.([]any)) + case float32: + result = ToTypedSlice[float32](result.([]any)) + case float64: + result = ToTypedSlice[float64](result.([]any)) + case string: + result = ToTypedSlice[string](result.([]any)) + case time.Time: + result = ToTypedSlice[time.Time](result.([]any)) + } + } + } + } + return result +} + +// ToTypedSlice converts []any to []T +func ToTypedSlice[T any](input []any) []T { + res := make([]T, len(input)) + for i, val := range input { + res[i] = val.(T) + } + return res +}