github_repository_ruleset and github_organization_ruleset fail with "Resource not accessible by integration" under GitHub App authentication
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start in table_github_repository_ruleset.go and models/ruleset.go, where the GraphQL query for repository.rulesets is built and its response decoded; the log points at the conditions block near character 1823. Decide between tolerating FORBIDDEN errors on conditions.repositoryName/bypassActors (returning null) or moving the table to GET /repos/{owner}/{repo}/rulesets, which needs only Metadata read. Reproduce with a read-only App installation token before and after. Done means the repository ruleset query returns rows for org-sourced rulesets, and the github_organization_ruleset docs state the Administration write requirement.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When the GitHub plugin is configured with GitHub App installation authentication (app_id, app_installation_id, app_private_key), both github_repository_ruleset and github_organization_ruleset fail with:
Error: github: Resource not accessible by integration (SQLSTATE HV000)
All other tables tested (github_organization, github_search_repository, github_branch, github_branch_protection, etc.) work with the same connection. Querying github_repository_ruleset for a repo with no rulesets returns an empty result with no error. The failure only occurs when an organization-sourced ruleset applies to the repo.
For github_repository_ruleset, the data is available to a read-only App: GitHub returns it, along with a FORBIDDEN error on one organization-level field (conditions.repositoryName). The plugin treats that partial error as fatal and discards the whole response.
Steampipe version (steampipe -v)
v2.5.0
Plugin version (steampipe plugin list)
+-----------------------------------------------+---------+-------------+
| Installed | Version | Connections |
+-----------------------------------------------+---------+-------------+
| hub.steampipe.io/plugins/turbot/aws@latest | 1.36.0 | aws |
| hub.steampipe.io/plugins/turbot/azure@latest | 1.17.1 | azure |
| hub.steampipe.io/plugins/turbot/github@latest | 1.11.2 | github |
+-----------------------------------------------+---------+-------------+
To reproduce
- Create a GitHub App with read-only permissions, including Organization → Administration (read) and Repository → Administration and Metadata (read), and install it on an organization.
- Create an organization ruleset (branch ruleset, enforcement Active) that targets a repository in the org.
- Configure the plugin to use App authentication only (no
token, noGITHUB_TOKEN):
connection "github" {
plugin = "github"
app_id = "<app id>"
app_installation_id = "<installation id>"
app_private_key = "/path/to/key.pem"
}
- Run:
select name from github_repository_ruleset where repository_full_name = '<org>/<repo>';
select name from github_organization_ruleset where organization = '<org>';
Both queries fail with Resource not accessible by integration.
Plugin log:
github_repository_ruleset: api_error=["{Resource not accessible by integration [{1 1823}]}"]
github_organization_ruleset: api_error=["{Resource not accessible by integration [{1 230}]}"]
Expected behavior
github_repository_rulesetreturns the rulesets that apply to the repository. Fields the App isn't permitted to read (conditions.repository_namefor organization-sourced rulesets, andbypass_actors) are returned as null rather than failing the whole query. This matches the behaviour of GitHub's REST API for the same token.github_organization_ruleset's documentation states that it requires Organization "Administration" write permission, so it isn't usable with a read-only GitHub App.
Additional context
I reproduced this outside Steampipe using an installation access token generated from the same App. I confirmed it was an installation token: GET /installation/repositories succeeds, and the token's permissions object includes organization_administration: read.
1. github_repository_ruleset: partial GraphQL error treated as fatal
I rebuilt the table's GraphQL query from table_github_repository_ruleset.go and models/ruleset.go and ran it with the installation token. GitHub returns full data plus a single error for the organization-sourced ruleset:
"errors": [{
"type": "FORBIDDEN",
"path": ["repository","rulesets","edges",0,"node","conditions","repositoryName"],
"message": "Resource not accessible by integration"
}]
Every other field is returned: name, enforcement, rules with parameters, bypassActors, conditions.refName and conditions.repositoryId. This matches the log's error location (character 1823 falls in the conditions block at the end of the query). Because githubv4 returns an error when any GraphQL error is present, the table fails entirely.
2. REST returns the same data without an error
With the same installation token, GET /repos/{owner}/{repo}/rulesets/{ruleset_id} for the organization-sourced ruleset returns name, enforcement, source_type: Organization, rules (including pull_request parameters such as required_approving_review_count), conditions.ref_name and current_user_can_bypass. It silently omits conditions.repository_name and bypass_actors, the fields the token can't see, instead of returning an error. GET /repos/{owner}/{repo}/rulesets also lists the organization-sourced ruleset.
3. GitHub's documented permission requirements
Per GitHub's docs ("Permissions required for GitHub Apps" and the REST "rules" endpoint pages):
- All
GET /orgs/{org}/rulesets*endpoints require Organization "Administration" write, even for reads. That explains whygithub_organization_rulesetfails with a read-only App: GraphQLorganization.rulesetsand RESTGET /orgs/{org}/rulesetsboth return "Resource not accessible by integration". - Repository-level ruleset endpoints (
GET /repos/{owner}/{repo}/rulesets,/rulesets/{ruleset_id}and/rules/branches/{branch}) require only Repository "Metadata" read.
Suggested fix
Granting Organization "Administration" write to a read-only compliance scanner isn't acceptable, because it would allow the scanner to modify the org's rulesets and settings. For github_repository_ruleset, either:
- tolerate partial GraphQL responses where the only errors are FORBIDDEN on organization-level fields (for example
conditions.repositoryName), returning those fields as null, or - source the data from the REST repository ruleset endpoints, which need only Metadata read.
For github_organization_ruleset, document the Administration write requirement in the table docs.
- Ngôn ngữ chính
- Go
- Star
- 89
- Fork
- 43
- Merge trung bình
- 3 giờ 48 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
coder/coder#33007 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
aji: divide-by-zero panic in Map/MapTolerant on empty items or when vCPU quota < per-worker CPUĐang mởfix p1-high scope:aji
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
scttfrdmn/burst-core#41 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OneBusAway/watchdog#553 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement receiver/prometheus
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-telemetry/opentelemetry-collector-contrib#53959 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement P3 server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày