From c599dd9ed5eb450f717beeb912588724bcf4edca Mon Sep 17 00:00:00 2001 From: Yggdrasil Date: Wed, 14 Oct 2026 04:15:18 -0400 Subject: [PATCH 1/2] fix(reputation): the reads are public, not self-view-only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit latest/history asserted owner — a sponsor or maintainer couldn't read a contributor's track record before assigning a bounty/team, which is the entire point of reputation. Any authenticated user may read; only recompute stays owner-gated. Resolves #583 --- src/reputation/reputation.controller.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/reputation/reputation.controller.ts b/src/reputation/reputation.controller.ts index 31da4a1d..10611b11 100644 --- a/src/reputation/reputation.controller.ts +++ b/src/reputation/reputation.controller.ts @@ -9,6 +9,7 @@ import { UseGuards, } from '@nestjs/common'; import { ApiBearerAuth, ApiQuery, ApiTags } from '@nestjs/swagger'; +import { Throttle } from '@nestjs/throttler'; import { ReputationService } from './reputation.service'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { CurrentUser } from '../common/decorators/current-user.decorator'; @@ -35,6 +36,10 @@ export class ReputationController { @ApiBearerAuth() @UseGuards(JwtAuthGuard) + // Unthrottled, every call ran the multi-join stats SQL AND inserted a row — + // ~170k snapshots/day from one user (#584). Tight limit + the service skips + // the insert when nothing changed. + @Throttle({ long: { limit: 10, ttl: 3_600_000 } }) @Post(':userId/recompute') recompute( @Param('userId', new ParseUUIDPipe()) userId: string, @@ -47,11 +52,10 @@ export class ReputationController { @ApiBearerAuth() @UseGuards(JwtAuthGuard) @Get(':userId') - latest( - @Param('userId', new ParseUUIDPipe()) userId: string, - @CurrentUser() user: AuthenticatedUser, - ) { - this.assertOwner(user, userId); + latest(@Param('userId', new ParseUUIDPipe()) userId: string) { + // Reputation is a contributor's public track record — a sponsor or + // maintainer needs to read it before assigning a bounty/team (#583). + // Any authenticated user may read; only recompute stays owner-gated. return this.reputationService.getLatest(userId); } @@ -66,11 +70,11 @@ export class ReputationController { @ApiQuery({ name: 'offset', required: false }) history( @Param('userId', new ParseUUIDPipe()) userId: string, - @CurrentUser() user: AuthenticatedUser, @Query('limit') limit?: string, @Query('offset') offset?: string, ) { - this.assertOwner(user, userId); + // Public read — sponsors/maintainers see a contributor's track record + // before assigning work (#583). Only recompute is owner-gated. return this.reputationService.history(userId, { limit: parseOptionalInt(limit), offset: parseOptionalInt(offset), From 94d64292c3aa6b338aa43ef88a83d6e6531ccad6 Mon Sep 17 00:00:00 2001 From: yggdrasilworld Date: Sun, 18 Oct 2026 21:50:34 -0400 Subject: [PATCH 2/2] fix: repair merge glue that left the branch uncompilable The shared base carried half-written merge artifacts: an orphaned invokeOnLockedEscrow block in escrow.service.ts, duplicated returns plus a dead parsePagination in sponsors.controller.ts, and missing describe/it closers in github-webhooks.service.spec.ts. Aligned each with the intended form so the branch typechecks and its specs load. --- src/escrow/escrow.service.ts | 10 ++-------- src/github/github-webhooks.service.spec.ts | 3 +++ src/sponsors/sponsors.controller.ts | 21 --------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/escrow/escrow.service.ts b/src/escrow/escrow.service.ts index 6d2dd289..c252993f 100644 --- a/src/escrow/escrow.service.ts +++ b/src/escrow/escrow.service.ts @@ -584,20 +584,14 @@ export class EscrowService { recipients: Array<[string, number]>, manager?: EntityManager, ): Promise { - return this.invokeOnLockedEscrow(escrow, operation, () => - this.soroban.invoke( - 'release', - // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). - [u64(this.onChainKeyFor(escrow)), recipients], - this.contractOpts(escrow), - ), return this.invokeOnLockedEscrow( escrow, operation, () => this.soroban.invoke( 'release', - [this.onChainKeyFor(escrow), recipients], + // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). + [u64(this.onChainKeyFor(escrow)), recipients], this.contractOpts(escrow), ), manager, diff --git a/src/github/github-webhooks.service.spec.ts b/src/github/github-webhooks.service.spec.ts index 45bb6fe8..a35ac3be 100644 --- a/src/github/github-webhooks.service.spec.ts +++ b/src/github/github-webhooks.service.spec.ts @@ -869,6 +869,9 @@ describe('GithubWebhooksService', () => { expect(bountiesService.markInReview).not.toHaveBeenCalled(); expect(bountiesService.markMergedAndRelease).not.toHaveBeenCalled(); + }); + }); + // #308: a redelivered X-GitHub-Delivery used to hit the unique constraint // on webhook_events.deliveryId and escape handleEvent as a 500, so every // redelivery of that event failed forever. diff --git a/src/sponsors/sponsors.controller.ts b/src/sponsors/sponsors.controller.ts index b7a48cca..c097bf1e 100644 --- a/src/sponsors/sponsors.controller.ts +++ b/src/sponsors/sponsors.controller.ts @@ -26,25 +26,6 @@ function validatePage(limit?: number, offset?: number) { throw new BadRequestException('offset must be >= 0'); } return { limit, offset }; -/** - * Parse optional limit/offset query params, rejecting NaN, negatives, - * non-integers, and limits above MAX_PAGE_LIMIT with a 400 (#280). - */ -function parsePagination(limit?: string, offset?: string) { - const parse = (name: string, raw: string | undefined, min: number, max: number) => { - if (raw === undefined || raw === '') return undefined; - const n = Number(raw); - if (!Number.isInteger(n) || n < min || n > max) { - throw new BadRequestException( - `${name} must be an integer between ${min} and ${max}`, - ); - } - return n; - }; - return { - limit: parse('limit', limit, 1, MAX_PAGE_LIMIT), - offset: parse('offset', offset, 0, Number.MAX_SAFE_INTEGER), - }; } @ApiTags('sponsors') @@ -73,7 +54,6 @@ export class SponsorsController { ) { this.assertOwnsSponsor(user, id); return this.sponsorsService.dashboard(id, validatePage(limit, offset)); - return this.sponsorsService.dashboard(id, parsePagination(limit, offset)); } @ApiBearerAuth() @@ -91,6 +71,5 @@ export class SponsorsController { id, validatePage(limit, offset), ); - return this.sponsorsService.milestoneProgress(id, parsePagination(limit, offset)); } }