Add table github_organization_ruleset#547
Conversation
cbruno10
left a comment
There was a problem hiding this comment.
@romain-pix-cyber Thanks for raising this PR! I've added a few suggestions, and can you please also share the results of running each of the example queries (just for 1 engine is ok), as some of them seem like they wouldn't return the expected set of rows.
| {Name: "organization", Require: plugin.Required}, | ||
| }, | ||
| }, | ||
| Columns: gitHubOrganizationRulesetColumns(), |
There was a problem hiding this comment.
Could you wrap this in commonColumns(...)? Almost every table in the plugin adds the standard login_id column via commonColumns(), and it looks like this was copied from github_repository_ruleset, which is one of the few tables that accidentally omits it.
For instance: https://github.com/turbot/steampipe-plugin-github/blob/main/github/table_github_organization.go#L113
| return nil, nil | ||
| } | ||
|
|
||
| func getAdditionalOrgRules(ctx context.Context, d *plugin.QueryData, client *githubv4.Client, databaseID int, org string, initialCursor githubv4.String) []models.Rule { |
There was a problem hiding this comment.
Is d *plugin.QueryData used, do we need it?
Also, for this function and getAdditionalOrgBypassActors, can we order the args to be consistent between the 2 functions?
|
|
||
| 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. |
There was a problem hiding this comment.
Can you please double check the required permissions? Reading organization rulesets generally needs organization Administration (Read-only), or admin:org for a classic PAT, not Members (Read-only).
There was a problem hiding this comment.
Sorry I doubled-checked this doc : according to the documentation, Reading organization rulesets even needs Administration (Write) for fine-grained Personal Access Tokens.
My own testing confirms this is indeed needed for access with PAT.
| github_organization_ruleset | ||
| where | ||
| organization = 'my-org' | ||
| and enforcement = 'active'; |
There was a problem hiding this comment.
Looking at the GraphQL schema, the values would be uppercase for enforcement, e.g., EVALUATE, DISABLED. Does this example return rows as expected?
There was a problem hiding this comment.
Indeed, the example needs to be uppercase. By re-running through all of them as you asked I corrected this issue as well.
I provided two different example values in the two engine examples
This commit handles review from PR 547 (turbot#547) * clean up typos in docs/tables/github_organization_ruleset.md * refactor arguments in github/tables_github_organization_ruleset.go * Fix error in documentation regarding PAT scopes needed
|
Hi @cbruno10 , thank you for your feedback, I fixed your remarks in the latest commit |
|
Thanks @romain-pix-cyber for the new table! We're planning a new plugin version in the next week or so, so we'll include this table with it. |
Problem : Steampipe allows to query the ruleset from individual repositories but not rulesets defined at the organization level.
This PR solves the issue with a new table github_organization_ruleset :
organization(login: $org) GraphQL path
Example query results
list of rulesets
Details
Results
Details of a ruleset
Results
``` +----------------+----------------------+------------------+---------------------------------------> | name | rule_id | rule_type | rule_parameters > +----------------+----------------------+------------------+---------------------------------------> | Corp-Rule-Infra | RRU_kwDOAL8SuM4E07XQ | NON_FAST_FORWARD | {"Type": "", "UpdateParameters": {"upd> | | | | "", "operator": ""}, "CommitAuthorEmai> | Corp-Rule-Infra | RRU_kwDOAL8SuM4E07XS | PULL_REQUEST | {"Type": "PullRequestParameters", "Upd> | | | | : false, "pattern": "", "operator": ""> +----------------+----------------------+------------------+---------------------------------------> ~ ```Get bypass actors for a specific ruleset
Results
``` +----------------+--------------------------------------+------------+-------------+----------------------+-----------------------------+ | name | bypass_actor_id | deploy_key | bypass_mode | repository_role_name | repository_role_database_id | +----------------+--------------------------------------+------------+-------------+----------------------+-----------------------------+ | Corp-Rule-Infra | MDE1Ol[...]jc4OTcw | false | ALWAYS | | 0 | +----------------+--------------------------------------+------------+-------------+----------------------+-----------------------------+ ```List rulesets with specific enforcement levels
Results
``` +----------------+-------------+ | name | enforcement | +----------------+-------------+ | Corp-Rule-Infra | EVALUATE | +----------------+-------------+ ```List all rulesets created after a specific date
Results
``` +----------------+---------------------------+ | name | created_at | +----------------+---------------------------+ | Corp-Rule-Infra | 2026-02-06T10:47:41+01:00 | +----------------+---------------------------+ ```List rulesets with pull request parameters
Results
``` +-----------------------------+--------------------+-----------------------+---------------------------+---------------------------------+ | id | name | type | require_code_owner_review | required_approving_review_count | +-----------------------------+--------------------+-----------------------+---------------------------+---------------------------------+ | RRS_lA[...]zgBnx1U | Branch protection | PullRequestParameters | false | 1 | | RRS_lA[...]zgC_Erg | Corp-Rule-Infra | PullRequestParameters | false | 1 | +-----------------------------+--------------------+-----------------------+---------------------------+---------------------------------+ ```List rulesets with required status check parameters
Results
``` +----+------+------+------------------------+ | id | name | type | required_status_checks | +----+------+------+------------------------+ +----+------+------+------------------------+ ```