Skip to content

fix(labels): bound custom type label cleanup#3552

Merged
JSONbored merged 2 commits into
mainfrom
codex/propose-fix-for-typelabels-vulnerability
Jul 5, 2026
Merged

fix(labels): bound custom type label cleanup#3552
JSONbored merged 2 commits into
mainfrom
codex/propose-fix-for-typelabels-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent unbounded attacker-controlled amplification of outbound GitHub label-removal calls by capping the number and length of per-repo typeLabels so a malicious or compromised repo cannot cause hundreds/thousands of DELETE requests per PR webhook.

Description

  • Add MAX_TYPE_LABEL_CATEGORIES = 32 and MAX_TYPE_LABEL_NAME_LENGTH = 50 and document the bounds in src/settings/pr-type-label.ts.
  • Enforce the caps in normalizeTypeLabelSet so oversized/overlong manifest entries are warned and ignored instead of being propagated into repository settings.
  • Apply the same bounds when computing removeLabels in resolvePrTypeLabel to cap the cleanup list before webhook processing can perform per-label GitHub operations.
  • Limit sparse manifest overrides in src/signals/focus-manifest.ts so only validated, in-range entries survive into the per-repo override, and update tests to cover overflow/overlong cases.

Testing

  • Ran targeted unit tests with npx vitest run test/unit/pr-type-label.test.ts test/unit/focus-manifest.test.ts, and the tests passed.
  • Ran static type checks with npm run typecheck, which succeeded.
  • Attempted the full coverage run with npm run test:coverage, but the environment hit long-running queue/backfill test time limits so the full suite did not complete here; the targeted unit regressions passed locally in the run above.
  • npm audit --audit-level=moderate could not complete in this environment due to an npm registry 403 Forbidden response.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 17:56:39 UTC

4 files · 1 AI reviewer · 2 blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR adds bounded caps (32 categories, 50-char names) to `typeLabels` processing across `normalizeTypeLabelSet`, `resolvePrTypeLabel`, and the sparse manifest-override path in `focus-manifest.ts`, closing the amplification vector where an attacker-controlled repo config could balloon into hundreds of per-PR label DELETE calls. I traced the category-cap accounting in `normalizeTypeLabelSet` (src/settings/pr-type-label.ts:82-107): keys are iterated via `new Set([...Object.keys(DEFAULT_TYPE_LABELS), ...Object.keys(record)])`, so the 3 built-in categories are always processed first and consume 3 of the 32 slots before custom categories are counted — this matches the test expectations (custom28 kept, custom29 dropped) exactly. The `resolvePrTypeLabel` cleanup-list capping and the `focus-manifest.ts` sparse-override guard (`validated[key] !== undefined`) are consistent with this same accounting, so the fix is wired correctly end-to-end rather than being a symptom-only patch.

Nits — 5 non-blocking
  • src/settings/pr-type-label.ts:96-99 — `wouldAddCategory = result[key] === undefined` is always true since `keys` is a Set of unique keys never previously written to `result`; the check reduces to `Object.keys(result).length >= MAX_TYPE_LABEL_CATEGORIES` and the extra variable/condition just adds noise.
  • codecov/patch is at 90.90% vs the 99% target — worth checking whether the untouched branches in the larger `focus-manifest.ts` diff (e.g. paths where `validated[key]` is undefined for a built-in default vs a dropped custom category) are exercised, since both arms of that `&&` in the sparse-override loop should have dedicated tests.
  • src/settings/pr-type-label.ts:100 — the warning message says 'ignoring {key}' but only fires when `value !== undefined`; a comment noting that an absent key at the cap boundary is silently skipped (correctly, since it was never present) would help future readers avoid assuming a warning always accompanies a dropped category.
  • Add a unit test asserting that when the built-in triad (bug/feature/priority) plus exactly `MAX_TYPE_LABEL_CATEGORIES` custom categories are supplied, none of the built-ins are ever evicted regardless of custom-key ordering, to lock in the 'built-ins always processed first' invariant relied on here.
  • Consider extracting the `length <= MAX_TYPE_LABEL_NAME_LENGTH` check into a small shared helper since it's now duplicated across `normalizeTypeLabelSet`, `resolvePrTypeLabel`, and `focus-manifest.ts`'s `isValidLabelName`.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ✅ No-issue rationale PR body explains why no issue is linked.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 56 registered-repo PR(s), 46 merged, 521 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 56 PR(s), 521 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 56 PR(s), 521 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (65de78e) to head (4be70d5).
⚠️ Report is 60 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3552   +/-   ##
=======================================
  Coverage   93.01%   93.01%           
=======================================
  Files         297      297           
  Lines       31038    31045    +7     
  Branches    11319    11322    +3     
=======================================
+ Hits        28870    28877    +7     
  Misses       1513     1513           
  Partials      655      655           
Files with missing lines Coverage Δ
src/settings/pr-type-label.ts 97.95% <100.00%> (+0.34%) ⬆️
src/signals/focus-manifest.ts 98.67% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ypeLabelSet

codecov/patch was at 90.90% -- the category-cap overflow branch only had
test coverage for entries with a defined-but-ignored value, missing the
sibling case where an overflow key's value is explicitly undefined (no
warning should fire, since nothing was going to be included either way).
@JSONbored
JSONbored merged commit a54441d into main Jul 5, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-typelabels-vulnerability branch July 5, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant