-
Notifications
You must be signed in to change notification settings - Fork 0
test: comment dedup - will push a fix to trigger re-review #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||||||||||||||||||||||||||||
| const express = require('express'); | ||||||||||||||||||||||||||||||||
| const router = express.Router(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // In-memory project store | ||||||||||||||||||||||||||||||||
| let projects = []; | ||||||||||||||||||||||||||||||||
| let nextId = 1; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // GET /projects | ||||||||||||||||||||||||||||||||
| router.get('/', (req, res) => { | ||||||||||||||||||||||||||||||||
| res.json(projects); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: In-memory data store for projects The |
||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // GET /projects/:id | ||||||||||||||||||||||||||||||||
| router.get('/:id', (req, res) => { | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Missing pagination for list endpoint The GET /projects endpoint does not support pagination with Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] style: Missing JSDoc comments for route handlers All route handlers are missing JSDoc comments describing their parameters and return values, which violates the project's coding style rules. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| const project = projects.find(p => p.id == req.params.id); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [LOW] style: Use strict equality ( Loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| if (!project) return res.status(404).json({ error: 'Project not found' }); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: GET /projects lacks pagination The |
||||||||||||||||||||||||||||||||
| res.json(project); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Missing pagination for GET /projects The Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Incorrect list response format for GET /projects The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| // POST /projects | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] correctness: Loose equality ( The use of loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| router.post('/', (req, res) => { | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Missing input validation for new projects The |
||||||||||||||||||||||||||||||||
| const { name, description, status } = req.body; | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] correctness: Use strict equality for ID comparisons The code uses loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] style: Use strict equality (===) instead of loose (==) Loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| // Minor issue: no input validation at all | ||||||||||||||||||||||||||||||||
| const project = { | ||||||||||||||||||||||||||||||||
| id: nextId++, | ||||||||||||||||||||||||||||||||
| name, | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Mutating endpoints lack authentication The |
||||||||||||||||||||||||||||||||
| description, | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: No input validation on project creation The |
||||||||||||||||||||||||||||||||
| status: status || 'active', | ||||||||||||||||||||||||||||||||
| tasks: [], | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Missing Authentication on POST /projects The POST /projects endpoint, which creates new project resources, is not protected by any authentication middleware. This allows any unauthenticated user to create projects, violating the 'All mutating endpoints must be behind authentication middleware' rule. Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing Input Validation for POST /projects The POST /projects endpoint lacks input validation for Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing authentication for POST /projects The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing input validation for POST /projects The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| createdAt: new Date().toISOString() | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| projects.push(project); | ||||||||||||||||||||||||||||||||
| res.status(201).json(project); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // PUT /projects/:id | ||||||||||||||||||||||||||||||||
| router.put('/:id', (req, res) => { | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [LOW] style: Use strict equality ( Loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| const project = projects.find(p => p.id == req.params.id); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Incorrect HTTP status code for resource creation According to API design patterns, a successful resource creation (POST) should return an HTTP 201 Created status code, not 200 OK. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| if (!project) return res.status(404).json({ error: 'Project not found' }); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Missing The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Minor issue: overwrites entire object without preserving id/createdAt | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Missing Authentication on PUT /projects/:id The PUT /projects/:id endpoint, which modifies existing project resources, is not protected by any authentication middleware. This allows any unauthenticated user to modify projects, violating the 'All mutating endpoints must be behind authentication middleware' rule. Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing Input Validation for PUT /projects/:id The PUT /projects/:id endpoint lacks input validation for Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: Missing The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| project.name = req.body.name; | ||||||||||||||||||||||||||||||||
| project.description = req.body.description; | ||||||||||||||||||||||||||||||||
| project.status = req.body.status; | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] architecture: PUT endpoint lacks The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] correctness: PUT overwrites immutable fields The PUT /projects/:id endpoint overwrites the entire project object without preserving immutable fields like Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| res.json(project); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing authentication for PUT /projects/:id The |
||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // DELETE /projects/:id | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [LOW] style: Use strict equality ( Loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| router.delete('/:id', (req, res) => { | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] quality: PUT overwrites fields and misses The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| const index = projects.findIndex(p => p.id == req.params.id); | ||||||||||||||||||||||||||||||||
| if (index === -1) return res.status(404).json({ error: 'Project not found' }); | ||||||||||||||||||||||||||||||||
| projects.splice(index, 1); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Missing Authentication on DELETE /projects/:id The DELETE /projects/:id endpoint, which removes project resources, is not protected by any authentication middleware. This allows any unauthenticated user to delete projects, violating the 'All mutating endpoints must be behind authentication middleware' rule. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| res.status(204).send(); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing authentication for DELETE /projects/:id The |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Mutating endpoint lacks authentication The |
||||||||||||||||||||||||||||||||
| // POST /projects/:id/tasks - add a task reference to a project | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [LOW] style: Use strict equality ( Loose equality ( Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| router.post('/:id/tasks', (req, res) => { | ||||||||||||||||||||||||||||||||
| const project = projects.find(p => p.id == req.params.id); | ||||||||||||||||||||||||||||||||
| if (!project) return res.status(404).json({ error: 'Project not found' }); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] correctness: No validation or existence check for taskId The |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [CRITICAL] security: Missing Authentication on POST /projects/:id/tasks The POST /projects/:id/tasks endpoint, which adds tasks to a project, is not protected by any authentication middleware. This allows any unauthenticated user to modify projects, violating the 'All mutating endpoints must be behind authentication middleware' rule. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| // Minor issue: no validation on taskId, no check if task actually exists | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing authentication for POST /projects/:id/tasks The |
||||||||||||||||||||||||||||||||
| const { taskId } = req.body; | ||||||||||||||||||||||||||||||||
| project.tasks.push(taskId); | ||||||||||||||||||||||||||||||||
| res.json(project); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [MEDIUM] quality: No validation or existence check for The Suggestion:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: No validation for taskId in project tasks The |
||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 [HIGH] security: Missing validation for taskId in POST /projects/:id/tasks The Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| module.exports = router; | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 [MEDIUM] architecture: Missing pagination for project list
The
GET /projectsendpoint returns all projects without supporting pagination. For larger datasets, this can lead to performance issues and large response payloads, violating the API design rule for list endpoints.