-
Notifications
You must be signed in to change notification settings - Fork 41
Add table github_organization_ruleset #547
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
Open
romain-pix-cyber
wants to merge
1
commit into
turbot:main
Choose a base branch
from
romain-pix-cyber:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+465
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| --- | ||
| title: "Steampipe Table: github_organization_ruleset - Query GitHub Organization Rulesets using SQL" | ||
| description: "Allows users to query GitHub Organization Rulesets, providing details about each ruleset within an organization. This information includes ruleset ID, name, enforcement level, bypass actors, and more." | ||
| folder: "Organization" | ||
| --- | ||
|
|
||
| # Table: github_organization_ruleset - Query GitHub Organization Rulesets using SQL | ||
|
|
||
| GitHub Organization Rulesets is a feature within GitHub that allows organizations to enforce rules and conditions across repositories. These rulesets help manage repository settings, permissions, and enforce best practices at the organization level. | ||
|
|
||
| ## Table Usage Guide | ||
|
|
||
| The `github_organization_ruleset` table provides insights into the rulesets within a GitHub organization. As a security engineer 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 organization-wide policies, manage permissions, and ensure compliance with organizational standards. | ||
|
|
||
| To query this table using a [fine-grained access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token), the following permissions are required: | ||
| - Organization permissions: | ||
| - Members (Read-only): Required to access organization rulesets. | ||
|
|
||
| **Important Notes** | ||
| - You must specify the `organization` column in the `where` or `join` clause to query the table. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### List all rulesets in an organization | ||
| Explore all rulesets within a specific organization, including their enforcement levels and creation dates, to understand and manage organization-wide policies. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| name, | ||
| enforcement, | ||
| created_at | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| name, | ||
| enforcement, | ||
| created_at | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org'; | ||
| ``` | ||
|
|
||
| ### Get rules from a specific ruleset | ||
| Retrieve the detailed rules of a specific ruleset within your organization. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| name, | ||
| r->>'id' as rule_id, | ||
| r->>'type' as rule_type, | ||
| r->>'parameters' as rule_parameters | ||
| from | ||
| github_organization_ruleset, | ||
| jsonb_array_elements(rules) as r | ||
| where | ||
| organization = 'my-org' | ||
| and name = 'my-ruleset'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| 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_parameters | ||
| from | ||
| github_organization_ruleset, | ||
| json_each(rules) as r | ||
| where | ||
| organization = 'my-org' | ||
| and name = 'my-ruleset'; | ||
| ``` | ||
|
|
||
| ### Get bypass actors for a specific ruleset | ||
| Identify the actors who can bypass the ruleset within your organization. | ||
|
|
||
| ```sql+postgres | ||
| 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_id | ||
| from | ||
| github_organization_ruleset, | ||
| jsonb_array_elements(bypass_actors) as b | ||
| where | ||
| organization = 'my-org' | ||
| and name = 'my-ruleset'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| 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_id | ||
| from | ||
| github_organization_ruleset, | ||
| json_each(bypass_actors) as b | ||
| where | ||
| organization = 'my-org' | ||
| and name = 'my-ruleset'; | ||
| ``` | ||
|
|
||
| ### List rulesets with specific enforcement levels | ||
| Identify rulesets within an organization that have specific enforcement levels. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| name, | ||
| enforcement | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org' | ||
| and enforcement = 'active'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the GraphQL schema, the values would be uppercase for |
||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| name, | ||
| enforcement | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org' | ||
| and enforcement = 'active'; | ||
| ``` | ||
|
|
||
| ### List all rulesets created after a specific date | ||
| Retrieve all rulesets created after a specified date, useful for auditing recent policy changes. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| name, | ||
| created_at | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org' | ||
| and created_at > '2023-01-01T00:00:00Z'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| name, | ||
| created_at | ||
| from | ||
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org' | ||
| and created_at > '2023-01-01T00:00:00Z'; | ||
| ``` | ||
|
|
||
| ### List pull request parameters | ||
| List rules with pull request parameters, including code owner review requirements. | ||
|
|
||
| ```sql+postgres | ||
| 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_count | ||
| from | ||
| github_organization_ruleset, | ||
| jsonb_array_elements(rules) as r | ||
| where | ||
| organization = 'my-org' | ||
| and (r -> 'parameters' ->> 'Type') = 'PullRequestParameters'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| 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_count | ||
| from | ||
| github_organization_ruleset, | ||
| json_each(rules) as r | ||
| where | ||
| organization = 'my-org' | ||
| and json_extract(r.value, '$.parameters.Type') = 'PullRequestParameters'; | ||
| ``` | ||
|
|
||
| ### List required status check parameters | ||
| List rules with required status check parameters. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| id, | ||
| name, | ||
| r -> 'parameters' ->> 'Type' as type, | ||
| r -> 'parameters' -> 'RequiredStatusChecksParameters' ->> 'required_status_checks' as required_status_checks | ||
| from | ||
| github_organization_ruleset, | ||
| jsonb_array_elements(rules) as r | ||
| where | ||
| organization = 'my-org'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| id, | ||
| name, | ||
| json_extract(r.value, '$.parameters.Type') as type, | ||
| json_extract(r.value, '$.parameters.RequiredStatusChecksParameters.required_status_checks') as required_status_checks | ||
| from | ||
| github_organization_ruleset, | ||
| json_each(rules) as r | ||
| where | ||
| organization = 'my-org'; | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please double check the required permissions? Reading organization rulesets generally needs organization
Administration (Read-only), oradmin:orgfor a classic PAT, notMembers (Read-only).