Skip to content

fix: enforce tracked-repo allowlist on repo-scoped API routes#155

Open
glorydavid03023 wants to merge 2 commits into
MkDev11:mainfrom
glorydavid03023:fix/gt-repo-miners-prs-allowlist
Open

fix: enforce tracked-repo allowlist on repo-scoped API routes#155
glorydavid03023 wants to merge 2 commits into
MkDev11:mainfrom
glorydavid03023:fix/gt-repo-miners-prs-allowlist

Conversation

@glorydavid03023
Copy link
Copy Markdown

@glorydavid03023 glorydavid03023 commented May 26, 2026

Summary

Test plan

  • CI: pnpm run lint and pnpm build
  • Tracked repo: GET /api/repos/<owner>/<name>/issues returns 200
  • Untracked repo: same path returns 404
  • Tracked repo: GET /api/gt/repos/<owner>/<name>/miners returns 200

Completes allowlist coverage for /api/gt/repos/[owner]/[name]/* so untracked repos cannot trigger SQLite reads or link backfills.

Fixes MkDev11#141

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

Two API routes under /api/gt/repos/[owner]/[name]/ now validate that the requested repository is in the tracked/allowed list before processing requests. The miners and PRs endpoints each import assertTrackedRepo and invoke it at the start of their GET handlers, returning immediately if the repo is denied access.

Changes

Repo Allowlist Access Control

Layer / File(s) Summary
Miners route access control
src/app/api/gt/repos/[owner]/[name]/miners/route.ts
Imports assertTrackedRepo and adds an early authorization check in GET that validates the requested owner/name, returning immediately if the repo is not allowed.
PRs route access control
src/app/api/gt/repos/[owner]/[name]/prs/route.ts
Imports assertTrackedRepo and adds an early authorization check in GET that validates the owner/name against the allowlist, denying access to untracked repos.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • MkDev11/gittensor-hub#142: Implements the same assertTrackedRepo access control pattern across other /api/gt/repos/[owner]/[name] endpoints (contents, readme, contributing, health routes).

Poem

🐰 Two routes now stand guard with care,
assertTrackedRepo checks what's there,
No sneaky repos slip on through—
Only tracked ones pass the queue! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the proposed fix from issue #141 by validating owner/name against the tracked repo list on the miners and prs routes, matching the expected behavior.
Out of Scope Changes check ✅ Passed Both route changes directly address issue #141 by adding the assertTrackedRepo check; no unrelated modifications are present.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: enforcing an allowlist check on repo-scoped API routes for miners and PRs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Add assertTrackedRepo to list/meta, badges, validations, author feeds, and related-prs index handlers so untracked owner/name pairs cannot read hub cache data.

Co-authored-by: Cursor <cursoragent@cursor.com>
@glorydavid03023 glorydavid03023 changed the title fix: enforce tracked-repo allowlist on gt miners and prs routes fix: enforce tracked-repo allowlist on repo-scoped API routes May 26, 2026
@MkDev11
Copy link
Copy Markdown
Owner

MkDev11 commented May 26, 2026

Please add screenshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants