-
Notifications
You must be signed in to change notification settings - Fork 1
security #159
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
security #159
Conversation
WalkthroughUpdated Docker base image to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 2 inconclusive)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/loading/k6.js (1)
1-55: Fix invalid crypto import and make admin password configurableTwo blocking issues:
Crypto import will fail in k6
- k6 doesn't recognize
'crypto'as a module. k6-specific modules use the'k6/'prefix (e.g.,'k6/crypto','k6/http').- Even if the import somehow resolved, k6's
k6/cryptomodule exportscreateHash, nothash.- This will prevent the script from running.
Random per-run password won't match backend's seeded admin
- You generate
password = hash('sha512', randomUUID())at script load time, then use it to log in asadmin@authplus.com.- Unless the backend is seeded with the exact same random value, the login will fail and the entire load test will not execute.
Recommended fix:
- Replace the invalid crypto import. If you need hashing, use
import { hash } from 'k6/crypto'(or usek6/encodingfor base64).- Source the admin password from configuration (e.g., k6 environment variable) instead of generating it randomly. This ensures the backend's seeded password and the script's login credentials are synchronized.
🧹 Nitpick comments (3)
src/presentation/http/routes/mfa.route.ts (1)
94-95: Prefer Express helpers overwriteHeadfor JSON responsesUsing
res.writeHead(200, { 'Content-Type': 'application/json' })on an ExpressResponseis non‑idiomatic and redundant, sinceres.status(200).json(credential)(or justres.json(credential)) will set the correct status andContent-Typefor you. It also avoids setting status/headers twice in the same handler.Consider simplifying to:
- res.writeHead(200, { 'Content-Type': 'application/json' }) - res.status(200).send(credential) + res.status(200).json(credential)This will also keep the pattern consistent with other routes.
Dockerfile (1)
1-17: Node image upgrade looks fine; consider a bit more container hardeningThe upgrade to
node:24.10.0-slimacross all stages and copyingpackage.jsoninto the deploy stage make sense and align with port 5000 being used elsewhere.For additional security/operational hardening (optional here), consider:
- Running the app as a non‑root user in the final stage.
- Installing only production dependencies in the deploy stage (or pruning dev deps before copying).
- Pinning the base image by digest (
node:24.10.0-slim@sha256:...) to reduce supply‑chain risk.Also double‑check that your runtime (e.g., compose, k8s) still starts the container correctly with Node 24.
src/presentation/http/routes/login.route.ts (1)
35-36: AvoidwriteHeadon Express responses; useres.json/res.sendinsteadCalling
res.writeHead(200, { 'Content-Type': 'application/json' })and thenres.status(200).send(resp)sets status/headers twice and mixes low‑level Node APIs with Express helpers. Express will already set the correct JSON content type when you send an object.You can simplify to:
- const resp = await core.login.login(email, password) - res.writeHead(200, { 'Content-Type': 'application/json' }) - res.status(200).send(resp) + const resp = await core.login.login(email, password) + res.status(200).json(resp)and similarly in the refresh route:
- const resp = await core.token.refresh(token) - res.writeHead(200, { 'Content-Type': 'application/json' }) - res.status(200).send(resp) + const resp = await core.token.refresh(token) + res.status(200).json(resp)This keeps the handlers clearer and avoids low‑level header manipulation.
Also applies to: 51-52
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Dockerfile(1 hunks)src/presentation/http/routes/login.route.ts(2 hunks)src/presentation/http/routes/mfa.route.ts(1 hunks)src/presentation/http/routes/reset_password.route.ts(2 hunks)test/loading/k6.js(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/presentation/http/routes/reset_password.route.ts (5)
src/core/usecases/reset_password.usecase.ts (3)
recover(39-50)forget(29-37)ResetPasswordUseCase(18-51)test/unit/usecases/reset_password.usecase.test.ts (2)
newPassword(64-101)hash(15-102)test/integration/http/reset_password.route.test.ts (1)
employeePassword(117-127)src/core/usecases/driver/recover_password.driver.ts (1)
RecoverPassword(1-3)src/core/usecases/driver/forget_password.driver.ts (1)
ForgetPassword(1-3)
src/presentation/http/routes/login.route.ts (1)
test/integration/http/login.route.test.ts (3)
responseLogin(181-203)response(85-95)casual(141-179)
test/loading/k6.js (4)
test/unit/usecases/user.usecase.test.ts (1)
newName(170-212)test/unit/services/password.services.test.ts (2)
name(15-22)it(6-30)src/core/services/password.service.ts (1)
PasswordService(4-19)test/fixtures/generators.ts (1)
passwordGenerator(39-51)
src/presentation/http/routes/mfa.route.ts (2)
test/integration/http/mfa.route.test.ts (1)
response(81-91)src/core/usecases/mfa_code.usecase.ts (1)
MFACode(24-69)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
src/presentation/http/routes/reset_password.route.ts (1)
31-32: Returning empty 200s for password reset looks good; verify client expectationsChanging both
/password/forgetand/password/recoverto:await core.reset.forget(email) res.status(200).send() await core.reset.recover(password, hash) res.status(200).send()aligns with the core contracts (
Promise<void>) and avoids leaking any extra information in the response body, which is a nice security/UX improvement.Just make sure there are no frontend or external consumers relying on a non‑empty response body from these endpoints; if any do, they’ll need to be adjusted to treat “200 with empty body” as success.
Also applies to: 57-58
|



Proposal
Summary by CodeRabbit
Bug Fixes
Infrastructure
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.