Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Invalid memory address or nil pointer dereference when cache returns a nil Qual value #442

Closed
aminvielledebatAtBedrock opened this issue Oct 27, 2022 · 3 comments

Comments

@aminvielledebatAtBedrock
Copy link
Contributor

aminvielledebatAtBedrock commented Oct 27, 2022

Hi steampipe team !

When i was developping a new query based on github_repository_content, i encountered the error of the death Invalid memory address or nil pointer dereference.

The query used to reproduce it (sorry, it's based on the github.github_repository_content table wich is not yet available (review in progress)) :

select
    ksa._ctx->'connection_name' as cluster_name
     ,namespace
     ,tags->'project' as project, lower(tags->>'team') as team , tags->'customer' as customer, tags->'tenant' as tenant
     ,case
          when ksa.annotations::text like '%role-arn%' then true else false
    end as has_irsa_enabled_in_service_account
     ,ksa.annotations->'eks.amazonaws.com/role-arn' as used_aws_role
     ,case when
               repo.full_name is not null then true else false
    end as github_repository_is_found
     , repo.full_name
     ,case
         when c.content::jsonb->'require' ? 'aws/aws-sdk-php' then  true
         when c.content::jsonb->'require' ?'aws/aws-sdk-php-symfony' then true
         else false
     end as need_irsa_in_composer
-- list all service accounts deployed on our kubernetes clusters
from kube_api_prod_all.kubernetes_service_account ksa
-- get the corresponding microservice repository based on "project" tag
left outer join github.github_my_repository repo
on repo.full_name like  '%' || (ksa.tags->>'project'::text)
-- get the composer.json file allowing us to identify wich project uses aws services with the sdk
left outer join github.github_repository_content c
on repo.full_name = c.repository_full_name and c.repository_content_path = 'composer.json'
where
    tags->'project' is not null
order by namespace, team, project, tenant

I try debugging it, and i found that this issue occurs when the plugin cache returns a cache record with other nil Qual Value (when dealing with my new table (see PR)
I don't know if the main trouble comes from the query, or the github plugin, but it seems to come from this line https://github.com/turbot/steampipe-plugin-sdk/blob/main/grpc/proto/qual.go#L34

Do you think this behaviour is legit ?
For now, i'm writting a PR to fix it.

@aminvielledebatAtBedrock
Copy link
Contributor Author

cc @cbruno10

@cbruno10
Copy link
Contributor

Hey @aminvielledebatAtBedrock , thanks for opening the issue! I'll defer to @kaidaguerre on this, as he's the maintainer of the SDK, but will pitch in wherever I can.

@kaidaguerre
Copy link
Contributor

Thanks for raising this @aminvielledebatAtBedrock - that is a bug, and the PR you have raised looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants