Skip to main content
Version: 0.12

GitHub Repositories

Fetches information regarding the repository, including

  • Repository metadata and settings
  • Configured workflows
  • Recent workflow runs
  • Optional direct Go dependency health and supply-chain visibility facts

This plugin is intended to be run as part of an aggregate agent, and will execute the policy suite for each repository.

This page is for operators who run the plugin-github-repositories plugin with the CCF Agent, and for developers who write policies for it. It documents v0.12.0 and is generated from the plugin's README at v0.12.0.

Requirements​

Authentication​

The plugin authenticates with a token (a fine-grained personal access token, for example) or as a GitHub App installation. Either needs at minimum the following read-only permissions:

  • Actions (read-only) - Used to pull workflow jobs and success
  • Administration (read-only) - Used to check configuration and rulesets for a repository
  • Contents (read-only) - Used to read repository files such as go.mod when dependency health collection is enabled
  • Metadata (read-only) - Required by GitHub
  • Pull Requests (read-only) - Used to pull PRs and status
  • Secret scanning alerts (read-only) - Used to check if secrets have been found
  • Secret scanning push protection bypass requests (read-only) - Used to check the process of any bypass requests

When dependency health collection is enabled, the token also uses repository contents, Actions, pull requests, license, and dependency graph/SBOM APIs against resolved public GitHub dependency repositories. Missing permissions or unavailable upstream data for resolved dependency repositories are recorded as dependency-level collection gaps and do not fail the repository evaluation.

Configuration​

plugins:
github_repos:
token: "gh-pat-abc123"
# Or authenticate as a GitHub App instead of setting token (see below):
# app_id: "123456"
# installation_id: "78901234"
# private_key_file: /etc/ccf/github-app.pem
# Organization which you want to check the repos of
organization: octocat
# The following items are mutually exclusive, so cannot be set together. If neither are set, all repos are
# pulled and tested, otherwise the selection is chosen below
# Alternatively, these can be limited via the PAT configuration
included_repositories: foo,bar,baz
excluded_repositories: quix,quiz
# Optional dependency health collection. Disabled by default to avoid extra GitHub API usage.
dependency_health_enabled: "false"
dependency_health_max_dependencies: "50"
dependency_health_closed_pr_lookback_days: "180"
dependency_health_include_unresolved: "true"
dependency_health_collect_sbom: "true"
dependency_health_pr_interaction_sample_size: "20"

Dependency health collection currently parses direct go.mod dependencies only. It resolves module paths that start with github.com/{owner}/{repo} and collects public upstream repository health signals. Dependency policies are now evaluated using policy behavior metadata from the request (dependency behavior), and dependency inputs expose repository/dependency context under input.dependency and input.repository with request policy data available at input.policy_data. This can add several GitHub API calls per direct dependency, so enable it only for policy collections that need dependency evidence.

Policy input migration: use request policy_data for new policy-specific inputs. The legacy plugin config key policy_input is still accepted as a JSON string fallback when request policy_data is not provided, and repository policy evaluation exposes the same data under both input.policy_data and the legacy input.policy_input key for compatibility. If both policy_data and policy_input are provided, policy_data is used.

GitHub App authentication​

Instead of a token, the plugin can authenticate as a GitHub App installed on the organization. Organizations can govern apps centrally, and the plugin only ever holds short-lived installation tokens, which it renews as they expire.

  1. Create a GitHub App (organization Settings → Developer settings → GitHub Apps) with the read-only repository permissions listed above, and generate a private key for it.
  2. Install the app on the organization, for all repositories or the ones the plugin checks.
  3. Configure the plugin with the app's ID, the installation's ID (the number at the end of the installation's settings URL) and the private key:
plugins:
github_repos:
app_id: "123456"
installation_id: "78901234"
# The PEM file the app's "Generate a private key" downloads (preferred), or
private_key_file: /etc/ccf/github-app.pem
# the key inline, as PEM or base64-encoded PEM (e.g. from an environment variable)
# private_key: "LS0tLS1CRUdJTi..."
organization: octocat

A token, when set, takes precedence over the app settings.

Policy input​

The plugin evaluates two kinds of input, and a policy bundle gets one of them. A repository policy receives one document per repository as input. A dependency policy receives one document per direct dependency of a repository. Bundles are matched by the behavior the agent assigns them: dependency for the bundle plugin-github-repositories-dependency-policies, repository for every other bundle. Dependency documents are only produced when dependency_health_enabled is on. The table lists fields by their path inside the document. Many repository fields are GitHub REST API objects, passed through as GitHub returns them, so only their top level is described here. A field marked as left out is missing from the document, not null. Any other field is always present, but a list or an object the plugin found nothing for can be null, so test for that. Your own policy data from the agent configuration is in input.policy_data on both kinds of document. Older agent configurations set it with the policy_input setting; the repository document still carries the same data a second time under the legacy key input.policy_input, which the dependency document does not have.

FieldTypeDescription
settingsobjectRepository document. The repository as the GitHub REST API returns it (name, full_name, owner, default_branch, visibility, archived, security_and_analysis and the rest).
workflowsarray of objectsRepository document. GitHub Actions workflows configured in the repository (id, name, path, state).
workflow_runsarray of objectsRepository document. Workflow runs the plugin collected, as GitHub returns them.
protected_branchesarray of stringsRepository document. Names of the protected branches.
branch_protection_rulesobject (branch name to object)Repository document. The full branch protection configuration of each branch, as GitHub returns it. A branch whose protection could not be read is missing. When no protected branch was read, the default branch is tried.
required_status_checksobject (branch name to object)Repository document. The required status checks of each branch that has them.
sbomobjectRepository document. The repository's SBOM from the dependency graph, as GitHub returns it. null when none is available.
last_releaseobjectRepository document. The latest release, as GitHub returns it. null when the repository has no release.
pull_requestsarray of objectsRepository document. Open pull requests, each with every field GitHub returns for a pull request plus reviews.
pull_requests[].reviewsarray of objectsReviews of the pull request, each with every field GitHub returns for a review plus threads.
pull_requests[].reviews[].threadsarray of objectsDiscussion threads of the review.
pull_requests[].reviews[].threads[].idstringThread ID.
pull_requests[].reviews[].threads[].is_resolvedbooleanWhether the thread is resolved.
pull_requests[].reviews[].threads[].commentsarray of objectsComments in the thread. Each has id, body, url, diff_hunk and path, and may have review_id, position, original_position, reply_to_id, created_at and updated_at, which are left out when empty.
code_ownersobjectRepository document. The CODEOWNERS file as GitHub returns repository content. null when the repository has none.
org_teamsarray of objectsRepository document. Teams of the organization: id (integer), name, slug and members (array of logins).
deploymentsarray of objectsRepository document. Deployments that match the plugin's deployment settings. Each has deployment (the GitHub deployment) and statuses (its GitHub deployment statuses).
failed_deploymentsarray of objectsRepository document. Every deployment that has a failed status, in the same shape as deployments.
collaboratorsarray of objectsRepository document. Direct collaborators: login, role_name and permissions (object, permission name to boolean).
repository_teamsarray of objectsRepository document. Teams with access to the repository: id (integer), name, slug, permission, permissions (object, permission name to boolean) and members (array of logins).
environmentsarray of objectsRepository document. Deployment environments. Each has id, name, can_admins_bypass, and may have url, html_url, wait_timer, reviewers, protection_rules and deployment_branch_policy, which are left out when empty.
environments[].reviewersarray of objectsRequired reviewers: type, and as they apply id, login, slug and name, left out when empty.
environments[].protection_rulesarray of objectsProtection rules: id, type, prevent_self_review, and wait_timer and reviewers when set.
environments[].deployment_branch_policyobjectprotected_branches and custom_branch_policies, both boolean.
effective_branch_rulesobject (branch name to object)Repository document. The rules that apply to each branch, from branch protection and rulesets together. Each object has required_signatures (boolean), and may have required_deployments (array of environment names), code_scanning_tools (array of strings), required_approving_review_count (integer), dismiss_stale_reviews_on_push and require_code_owner_review (booleans). These are left out when empty, 0 or false.
policy_dataobjectBoth documents. The policy data from the agent configuration. An empty object when none is set.
policy_inputobjectRepository document only. Legacy key, the same data as policy_data. Use policy_data.
repositoryobjectDependency document. The repository that declares the dependency.
repository.organizationstringOrganization login.
repository.namestringRepository name.
repository.full_namestringorganization/name.
repository.urlstringWeb URL of the repository. Left out when empty.
dependencyobjectDependency document. One direct dependency. Today only direct go.mod dependencies are read.
dependency.namestringModule path.
dependency.ecosystemstringPackage ecosystem.
dependency.source_filestringFile the dependency was declared in.
dependency.directbooleanWhether the dependency is direct.
dependency.declared_versionstringVersion declared in the source file.
dependency.repositoryobjectThe upstream repository the dependency resolves to. provider, owner, name and url are left out when empty.
dependency.repository.resolvedbooleanWhether the module path was resolved to a public GitHub repository.
dependency.healthobjectMaintenance signals of the upstream repository. null when not collected.
dependency.health.repository_archivedbooleanWhether the upstream repository is archived.
dependency.health.latest_releaseobjecttag and published_at (RFC 3339 time) of the latest release. Left out when there is none.
dependency.health.latest_commitobjectsha and committed_at (RFC 3339 time) of the latest default-branch commit. Left out when unknown.
dependency.health.workflowsobjectcount (integer) of workflows, and latest_default_branch_run with status, conclusion and created_at when a run exists. Left out when not collected.
dependency.health.pull_requestsobjectPull request activity. open_count, open_count_capped, recent_closed_count, recent_closed_count_capped and first_interaction_sampled_pull_requests are always there; oldest_open_created_at, median_days_to_close and median_hours_to_first_interaction are left out when unknown. Left out as a whole when not collected.
dependency.supply_chainobjectLicense and SBOM facts. null when not collected.
dependency.supply_chain.licenseobjectcollected (boolean), and spdx_id, name and url when known.
dependency.supply_chain.sbomobjectavailable (boolean), package_count (integer), collected (boolean), and spdx_id, spdx_version and creation_info_created when known.
dependency.collection_statusobjectWhich collection stages finished: dependency_parsed, repository_resolved, health_collected, license_collected and sbom_collected, all boolean. A missing upstream fact is recorded here and does not fail the run.
dependency.collection_status.errorsarray of objectsNon-fatal collection failures, each with scope and message strings.

An example input:

{
"repository": {
"organization": "example-org",
"name": "payments-api",
"full_name": "example-org/payments-api",
"url": "https://github.com/example-org/payments-api"
},
"dependency": {
"name": "github.com/example-org/ledger-kit",
"ecosystem": "go",
"source_file": "go.mod",
"direct": true,
"declared_version": "v1.4.2",
"repository": {
"provider": "github",
"owner": "example-org",
"name": "ledger-kit",
"url": "https://github.com/example-org/ledger-kit",
"resolved": true
},
"health": {
"repository_archived": false,
"latest_release": {
"tag": "v1.4.2",
"published_at": "2026-02-03T10:15:00Z"
},
"latest_commit": {
"sha": "3f2c9a7d1b8e4c6a05d9f7b2e1a4c8d6f0b3e5a7",
"committed_at": "2026-03-01T16:40:12Z"
},
"workflows": {
"count": 3,
"latest_default_branch_run": {
"status": "completed",
"conclusion": "success",
"created_at": "2026-03-01T16:45:00Z"
}
},
"pull_requests": {
"open_count": 4,
"open_count_capped": false,
"oldest_open_created_at": "2026-01-12T09:00:00Z",
"recent_closed_count": 18,
"recent_closed_count_capped": false,
"median_days_to_close": 2.5,
"median_hours_to_first_interaction": 6,
"first_interaction_sampled_pull_requests": 18
}
},
"supply_chain": {
"license": {
"spdx_id": "Apache-2.0",
"name": "Apache License 2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"collected": true
},
"sbom": {
"available": true,
"package_count": 27,
"spdx_id": "SPDXRef-DOCUMENT",
"spdx_version": "SPDX-2.3",
"creation_info_created": "2026-03-01T17:00:00Z",
"collected": true
}
},
"collection_status": {
"dependency_parsed": true,
"repository_resolved": true,
"health_collected": true,
"license_collected": true,
"sbom_collected": true,
"errors": []
}
},
"policy_data": {
"max_days_since_last_commit": 365
}
}

Subject templates​

The subject templates this plugin registers. Each example is built from sample data.

github-repository​

A GitHub repository. Title: GitHub Repository: {{ .repository }}. Dependency evaluations use the labels type (repository-dependency), dependency, ecosystem and dependency_version on top of these, and repository evaluations use provider (github) and type (repository); none of those are part of the identity.

Identity keyDescription
repositoryName of the repository, without the organization.
organizationLogin of the GitHub organization that owns the repository.

Example:

{
"name": "github-repository",
"type": "component",
"title": "GitHub Repository: payments-api",
"description": "GitHub repository payments-api in organization example-org",
"purpose": "Represents a GitHub repository being monitored for compliance",
"identityLabels": {
"repository": "payments-api",
"organization": "example-org"
}
}

Policies​

The policy bundles that work with this plugin, at their newest releases. The controls are the ones the bundle's policies list in their metadata.

BundleLatest versionControls coveredCompatible plugin lines
plugin-github-repositories-custom-policiesv0.2.1none listedlatest
plugin-github-repositories-dependency-policiesv0.1.2none listedlatest
plugin-github-repositories-policiesv0.7.4none listedlatest
plugin-github-repositories-pr-policiesv0.2.1none listedlatest

When writing OPA/Rego policies for this plugin, they must be added under the compliance_framework Rego package:

# deny_critical_severity.rego
# package compliance_framework.[YOUR_RULE_PATH]
package compliance_framework.deny_critical_severity