Repository navigation
fix(service): require authentication for push/repo/user read APIs and trim file-sink push list (sfind-0d184eca) - #27
Conversation
GET /api/v1/push and /api/v1/push/:id (and the repo/user routers) were mounted behind jwtAuthHandler only, which calls next() when JWT API auth is disabled (the shipped default). Add ensureAuthenticated after it so an authenticated session or req.user is always required. Finding: sfind-0d184eca06e84568b1b702489eaf0f34 Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…d (sfind-0d184eca) Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…ead APIs require auth Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Verificação (antes/depois) O
(No caso logado, "LEAKS" só indica que o usuário autenticado continua recebendo os dados completos, que é o comportamento esperado.)
Ainda não testado:
|
…sink's push list Co-Authored-By: Samir Chaudhry <samir@cognition.ai>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Devin Review found 2 new potential issues.
Custom reviewers
| if (!query) query = defaultPushQuery; | ||
| return new Promise((resolve, reject) => { | ||
| db.find(query) | ||
| .projection(pushListProjection) |
There was a problem hiding this comment.
⏱️ TD API Contracts: Push list drops existing v1 fields
For file-sink lists, getPushes changes v1 records from full actions to summaries without attestation, autoApproved, or lastStep. getGitPushes still prints these fields, so CLI users now receive undefined instead of approval and diagnostic data. Dropping existing response fields within v1 violates §4 compatibility.
View in Devin Review · Custom reviewer
Was this helpful? React with 👍 or 👎 to provide feedback.
| if (sessionAuthed || req.user) { | ||
| return next(); | ||
| } | ||
| res.status(401).send({ message: 'Authentication required' }); |
There was a problem hiding this comment.
⏱️ TD API Contracts: Authentication errors omit required problem details
For unauthenticated push, repository, and user requests, ensureAuthenticated returns application/json containing only {"message":"Authentication required"}. §4 requires RFC 9457 application/problem+json with a <DOMAIN>-<4 digits> code and correlationId. API clients receive neither the required error code nor a correlation identifier.
View in Devin Review · Custom reviewer
Was this helpful? React with 👍 or 👎 to provide feedback.
Co-Authored-By: Samir Chaudhry <samir@cognition.ai>
Description
Fixes code scan finding sfind-0d184eca06e84568b1b702489eaf0f34 (high):
GET /api/v1/pushandGET /api/v1/push/:idanswered anonymous requests, exposing full diffs, commit messages, author emails and the secret literals recorded byscanDiff.Root cause:
src/service/routes/index.tsmounted thepush,repoanduserrouters behindjwtAuthHandler()only, which callsnext()when the JWTapiAuthenticationmethod is disabled (the default inproxy.config.json). The read handlers inpush.tsnever checkreq.user.Fix:
ensureAuthenticatedmiddleware (src/service/routes/middleware.ts): passes a passport session (req.isAuthenticated()) or areq.userset by an earlier handler (e.g. JWT); otherwise returns401 { message: 'Authentication required' }.jwtAuthHandler()on/api/v1/push,/api/v1/repoand/api/v1/user, so protection no longer depends on the optional JWT method.getPushesnow applies the same field projection as the Mongo adapter, so the list no longer returnssteps(diff / scan output),user,userEmailorattestation. The full document is still available fromGET /api/v1/push/:idto authenticated users. The dashboard list only readscommitData,repo,branch,url,commitToandid, all of which are kept.Login.tsx; they would now hit 401 and bounce back to login.API contract change
GET /api/v1/push,GET /api/v1/push/:id,GET /api/v1/repo[/:id]andGET /api/v1/user[/:id]now require an authenticated session (or a valid JWT when enabled). Anonymous calls get 401.Not logged in/You are not authorised to perform this action.toAuthentication required.git-proxy-cli lsno longer showsattestation,autoApprovedorlastStepin list output, matching the existing Mongo behaviour.Tests
test/services/routes/middleware.test.ts(unit + router).test/testPush.test.ts: anonymous list/detail return 401; authenticated list omitssteps/user/userEmail/attestation; detail returns the full push.test/testDb.test.ts: list projection test; create-push now checked viagetPush.npx vitest --run test/testDb.test.ts test/testPush.test.ts test/testRepoApi.test.ts test/services/routes/middleware.test.ts test/db test/ui/git-push.test.ts: 214 passed, 45 skipped. Fullvitestfailures are limited to the knownConfigLoader/plugin/Docker e2e/experimentalsuites that also fail onmain.How to verify
npm run server, thencurl -i http://localhost:8080/api/v1/pushwith no cookie returns401.POST /api/auth/login) and repeat with theconnect.sidcookie:200with the list, withoutsteps/user/userEmail/attestation.Related Issue
Code scan finding
sfind-0d184eca06e84568b1b702489eaf0f34.Checklist
General
Documentation
Configuration
config.schema.json) was modified: N/ATests
npm test)npm run lintandnpm run format:check)npm run check-types) (except pre-existing errors inAttestationInfo.tsx)Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/a3684abf498d4cbcb15511543f17a602
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/a3684abf498d4cbcb15511543f17a602?variant=devin
Requested by: @schaudhry123
Devin Review