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

Add column hooks in tables github_my_organization, github_my_repository Closes #183 #185

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

karanpopat
Copy link
Contributor

Example query results

Results
> with hooks_info as (
  select
    name,
    h as hook
  from
    github_my_organization,
    jsonb_array_elements(hooks) h
  union
  select
    name,
    h as hook
  from
    github_my_repository,
    jsonb_array_elements(hooks) h
)
select
  hook -> 'id' as resource,
  case
    when (hook ->> 'active' = 'true' 
      and (hook -> 'config' ->> 'insecure_ssl' = '1'
      or hook -> 'config' ->> 'secret' is null
      or hook -> 'config' ->> 'url' not like '%https:%')) then 'alarm'
    else 'ok'
  end as status,
  case
    when (hook ->> 'active' = 'true' 
      and (hook -> 'config' ->> 'insecure_ssl' = '1'
      or hook -> 'config' ->> 'secret' is null
      or hook -> 'config' ->> 'url' not like '%https:%')) then (hook ->> 'id') || ' is an insecure hook'
    else (hook ->> 'id') || ' is a secure hook'
  end as reason
from
  hooks_info
+-----------+--------+-------------------------------+
| resource  | status | reason                        |
+-----------+--------+-------------------------------+
| 371816462 | ok     | 371816462 is a secure hook    |
| 371814098 | alarm  | 371814098 is an insecure hook |
+-----------+--------+-------------------------------+

@karanpopat karanpopat self-assigned this Aug 2, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants