-
Notifications
You must be signed in to change notification settings - Fork 42
Add github_organization_credential_authorization table #552
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| --- | ||
| title: "Steampipe Table: github_organization_credential_authorization - Query GitHub Organization Credential Authorizations using SQL" | ||
| description: "Allows users to query classic personal access tokens (and SSH keys) that members have authorized to access an organization's resources through SAML single sign-on (SSO)." | ||
| folder: "Organization" | ||
| --- | ||
|
|
||
| # Table: github_organization_credential_authorization - Query GitHub Organization Credential Authorizations using SQL | ||
|
|
||
| GitHub organizations that enforce SAML single sign-on (SSO) require members to authorize their classic personal access tokens (PATs) and SSH keys before those credentials can access organization resources. A credential authorization records the token (or key) that a member has approved for use against the organization, including who it belongs to, its scopes, when it was authorized, when it was last used, and when it expires. | ||
|
|
||
| ## Table Usage Guide | ||
|
|
||
| The `github_organization_credential_authorization` table provides insights into the classic personal access tokens authorized against a GitHub organization. As a security or compliance engineer, use this table to inventory the classic PATs that can reach your organization's resources, review the scopes they have been granted, and identify tokens that are stale, never used, or approaching expiration. The same endpoint also returns authorized SSH keys, which can be distinguished using the `credential_type` column. | ||
|
|
||
| To query this table, the credential must be created under an organization owner. Classic personal access tokens require the `admin:org` scope (specifically `read:org`). | ||
|
|
||
| **Important Notes** | ||
| - You must specify the `organization` column in the `where` or `join` clause to query the table. | ||
| - This table is only available for organizations on **GitHub Enterprise Cloud** that have **SAML single sign-on (SSO)** enabled. Organizations without SAML SSO return no rows. | ||
|
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. This is only true because of the |
||
| - The underlying [SAML SSO authorizations API](https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization) returns both personal access tokens and SSH keys. Filter on `credential_type = 'personal access token'` to return only classic PATs. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### List all credential authorizations for an organization | ||
| Inventory every classic personal access token and SSH key that has been authorized to access your organization's resources. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| credential_id, | ||
| credential_type, | ||
| scopes, | ||
| credential_authorized_at, | ||
| credential_accessed_at, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| login, | ||
| credential_id, | ||
| credential_type, | ||
| scopes, | ||
| credential_authorized_at, | ||
| credential_accessed_at, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org'; | ||
| ``` | ||
|
|
||
| ### List only classic personal access tokens | ||
| Focus on classic PATs (excluding SSH keys) to review the tokens that can access your organization. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| credential_id, | ||
| token_last_eight, | ||
| scopes, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and credential_type = 'personal access token'; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| login, | ||
| credential_id, | ||
| token_last_eight, | ||
| scopes, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and credential_type = 'personal access token'; | ||
| ``` | ||
|
|
||
| ### Find tokens that have expired or expire within 30 days | ||
| Identify personal access tokens that need to be rotated or removed because they are expired or about to expire. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| credential_id, | ||
| scopes, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and authorized_credential_expires_at is not null | ||
| and authorized_credential_expires_at < now() + interval '30 days' | ||
| order by | ||
| authorized_credential_expires_at; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| login, | ||
| credential_id, | ||
| scopes, | ||
| authorized_credential_expires_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and authorized_credential_expires_at is not null | ||
| and authorized_credential_expires_at < datetime('now', '+30 days') | ||
| order by | ||
| authorized_credential_expires_at; | ||
| ``` | ||
|
|
||
| ### Find tokens that have never been used | ||
| Spot credentials that were authorized but never accessed, which are good candidates for revocation. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| credential_id, | ||
| credential_type, | ||
| credential_authorized_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and credential_accessed_at is null; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| login, | ||
| credential_id, | ||
| credential_type, | ||
| credential_authorized_at | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and credential_accessed_at is null; | ||
| ``` | ||
|
|
||
| ### Find tokens with highly privileged scopes | ||
| Surface classic PATs that have been granted broad access such as full `repo` or organization administration scopes. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| credential_id, | ||
| scopes | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| and scopes ?| array['repo', 'admin:org', 'delete_repo']; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| c.login, | ||
| c.credential_id, | ||
| c.scopes | ||
| from | ||
| github_organization_credential_authorization as c, | ||
| json_each(c.scopes) as s | ||
| where | ||
| c.organization = 'my_org' | ||
| and s.value in ('repo', 'admin:org', 'delete_repo'); | ||
| ``` | ||
|
|
||
| ### Count authorized tokens per member | ||
| Understand which members have the most credentials authorized against the organization. | ||
|
|
||
| ```sql+postgres | ||
| select | ||
| login, | ||
| count(*) as authorized_credentials | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| group by | ||
| login | ||
| order by | ||
| authorized_credentials desc; | ||
| ``` | ||
|
|
||
| ```sql+sqlite | ||
| select | ||
| login, | ||
| count(*) as authorized_credentials | ||
| from | ||
| github_organization_credential_authorization | ||
| where | ||
| organization = 'my_org' | ||
| group by | ||
| login | ||
| order by | ||
| authorized_credentials desc; | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,74 +23,75 @@ func Plugin(ctx context.Context) *plugin.Plugin { | |
| DefaultTransform: transform.FromGo(), | ||
| DefaultRetryConfig: retryConfig(), | ||
| TableMap: map[string]*plugin.Table{ | ||
| "github_actions_artifact": tableGitHubActionsArtifact(), | ||
| "github_actions_environment_variable": tableGitHubActionsEnvironmentVariable(), | ||
| "github_actions_organization_variable": tableGitHubActionsOrganizationVariable(), | ||
| "github_actions_repository_runner": tableGitHubActionsRepositoryRunner(), | ||
| "github_actions_repository_secret": tableGitHubActionsRepositorySecret(), | ||
| "github_actions_repository_variable": tableGitHubActionsRepositoryVariable(), | ||
| "github_actions_repository_workflow_run": tableGitHubActionsRepositoryWorkflowRun(), | ||
| "github_audit_log": tableGitHubAuditLog(), | ||
| "github_blob": tableGitHubBlob(), | ||
| "github_branch": tableGitHubBranch(), | ||
| "github_branch_protection": tableGitHubBranchProtection(), | ||
| "github_code_owner": tableGitHubCodeOwner(), | ||
| "github_commit": tableGitHubCommit(), | ||
| "github_community_profile": tableGitHubCommunityProfile(), | ||
| "github_gist": tableGitHubGist(), | ||
| "github_gitignore": tableGitHubGitignore(), | ||
| "github_issue": tableGitHubIssue(), | ||
| "github_issue_comment": tableGitHubIssueComment(), | ||
| "github_license": tableGitHubLicense(), | ||
| "github_my_gist": tableGitHubMyGist(), | ||
| "github_my_issue": tableGitHubMyIssue(), | ||
| "github_my_organization": tableGitHubMyOrganization(), | ||
| "github_my_repository": tableGitHubMyRepository(), | ||
| "github_my_star": tableGitHubMyStar(), | ||
| "github_my_team": tableGitHubMyTeam(), | ||
| "github_organization": tableGitHubOrganization(), | ||
| "github_organization_dependabot_alert": tableGitHubOrganizationDependabotAlert(), | ||
| "github_organization_external_identity": tableGitHubOrganizationExternalIdentity(), | ||
| "github_organization_member": tableGitHubOrganizationMember(), | ||
| "github_organization_collaborator": tableGitHubOrganizationCollaborator(), | ||
| "github_package": tableGitHubPackage(), | ||
| "github_package_version": tableGitHubPackageVersion(), | ||
| "github_pull_request": tableGitHubPullRequest(), | ||
| "github_pull_request_comment": tableGitHubPullRequestComment(), | ||
| "github_pull_request_review": tableGitHubPullRequestReview(), | ||
| "github_rate_limit": tableGitHubRateLimit(), | ||
| "github_rate_limit_graphql": tableGitHubRateLimitGraphQL(), | ||
| "github_release": tableGitHubRelease(), | ||
| "github_repository": tableGitHubRepository(), | ||
| "github_repository_collaborator": tableGitHubRepositoryCollaborator(), | ||
| "github_repository_content": tableGitHubRepositoryContent(), | ||
| "github_repository_dependabot_alert": tableGitHubRepositoryDependabotAlert(), | ||
| "github_repository_deployment": tableGitHubRepositoryDeployment(), | ||
| "github_repository_discussion": tableGitHubRepositoryDiscussion(), | ||
| "github_repository_environment": tableGitHubRepositoryEnvironment(), | ||
| "github_repository_ruleset": tableGitHubRepositoryRuleset(), | ||
| "github_repository_sbom": tableGitHubRepositorySbom(), | ||
| "github_repository_vulnerability_alert": tableGitHubRepositoryVulnerabilityAlert(), | ||
| "github_search_code": tableGitHubSearchCode(), | ||
| "github_search_commit": tableGitHubSearchCommit(), | ||
| "github_search_issue": tableGitHubSearchIssue(), | ||
| "github_search_label": tableGitHubSearchLabel(), | ||
| "github_search_pull_request": tableGitHubSearchPullRequest(), | ||
| "github_search_repository": tableGitHubSearchRepository(), | ||
| "github_search_topic": tableGitHubSearchTopic(), | ||
| "github_search_user": tableGitHubSearchUser(), | ||
| "github_stargazer": tableGitHubStargazer(), | ||
| "github_tag": tableGitHubTag(), | ||
| "github_team": tableGitHubTeam(), | ||
| "github_team_member": tableGitHubTeamMember(), | ||
| "github_team_repository": tableGitHubTeamRepository(), | ||
| "github_traffic_clone_daily": tableGitHubTrafficCloneDaily(), | ||
| "github_traffic_clone_weekly": tableGitHubTrafficCloneWeekly(), | ||
| "github_traffic_view_daily": tableGitHubTrafficViewDaily(), | ||
| "github_traffic_view_weekly": tableGitHubTrafficViewWeekly(), | ||
| "github_tree": tableGitHubTree(), | ||
| "github_user": tableGitHubUser(), | ||
| "github_workflow": tableGitHubWorkflow(), | ||
| "github_actions_artifact": tableGitHubActionsArtifact(), | ||
| "github_actions_environment_variable": tableGitHubActionsEnvironmentVariable(), | ||
| "github_actions_organization_variable": tableGitHubActionsOrganizationVariable(), | ||
| "github_actions_repository_runner": tableGitHubActionsRepositoryRunner(), | ||
| "github_actions_repository_secret": tableGitHubActionsRepositorySecret(), | ||
| "github_actions_repository_variable": tableGitHubActionsRepositoryVariable(), | ||
| "github_actions_repository_workflow_run": tableGitHubActionsRepositoryWorkflowRun(), | ||
| "github_audit_log": tableGitHubAuditLog(), | ||
| "github_blob": tableGitHubBlob(), | ||
| "github_branch": tableGitHubBranch(), | ||
| "github_branch_protection": tableGitHubBranchProtection(), | ||
| "github_code_owner": tableGitHubCodeOwner(), | ||
| "github_commit": tableGitHubCommit(), | ||
| "github_community_profile": tableGitHubCommunityProfile(), | ||
| "github_gist": tableGitHubGist(), | ||
| "github_gitignore": tableGitHubGitignore(), | ||
| "github_issue": tableGitHubIssue(), | ||
| "github_issue_comment": tableGitHubIssueComment(), | ||
| "github_license": tableGitHubLicense(), | ||
| "github_my_gist": tableGitHubMyGist(), | ||
| "github_my_issue": tableGitHubMyIssue(), | ||
| "github_my_organization": tableGitHubMyOrganization(), | ||
| "github_my_repository": tableGitHubMyRepository(), | ||
| "github_my_star": tableGitHubMyStar(), | ||
| "github_my_team": tableGitHubMyTeam(), | ||
| "github_organization": tableGitHubOrganization(), | ||
| "github_organization_credential_authorization": tableGitHubOrganizationCredentialAuthorization(), | ||
|
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. This is where the merge conflict comes from. The new key is the longest in the map, so |
||
| "github_organization_dependabot_alert": tableGitHubOrganizationDependabotAlert(), | ||
| "github_organization_external_identity": tableGitHubOrganizationExternalIdentity(), | ||
| "github_organization_member": tableGitHubOrganizationMember(), | ||
| "github_organization_collaborator": tableGitHubOrganizationCollaborator(), | ||
| "github_package": tableGitHubPackage(), | ||
| "github_package_version": tableGitHubPackageVersion(), | ||
| "github_pull_request": tableGitHubPullRequest(), | ||
| "github_pull_request_comment": tableGitHubPullRequestComment(), | ||
| "github_pull_request_review": tableGitHubPullRequestReview(), | ||
| "github_rate_limit": tableGitHubRateLimit(), | ||
| "github_rate_limit_graphql": tableGitHubRateLimitGraphQL(), | ||
| "github_release": tableGitHubRelease(), | ||
| "github_repository": tableGitHubRepository(), | ||
| "github_repository_collaborator": tableGitHubRepositoryCollaborator(), | ||
| "github_repository_content": tableGitHubRepositoryContent(), | ||
| "github_repository_dependabot_alert": tableGitHubRepositoryDependabotAlert(), | ||
| "github_repository_deployment": tableGitHubRepositoryDeployment(), | ||
| "github_repository_discussion": tableGitHubRepositoryDiscussion(), | ||
| "github_repository_environment": tableGitHubRepositoryEnvironment(), | ||
| "github_repository_ruleset": tableGitHubRepositoryRuleset(), | ||
| "github_repository_sbom": tableGitHubRepositorySbom(), | ||
| "github_repository_vulnerability_alert": tableGitHubRepositoryVulnerabilityAlert(), | ||
| "github_search_code": tableGitHubSearchCode(), | ||
| "github_search_commit": tableGitHubSearchCommit(), | ||
| "github_search_issue": tableGitHubSearchIssue(), | ||
| "github_search_label": tableGitHubSearchLabel(), | ||
| "github_search_pull_request": tableGitHubSearchPullRequest(), | ||
| "github_search_repository": tableGitHubSearchRepository(), | ||
| "github_search_topic": tableGitHubSearchTopic(), | ||
| "github_search_user": tableGitHubSearchUser(), | ||
| "github_stargazer": tableGitHubStargazer(), | ||
| "github_tag": tableGitHubTag(), | ||
| "github_team": tableGitHubTeam(), | ||
| "github_team_member": tableGitHubTeamMember(), | ||
| "github_team_repository": tableGitHubTeamRepository(), | ||
| "github_traffic_clone_daily": tableGitHubTrafficCloneDaily(), | ||
| "github_traffic_clone_weekly": tableGitHubTrafficCloneWeekly(), | ||
| "github_traffic_view_daily": tableGitHubTrafficViewDaily(), | ||
| "github_traffic_view_weekly": tableGitHubTrafficViewWeekly(), | ||
| "github_tree": tableGitHubTree(), | ||
| "github_user": tableGitHubUser(), | ||
| "github_workflow": tableGitHubWorkflow(), | ||
| }, | ||
| } | ||
| return p | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Having
admin:organdread:orgcan't both be right, and GitHub's docs sayadmin:orgfor this endpoint.Could you also mention it's classic PAT only (fine-grained tokens don't support it) and add the permissions block the other org tables have, e.g. github_organization_external_identity.md?