turbot / steampipe

Zero-ETL, infinite possibilities. Live query APIs, code & more with SQL. No DB required.
https://steampipe.io
GNU Affero General Public License v3.0
6.85k stars 264 forks source link

Invalid syntax in mod control query results in masked error #1207

Closed judell closed 2 years ago

judell commented 2 years ago

This snippet fails for an obvious reason.

    select
      html_url as resource,
      case
        when license_spdx_id = 'Apache-2.0' then 'ok'
        else 'alarm' 
      end as status,
      full_name || ' license is ' || license_name as reason,
      full_name
    from
      github_my_repository g
    join
      reposheet."Repos" r
    using (full_name)
   where full_name ~ 'sherlock'

Error: relation "reposheet.Repos" does not exist

When wrapped as a control, it fails for a non-obvious reason.

Error: prepared statement "github_sherlock_license_is_apache_c28a5" does not exist.

Perhaps related to https://github.com/turbot/steampipe/issues/1144?

cbruno10 commented 2 years ago

I just this bug while testing a new mod, with the same conditions as @judell , namely that if I have syntax errors, I get an error like:

cbruno@M1P terraform_draft % steampipe check control.aws_ec2_instance_not_publicly_accessible

+ AWS EC2 instances should not be publicly accessible ............................................................................................................................... 1 / 1 [==========]

  ERROR: prepared statement "terraform_sherlock_aws_ec2_instance_not_publicly_accessib_cb748" does not exist

Summary

OK ...................................................................................................................................................................................... 0 [          ]
SKIP .................................................................................................................................................................................... 0 [          ]
INFO .................................................................................................................................................................................... 0 [          ]
ALARM ................................................................................................................................................................................... 0 [          ]
ERROR ................................................................................................................................................................................... 1 [==========]

TOTAL ............................................................................................................................................................................... 1 / 1 [==========]

But if I run the query in interactive mode, I'm able to see the actual error easily (missing comma):

>     select
      type || ' ' || name as resource,
      case
        when not (arguments -> 'associate_public_ip_address')::bool then 'ok'
        -- Alarm if property is set to true or isn't defined
        else 'alarm'
      end as status,
      name || case when not (arguments -> 'associate_public_ip_address')::bool then ' is not publicly accessible' else ' is publicly accessible' end || '.' as reason
      path
    from
      terraform_resource
    where
      type = 'aws_instance'
Error: syntax error at or near "path"
kaidaguerre commented 2 years ago

fixed in v0.11.0

image

kaidaguerre commented 2 years ago

errors are reported as expected

judell commented 2 years ago

Thanks @kaidaguerre!