Table: github_my_repository - Query GitHub Repositories using SQL
GitHub is a version control system that allows developers to collaborate on projects. Repositories in GitHub contain all of the project files and each file's revision history. They also contain a README file which provides information about the project. Repositories can be public or private, and they can be accessed and managed on GitHub's website.
Table Usage Guide
The github_my_repository
table provides insights into personal GitHub repositories. As a developer or project manager, explore repository-specific details through this table, including repository name, description, owner, and visibility status. Utilize it to manage and monitor your repositories, such as checking the visibility status, reviewing the repository description, and identifying the repository owner.
Important Notes
- You can own repositories individually, or you can share ownership of repositories with other people in an organization. The
github_my_repository
table will list tables you own, you collaborate on, or that belong to your organizations. - To query ANY repository, including public repos, use the
github_repository
table.
Examples
List of repositories that you or your organizations own or contribute to
Explore which repositories you or your organizations have ownership of or contribute to, in order to better understand your coding involvement and collaborations. This could be particularly useful for tracking project participation or evaluating the spread of your contributions.
select name, owner_login, name_with_ownerfrom github_my_repositoryorder by name_with_owner;
select name, owner_login, name_with_ownerfrom github_my_repositoryorder by name_with_owner;
Show repository stats
Explore your GitHub repositories' statistics to gain insights into popularity and user engagement. This query is useful in understanding the overall performance and reach of your repositories, including the primary language used, number of forks, stars, subscribers, watchers, and the last updated date.
select name, owner_login, primary_language ->> 'name' as language, fork_count, stargazer_count, subscribers_count, watchers_total_count, updated_at as last_updated, descriptionfrom github_my_repository;
select name, owner_login, json_extract(primary_language, '$.name') as language, fork_count, stargazer_count, subscribers_count, watchers_total_count, updated_at as last_updated, descriptionfrom github_my_repository;
List your public repositories
Explore which of your repositories on GitHub are publicly accessible. This is useful for ensuring your private work remains confidential while sharing the projects you wish to showcase.
select name, is_private, visibility, owner_loginfrom github_my_repositorywhere not is_private;
select name, is_private, visibility, owner_loginfrom github_my_repositorywhere not is_private;
OR
select name, is_private, visibilityfrom github_my_repositorywhere visibility = 'PUBLIC';
select name, is_private, visibilityfrom github_my_repositorywhere visibility = 'PUBLIC';
List all your repositories and their collaborators
Gain insights into the collaboration dynamics of your GitHub repositories by identifying the collaborators and their respective permissions. This can be useful in assessing access levels and ensuring proper project management.
select r.name_with_owner as repository_full_name, c.user_login, c.permissionfrom github_my_repository r, github_repository_collaborator cwhere r.name_with_owner = c.repository_full_name;
select r.name_with_owner as repository_full_name, c.user_login, c.permissionfrom github_my_repository r, github_repository_collaborator cwhere r.name_with_owner = c.repository_full_name;
List all your repository collaborators with admin or maintainer permissions
Identify individuals with elevated access rights within your repositories. This can help enhance security by ensuring only necessary permissions are granted.
select r.name_with_owner as repository_full_name, c.user_login, c.permissionfrom github_my_repository r, github_repository_collaborator cwhere r.name_with_owner = c.repository_full_name and permission in ('ADMIN', 'MAINTAIN');
select r.name_with_owner as repository_full_name, c.user_login, c.permissionfrom github_my_repository r join github_repository_collaborator c on r.name_with_owner = c.repository_full_namewhere c.permission in ('ADMIN', 'MAINTAIN');
List repository hooks that are insecure
Discover the segments that have insecure settings in your GitHub repository hooks. This query is useful to identify potential security vulnerabilities in your repositories' hooks configuration.
select name as repository, hookfrom github_my_repository, jsonb_array_elements(hooks) as hookwhere hook -> 'config' ->> 'insecure_ssl' = '1' or hook -> 'config' ->> 'secret' is null or hook -> 'config' ->> 'url' not like '%https:%';
select name as repository, hook.value as hookfrom github_my_repository, json_each(hooks) as hookwhere json_extract(hook.value, '$.config.insecure_ssl') = '1' or json_extract(hook.value, '$.config.secret') is null or json_extract(hook.value, '$.config.url') not like '%https:%';
Query examples
- default_branch_protection_disabled_unverifiable_count
- default_branch_protection_enabled_count
- default_branch_protection_table
- open_issue_1_year_count
- open_issue_24_hours_count
- open_issue_30_90_days_count
- open_issue_30_days_count
- open_issue_90_365_days_count
- open_issue_count
- open_issue_table
- open_pull_request_1_year_count
- open_pull_request_24_hours_count
- open_pull_request_30_90_days_count
- open_pull_request_30_days_count
- open_pull_request_90_365_days_count
- open_pull_request_count
- open_pull_request_table
- repository_1_100_stars_count
- repository_101_500_stars_count
- repository_501_1000_stars_count
- repository_count
- repository_license_table
- repository_other_license_count
- repository_over_1000_stars_count
- repository_permissive_license_count
- repository_popular_copyleft_license_count
- repository_private_count
- repository_public_count
- repository_security_advisory_count
- repository_security_advisory_critical_count
- repository_security_advisory_high_count
- repository_security_advisory_low_count
- repository_security_advisory_medium_count
- repository_security_advisory_table
- repository_stargazer_table
- repository_unstarred_count
- repository_visibility_table
- repository_weak_copyleft_license_count
- repository_without_license_count
Control examples
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.10 Ensure open Git branches are up to date before they can be merged into code base
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.11 Ensure all open comments are resolved before allowing code change merging
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.12 Ensure verification of signed commits for new changes before merging
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.13 Ensure linear history is required
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.14 Ensure branch protection rules are enforced for administrators
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.15 Ensure pushing or merging of new code is restricted to specific individuals or teams
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.16 Ensure force push code to branches is denied
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.17 Ensure branch deletions are denied
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.3 Ensure any change to code receives approval of two strongly authenticated users
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.4 Ensure previous approvals are dismissed when updates are introduced to a code change proposal
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.5 Ensure there are restrictions on who can dismiss code change reviews
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.6 Ensure code owners are set for extra sensitive code or configuration
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.1 Code Changes > 1.1.9 Ensure all checks have passed before merging new code
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.2 Repository Management > 1.2.1 Ensure all public repositories contain a SECURITY.md file
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.2 Repository Management > 1.2.3 Ensure repository deletion is limited to specific users
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.2 Repository Management > 1.2.4 Ensure inactive repositories are reviewed and archived periodically
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.2 Repository Management > 1.2.4 Ensure issue deletion is limited to specific users
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.3 Contribution Access > 1.3.1 Ensure inactive users are reviewed and removed periodically
- CIS Software Supply Chain v1.0.0 > 1 Source Code > 1.3 Contribution Access > 1.3.7 Ensure two administrators are set for each repository
- CIS Software Supply Chain v1.0.0 > 2 Build Pipelines > 2.3 Pipeline Instructions > 2.3.1 Ensure all build steps are defined as code
- CIS Software Supply Chain v1.0.0 > 2 Build Pipelines > 2.3 Pipeline Instructions > 2.3.7 Ensure pipelines are automatically scanned for vulnerabilities
- CIS Software Supply Chain v1.0.0 > 2 Build Pipelines > 2.3 Pipeline Instructions > 2.3.8 Ensure scanners are in place to identify and prevent sensitive data in pipeline files
- CIS Software Supply Chain v1.0.0 > 2 Build Pipelines > 2.4 Pipeline Integrity > 2.4.2 Ensure all external dependencies used in the build process are locked
- CIS Software Supply Chain v1.0.0 > 2 Build Pipelines > 2.4 Pipeline Integrity > 2.4.6 Ensure pipeline steps sign the SBOM produced
- CIS Software Supply Chain v1.0.0 > 3 Dependencies > 3.1 Third-Party Packages > 3.1.7 Ensure dependencies are pinned to a specific, verified version
- CIS Software Supply Chain v1.0.0 > 3 Dependencies > 3.2 Validate Packages > 3.2.2 Ensure packages are automatically scanned for known vulnerabilities
- CIS Software Supply Chain v1.0.0 > 3 Dependencies > 3.2 Validate Packages > 3.2.3 Ensure packages are automatically scanned for license implications
- CIS Software Supply Chain v1.0.0 > 4 Artifacts > 4.3 Package Registries > 4.3.4 Ensure webhooks of the package registry are secured
Schema for github_my_repository
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
allow_update_branch | boolean | If true, a pull request head branch that is behind its base branch can always be updated even if it is not required to be up to date before merging. | |
archived_at | timestamp with time zone | Timestamp when repository was archived. | |
auto_merge_allowed | boolean | If true, auto-merge can be enabled on pull requests in this repository. | |
can_administer | boolean | If true, you can administer this repository. | |
can_create_projects | boolean | If true, you can create projects in this repository. | |
can_subscribe | boolean | If true, you can subscribe to this repository. | |
can_update_topics | boolean | If true, you can update topics on this repository. | |
code_of_conduct | jsonb | The code of conduct for this repository. | |
contact_links | jsonb | List of contact links associated to the repository. | |
created_at | timestamp with time zone | Timestamp when the repository was created. | |
default_branch_ref | jsonb | Default ref information. | |
delete_branch_on_merge | boolean | If true, branches are automatically deleted when merged in this repository. | |
description | text | The description of the repository. | |
disk_usage | bigint | Number of kilobytes this repository occupies on disk. | |
fork_count | bigint | Number of forks there are of this repository in the whole network. | |
forking_allowed | boolean | If true, repository allows forks. | |
funding_links | jsonb | The funding links for this repository. | |
has_discussions_enabled | boolean | If true, the repository has the Discussions feature enabled. | |
has_downloads | boolean | If true, the GitHub Downloads feature is enabled on the repository. | |
has_issues_enabled | boolean | If true, the repository has issues feature enabled. | |
has_pages | boolean | If true, the GitHub Pages feature is enabled on the repository. | |
has_projects_enabled | boolean | If true, the repository has the Projects feature enabled. | |
has_starred | boolean | If true, you have starred this repository. | |
has_vulnerability_alerts_enabled | boolean | If true, vulnerability alerts are enabled for the repository. | |
has_wiki_enabled | boolean | If true, the repository has wiki feature enabled. | |
homepage_url | text | The external URL of the repository if set. | |
hooks | jsonb | The API Hooks URL. | |
id | bigint | The numeric ID of the repository. | |
interaction_ability | jsonb | The interaction ability settings for this repository. | |
is_archived | boolean | If true, the repository is unmaintained (archived). | |
is_blank_issues_enabled | boolean | If true, blank issue creation is allowed. | |
is_disabled | boolean | If true, this repository disabled. | |
is_empty | boolean | If true, this repository is empty. | |
is_fork | boolean | If true, the repository is a fork. | |
is_in_organization | boolean | If true, repository is either owned by an organization, or is a private fork of an organization repository. | |
is_locked | boolean | If true, repository is locked. | |
is_mirror | boolean | If true, the repository is a mirror. | |
is_private | boolean | If true, the repository is private or internal. | |
is_security_policy_enabled | boolean | If true, repository has a security policy. | |
is_template | boolean | If true, the repository is a template that can be used to generate new repositories. | |
is_user_configuration_repository | boolean | If true, this is a user configuration repository. | |
issue_templates | jsonb | A list of issue templates associated to the repository. | |
license_info | jsonb | The license associated with the repository. | |
lock_reason | text | The reason the repository has been locked. | |
login_id | text | =, !=, ~~, ~~*, !~~, !~~* | Unique identifier for the user login. |
merge_commit_allowed | boolean | If true, PRs are merged with a merge commit on this repository. | |
merge_commit_message | text | How the default commit message will be generated when merging a pull request. | |
merge_commit_title | text | How the default commit title will be generated when merging a pull request. | |
mirror_url | text | The repository's original mirror URL. | |
name | text | The name of the repository. | |
name_with_owner | text | The repository's name with owner. | |
network_count | bigint | The number of member repositories in the network. | |
node_id | text | The node ID of the repository. | |
open_graph_image_url | text | The image used to represent this repository in Open Graph data. | |
open_issues_total_count | bigint | Count of issues open on the repository. | |
owner_login | text | Login of the repository owner. | |
possible_commit_emails | jsonb | A list of emails you can commit to this repository with. | |
primary_language | jsonb | The primary language of the repository's code. | |
projects_url | text | The URL listing the repository's projects. | |
pull_request_templates | jsonb | Returns a list of pull request templates associated to the repository. | |
pushed_at | timestamp with time zone | Timestamp when the repository was last pushed to. | |
rebase_merge_allowed | boolean | If true, rebase-merging is enabled on this repository. | |
repository_topics_total_count | bigint | Count of topics associated with the repository. | |
security_policy_url | text | The security policy URL. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
squash_merge_allowed | boolean | If true, squash-merging is enabled on this repository. | |
squash_merge_commit_message | text | How the default commit message will be generated when squash merging a pull request. | |
squash_merge_commit_title | text | How the default commit title will be generated when squash merging a pull request. | |
ssh_url | text | The SSH URL to clone this repository. | |
stargazer_count | bigint | Returns a count of how many stargazers there are on this repository. | |
subscribers_count | bigint | The number of users who have subscribed to the repository. | |
subscription | text | Identifies if the current user is watching, not watching, or ignoring the repository. | |
topics | jsonb | The topics (similar to tags or labels) associated with the repository. | |
updated_at | timestamp with time zone | Timestamp when repository was last updated. | |
url | text | The URL of the repository. | |
uses_custom_open_graph_image | boolean | if true, this repository has a custom image to use with Open Graph as opposed to being represented by the owner's avatar. | |
visibility | text | Indicates the repository's visibility level. | |
watchers_total_count | bigint | Count of watchers on the repository. | |
web_commit_signoff_required | boolean | If true, contributors are required to sign off on web-based commits in this repository. | |
your_permission | text | Your permission level on the repository. Will return null if authenticated as an GitHub App. |
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_my_repository