fix(github): reject malformed repoFullName in app.ts and comments.ts - #8402
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
app.ts's three GitHub-write call sites (getRepositoryCollaboratorPermission, cancelInFlightWorkflowRunsForHeadSha, createOrUpdateNamedCheckRun) did a bare two-variable destructure with only a truthiness check, so "owner/repo/extra" silently dropped the extra segment and issued a call against a different repo, and a padded "owner/ repo" was encodeURIComponent-ed straight into a GitHub URL. comments.ts had the segment-count guard but not the whitespace one. Adds a local parseRepoFullNameStrict helper in app.ts (per this directory's house convention of a small per-module copy rather than a shared export) used by all three call sites, each preserving its existing failure contract, and adds the whitespace condition to comments.ts's existing check. Regression tests cover the extra-segment and whitespace-padded shapes at all four call sites. Closes JSONbored#8311
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8402 +/- ##
==========================================
- Coverage 92.17% 89.71% -2.47%
==========================================
Files 791 99 -692
Lines 79249 23044 -56205
Branches 23947 3993 -19954
==========================================
- Hits 73048 20673 -52375
+ Misses 5062 2188 -2874
+ Partials 1139 183 -956
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-24 12:06:13 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed 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
src/github/app.ts's three GitHub-write call sites did a bare two-variable destructure with only a truthiness check, so two failure modes every sibling module insrc/github/already rejects got through:"owner/repo/extra"silently dropped the extra segment and issued the call against a different repo than the caller named, and a padded"owner/ repo"/" owner/repo"wasencodeURIComponent-ed straight into a GitHub API URL.getRepositoryCollaboratorPermission(:446),cancelInFlightWorkflowRunsForHeadSha(:620),createOrUpdateNamedCheckRun(:911 — the function backing everycreateOrUpdate*GateCheckRun/createOrUpdateCheckRun, i.e. the gate-check-posting path).src/github/comments.ts(createOrUpdateIssueCommentWithMarker) had the segment-count guard but was missing the/\s/whitespace check thatpr-actions.ts/assignees.ts/labels.tsgained under pr-actions.ts splitRepo misses per-segment whitespace padding (owner/ repo slips through) #6613.parseRepoFullNameStricthelper insideapp.ts, reused by its own three call sites, per this directory's stated house convention of a per-module copy of this tiny pure check rather than a shared cross-file export (issues.ts:5-15's own comment). It returnsnullso each call site maps a malformed value to its existing, unchanged failure contract:getRepositoryCollaboratorPermission→ returnsnullcancelInFlightWorkflowRunsForHeadSha→ returns{ kind: "error", warning: … }createOrUpdateNamedCheckRun→ throwsInvalid repository full name: …createOrUpdateIssueCommentWithMarker→ throws (already did; only the whitespace condition was added)owner/repovalue.test/unit/github-app.test.ts,test/unit/github-comments.test.ts) assert"owner/repo/extra"and whitespace-padded slugs are rejected exactly like the existing no-slash"invalid"case, and collectively exercise all four operands of the guard (parts.length !== 2,!owner,!repo,/\s/) plus the valid-input path.Closes #8311
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
src/github/app.ts,src/github/comments.tsand their two root test suites, soactionlint(no workflow change),build:mcp/test:mcp-pack(no MCP change),ui:openapi:check/ui:lint/ui:typecheck/ui:build(no UI or OpenAPI/route change),test:workers(no worker change), andnpm audit(no dependency change) are not exercised by it.vitest run --coverage --coverage.all=false --changed=origin/main): the resultingcoverage/lcov.infois non-empty, contains both changed source files, and every executable changed line and branch in them is hit (0 uncovered).test/unit/github-app.test.ts+test/unit/github-comments.test.tspass in full (113 tests). Roottsc --noEmitis clean.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
Not applicable — backend-only input-validation hardening in
src/github/; no visible UI, frontend, docs, or extension change.Notes
owner/repo, so no existing behavior changes. The value is closing the last inconsistency in this boundary —pr-actions.ts,assignees.ts,labels.ts,issues.ts, andmilestones.tsall already reject these shapes, andapp.tscarries the heaviest GitHub-write traffic (installation tokens, check-run creation, workflow-run cancellation).client.tsor elsewhere; the guard is a local helper withinapp.ts(its three call sites share a file) and an inline condition incomments.ts, matching the five existing per-module copies.