fix(bounties): type-guard normalizeGittBountySnapshot's untrusted Gitt payload fields - #9335
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…t payload fields normalizeGittBountySnapshot parses a `payload: unknown` from the untrusted Gitt API, cast to GittIssueListPayload — so its declared field types are not guaranteed at runtime. The old guard only truthiness-checked the fields, letting a wrong-typed value (e.g. a numeric repository_full_name or a string issue_number) flow straight into a mistyped BountyRecord. Add typed value guards mirroring registry/normalize.ts's convention: a wrong-typed required field (id, repoFullName, issueNumber, status) drops the whole record, and a wrong-typed/non-finite amount degrades to undefined without dropping the record. Closes JSONbored#9313 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9335 +/- ##
=======================================
Coverage 75.38% 75.38%
=======================================
Files 275 276 +1
Lines 58023 58036 +13
Branches 6181 6186 +5
=======================================
+ Hits 43739 43752 +13
Misses 14014 14014
Partials 270 270
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-27 13:27:12 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
normalizeGittBountySnapshot(src/bounties/ingest.ts) parses apayload: unknownfrom theuntrusted Gitt API, cast to
GittIssueListPayload— so the declared field types are notguaranteed at runtime. The old guard only truthiness-checked the fields, so a wrong-typed value
(e.g. a numeric
repository_full_name, or a stringissue_number) flowed straight into a mistypedBountyRecord, violating the contract insrc/types.ts(repoFullName: string,issueNumber: number,status: string).Adds typed value guards mirroring the sibling
src/registry/normalize.tsconvention:id,repoFullName,issueNumber,status) drops the whole record.undefinedwithout dropping the record.Test plan
test/unit/bounties-ingest.test.ts: each required field wrong-typed → record dropped; well-typed records (string id via bounty_alpha; numeric id via bounty_amount) preserved; non-finite/absent amount →amountText: undefined; null/malformed payload →[]tsc --noEmitclean (engine rebuilt); 11/11 tests passCloses #9313