turbot / steampipe-mod-github-sherlock

Interrogate your GitHub resources with the help of the world's greatest detectives: Powerpipe + Steampipe + Sherlock.
https://hub.powerpipe.io/mods/turbot/github_sherlock
Apache License 2.0
39 stars 4 forks source link

Optimize ad-hoc queries to use 'in' operator #Closes 25 #26

Closed bigdatasourav closed 2 years ago

bigdatasourav commented 2 years ago

Result

> select
      r.full_name as resource,
      case
        when b.allow_force_pushes_enabled = 'false' then 'ok'
        else 'alarm'
      end as status,
      r.full_name || ' default branch ' || b.name ||
        case
          when b.allow_force_pushes_enabled = 'false' then ' prevents force push.'
          when b.allow_force_pushes_enabled = 'true' then ' allows force push.'
          -- If not false or true, then null, which means no branch protection rule exists
          else ' is not protected.'
        end as reason,
      r.full_name
    from
      github_my_repository as r
      left join github_branch_protection as b on r.full_name = b.repository_full_name
    where
      visibility = 'public' and r.fork = false and b.name in ('main', 'master')
+---------------------------+--------+------------------------------------------------------------------+---------------------------+
| resource                  | status | reason                                                           | full_name                 |
+---------------------------+--------+------------------------------------------------------------------+---------------------------+
| bigdatasourav/turbot-test | alarm  | bigdatasourav/turbot-test default branch main allows force push. | bigdatasourav/turbot-test |
+---------------------------+--------+------------------------------------------------------------------+---------------------------+