steampipe plugin install github

Table: github_tree - Query GitHub Repositories using SQL

GitHub Repositories are a fundamental resource in GitHub. They allow users to host and manage their codebase, track changes, and collaborate with other users. Each repository contains a tree structure that represents the file and directory hierarchy.

Table Usage Guide

The github_tree table provides insights into the tree structures within GitHub Repositories. As a developer or project manager, explore each repository's file and directory hierarchy through this table, including file names, types, and associated metadata. Utilize it to uncover information about the organization and structure of repositories, such as the distribution of file types and the depth of directory nesting.

Important Notes

  • You must specify the repository_full_name and tree_sha columns in where or join clause to query the table.

Examples

List tree entries non-recursively

Explore the specific elements within the 'turbot/steampipe' repository by pinpointing specific locations using a unique identifier. This allows for a non-recursive view of the repository's structure, enabling easier navigation and understanding of the repository's layout and content.

select
tree_sha,
truncated,
path,
mode,
type,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a';
select
tree_sha,
truncated,
path,
mode,
type,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a';

List tree entries for a subtree recursively

Determine the areas in which you can explore the components of a specific subtree within the 'turbot/steampipe' repository. This is useful for gaining insights into the structure and elements of the subtree in a recursive manner.

select
tree_sha,
truncated,
path,
mode,
type,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '5622172b528cd38438c52ecfa3c20ac3f71dd2df'
and recursive = true;
select
tree_sha,
truncated,
path,
mode,
type,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '5622172b528cd38438c52ecfa3c20ac3f71dd2df'
and recursive = 1;

List executable files

This query allows you to identify all the executable files within a specified repository. It's particularly useful for understanding the structure and content of a repository, and for identifying potential security risks associated with executable files.

select
tree_sha,
truncated,
path,
mode,
size,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a'
and recursive = true
and mode = '100755';
select
tree_sha,
truncated,
path,
mode,
size,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a'
and recursive = 1
and mode = '100755';

List JSON files

This query is useful for identifying all JSON files within a specific GitHub repository. It can help developers or project managers to quickly locate and manage all JSON files in the repository, aiding in tasks such as code review, debugging, or configuration management.

select
tree_sha,
truncated,
path,
mode,
size,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a'
and recursive = true
and path like '%.json';
select
tree_sha,
truncated,
path,
mode,
size,
sha
from
github_tree
where
repository_full_name = 'turbot/steampipe'
and tree_sha = '0f200416c44b8b85277d973bff933efa8ef7803a'
and recursive = 1
and path like '%.json';

Schema for github_tree

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
modetextFile mode. Valid values are 100644 (blob file), 100755 (blob executable), 040000 (tree subdirectory), 160000 (commit submodule), 120000 (blob that specifies path of a symlink).
pathtextThe file referenced in the tree.
recursiveboolean=If set to true, return objects or subtrees referenced by the tree. Defaults to false.
repository_full_nametext=Full name of the repository that contains the tree.
shatextSHA1 checksum ID of the object in the tree.
sizetextSize of the blob.
tree_shatext=SHA1 of the tree.
truncatedbooleanTrue if the entires were truncated because the number of items in the tree exceeded Github's maximum limit.
typetextEither blob, tree, or commit.
urltextURL to the file referenced in the tree.

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_tree