Table: github_repository_ruleset - Query GitHub Repository Rulesets using SQL
GitHub Repository Rulesets is a feature within GitHub that allows organizations to enforce rules and conditions on repositories. These rulesets help manage repository settings, and permissions, and enforce best practices.
Table Usage Guide
The github_repository_ruleset
table provides insights into the rulesets within GitHub repositories. As a project manager or team lead, you can explore ruleset-specific details through this table, including ruleset ID, name, enforcement level, bypass actors, and conditions. Utilize it to enforce repository policies, manage permissions, and ensure compliance with organizational standards.
Important Notes
- You must specify the
repository_full_name
column in thewhere
orjoin
clause to query the table.
Examples
List all rulesets in a repository
Explore all rulesets within a specific repository, including their enforcement levels and creation dates, to understand and manage repository policies.
select name, enforcement, created_atfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule';
select name, enforcement, created_atfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule';
Get rules from a specific ruleset
Retrieve the detailed rules of a specific ruleset within your repository. This can be useful for reviewing the rules enforced and ensuring they align with your project requirements.
select name, r ->> 'id' as rule_id, r ->> 'type' as rule_type, r ->> 'parameters' as rule_parametersfrom github_repository_ruleset, jsonb_array_elements(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and name = 'test34';
select name, json_extract(r.value, '$.id') as rule_id, json_extract(r.value, '$.type') as rule_type, json_extract(r.value, '$.parameters') as rule_parametersfrom github_repository_ruleset, json_each(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and name = 'test34';
Get bypass actors for a specific ruleset
Identify the actors who can bypass the ruleset within your repository. This information is crucial for managing exceptions and understanding who has elevated permissions.
select name, b ->> 'id' as bypass_actor_id, b ->> 'deploy_key' as deploy_key, b ->> 'bypass_mode' as bypass_mode, b ->> 'repository_role_name' as repository_role_name, b ->> 'repository_role_database_id' as repository_role_database_idfrom github_repository_ruleset, jsonb_array_elements(bypass_actors) as bwhere repository_full_name = 'pro-cloud-49/test-rule' and name = 'test34';
select name, json_extract(b.value, '$.id') as bypass_actor_id, json_extract(b.value, '$.deploy_key') as deploy_key, json_extract(b.value, '$.bypass_mode') as bypass_mode, json_extract(b.value, '$.repository_role_name') as repository_role_name, json_extract(b.value, '$.repository_role_database_id') as repository_role_database_idfrom github_repository_ruleset, json_each(bypass_actors) as bwhere repository_full_name = 'pro-cloud-49/test-rule' and name = 'test34';
List rulesets with specific enforcement levels
Identify rulesets within a repository that have specific enforcement levels, helping to understand the compliance and security posture of the repository.
select name, enforcementfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule' and enforcement = 'strict';
select name, enforcementfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule' and enforcement = 'strict';
List all rulesets created after a specific date
Retrieve all rulesets that were created after a specified date, useful for auditing and tracking recent changes in repository policies.
select name, created_atfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule' and created_at > '2023-01-01T00:00:00Z';
select name, created_atfrom github_repository_rulesetwhere repository_full_name = 'pro-cloud-49/test-rule' and created_at > '2023-01-01T00:00:00Z';
List update parameters
List rules with update parameters, focusing on the update_allows_fetch_and_merge
setting.
select id, name, r -> 'parameters' ->> 'Type' as type, r -> 'parameters' -> 'UpdateParameters' ->> 'update_allows_fetch_and_merge' as update_allows_fetch_and_mergefrom github_repository_ruleset, jsonb_array_elements(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and (r -> 'parameters' ->> 'Type') = 'UpdateParameters';
select id, name, json_extract(r.value, '$.parameters.Type') as type, json_extract( r.value, '$.parameters.UpdateParameters.update_allows_fetch_and_merge' ) as update_allows_fetch_and_mergefrom github_repository_ruleset, json_each(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and json_extract(r.value, '$.parameters.Type') = 'UpdateParameters';
List workflow parameters
List rules with workflow parameters, focusing on the workflow configurations.
select id, name, r -> 'parameters' ->> 'Type' as type, r -> 'parameters' -> 'WorkflowsParameters' ->> 'workflows' as workflowsfrom github_repository_ruleset, jsonb_array_elements(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and (r -> 'parameters' ->> 'Type') = 'WorkflowsParameters';
select id, name, json_extract(r.value, '$.parameters.Type') as type, json_extract( r.value, '$.parameters.WorkflowsParameters.workflows' ) as workflowsfrom github_repository_ruleset, json_each(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and json_extract(r.value, '$.parameters.Type') = 'WorkflowsParameters';
List pull request parameters
List rules with pull request parameters, including various settings such as code owner review requirements.
select id, name, r -> 'parameters' ->> 'Type' as type, r -> 'parameters' -> 'PullRequestParameters' ->> 'require_code_owner_review' as require_code_owner_review, r -> 'parameters' -> 'PullRequestParameters' ->> 'required_approving_review_count' as required_approving_review_countfrom github_repository_ruleset, jsonb_array_elements(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and (r -> 'parameters' ->> 'Type') = 'PullRequestParameters';
select id, name, json_extract(r.value, '$.parameters.Type') as type, json_extract( r.value, '$.parameters.PullRequestParameters.require_code_owner_review' ) as require_code_owner_review, json_extract( r.value, '$.parameters.PullRequestParameters.required_approving_review_count' ) as required_approving_review_countfrom github_repository_ruleset, json_each(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule' and json_extract(r.value, '$.parameters.Type') = 'PullRequestParameters';
List required status check parameters
List rules with required status check parameters.
select id, name, r -> 'parameters' ->> 'Type' as type, r -> 'parameters' -> 'RequiredStatusChecksParameters' ->> 'required_status_checks' as required_status_checksfrom github_repository_ruleset, jsonb_array_elements(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule';
select id, name, json_extract(r.value, '$.parameters.Type') as type, json_extract( r.value, '$.parameters.RequiredStatusChecksParameters.required_status_checks' ) as required_status_checksfrom github_repository_ruleset, json_each(rules) as rwhere repository_full_name = 'pro-cloud-49/test-rule';
Schema for github_repository_ruleset
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
bypass_actors | jsonb | The list of actors who can bypass the ruleset. | |
conditions | jsonb | The conditions under which the ruleset applies. | |
created_at | timestamp with time zone | The date and time when the ruleset was created. | |
database_id | bigint | The database ID of the ruleset. | |
enforcement | text | The enforcement level of the ruleset. | |
id | text | The ID of the ruleset. | |
name | text | The name of the ruleset. | |
repository_full_name | text | = | Full name of the repository that contains the ruleset. |
rules | jsonb | The list of rules in the ruleset. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- github
You can pass the configuration to the command with the --config
argument:
steampipe_export_github --config '<your_config>' github_repository_ruleset