fix(backend): protect analytics/reputation routes with JwtAuthGuard, add indexes on claimedById and webhook events, and enforce MaxLength on free-text DTOs (#138, #139, #148, #149, #151) - #184
Open
ghzhost wants to merge 1 commit into
Conversation
…add indexes on claimedById and webhook events, and enforce MaxLength on free-text DTOs (MergeFi#138, MergeFi#139, MergeFi#148, MergeFi#149, MergeFi#151)
|
Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR addresses multiple security, performance, and schema validation items across the backend:
Authentication Guards on Analytics & Reputation Endpoints (ReputationController has zero authentication guards, including POST /:userId/recompute #138, AnalyticsController.forContributor has no authentication guard #139):
@UseGuards(JwtAuthGuard)and@ApiBearerAuth()toAnalyticsController.forContributor(GET /analytics/contributors/:userId), preventing unauthenticated scraping of contributor financial/performance profile data.@UseGuards(JwtAuthGuard)and@ApiBearerAuth()toReputationControlleracrossPOST /:userId/recompute,GET /:userId, andGET /:userId/history, preventing unauthenticated denial-of-service / duplicate snapshot writes and information exposure.Database Performance Indexing (Bounty.claimedById has no database index despite being the primary filter column for reputation and analytics #148, WebhookEvent has no index on eventType, status, or receivedAt #149):
@Index()onBounty.claimedById(src/common/entities/bounty.entity.ts), speeding up critical contributor lookups inReputationServiceandAnalyticsService.@Index(["eventType", "status"]),@Index(["status", "receivedAt"]), and single index onreceivedAtinWebhookEvent(src/common/entities/webhook-event.entity.ts) for query performance over ever-growing webhook audit logs.String Length Range & DTO Constraints (Several free-text DTO fields have no @MaxLength(), and their entity columns have no varchar length either #151):
@MaxLength(100)onTeamMemberSplitDto.roleand matchinglength: 100onTeamMemberSplit.role.@MaxLength(150)onCreateTeamDto.name.@MaxLength(255)onCreateMilestoneDto.titleand@MaxLength(2000)ondescription, with corresponding column lengths inMilestoneentity.@MaxLength(150)onCreatePoolDto.nameand corresponding column length inMaintenancePoolentity.Validation
npm testexcluding disconnected Postgres DB integration specs): all 20 test suites and 163 unit tests passed cleanly.npm run build): clean build.Closes #138, Closes #139, Closes #148, Closes #149, Closes #151