Repository navigation
feat(flowscript): secure project-scoped API and deployment boundaries (#651) - #665
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
CodeAnt Nitpicks3 code suggestions1. The accepted
|
CodeAnt PR Risk: Medium Risk
Assessed commit: |
|
Rebase request ⏰ — Could you rebase onto Suggested order for your stack: #664 first, then #665, then #666 last (it contains all three branches via merge commits, so it'll reduce to its own CI-job delta once the parents land). — Hermes Agent, on behalf of @Mihir-Rabari |
|
Quick re-ping @atharvashukla098-tech ⏰ — the rebase request above (~16:06Z) is ~3h unanswered, so bumping it once to keep Also: your 16:30Z fix commit Current state:
Suggested stack order remains 664 → 665 → 666 (rebasing on top of #664 avoids a second conflict pass). 🙌 |
|
👋 Friendly bump — still CONFLICTING against dev (head |
|
4th ping — rebase still owed (~7h). Still CONFLICTING with |
…ff (#657) - Preserve cancelled status in finishRun to prevent worker result overwrite - Cap exponential backoff with jitter strictly at maxMs - Abort worker execution if heartbeat detects lease loss (!hb.active) - Document succeeded attempt status and backoff formula in EXECUTION.md
… align attempt status doc
… (#651) - Enforce cryptographic gateway signatures (HMAC-SHA256) and signed Bearer tokens - Fail closed when gateway secret is missing - Validate project ID format and reject forged project headers on identity conflict - Add stripUntrustedProjectHeaders helper for edge gateway sanitization - Enforce global 1MB payload bodyLimit mapping to PAYLOAD_TOO_LARGE - Implement x-request-id correlation across request headers and error responses - Standardize error envelope with statusCode, code, error, message, requestId - Enforce flow name verification and project isolation on deploy - Add comprehensive tenant isolation test suite and update documentation
…axonomy and json parser
82202b9 to
1915f9d
Compare
|
@Mihir-Rabari @hermes-agent Rebased eat/flowscript-tenant-isolation onto PR #664 (40a8a5e), resolved trigger column integration with #663, addressed all CodeAnt review feedback, and verified 100% test pass (238 passed, 0 failed) with clean typecheck and lint. Ready for review and merge. |
Mihir-Rabari
left a comment
There was a problem hiding this comment.
Review TL;DR — ✅ APPROVE
Reviewed head: 1915f9dfe1 (delta on top of merged #664 40a8a5e11a; full CI matrix green at this head; issues #651)
First review after the rebase — the 16:30Z Oct-17 polish commit (missedTickPolicy / error-taxonomy) is folded in and credited. This delta is a genuinely strong hardening pass.
✅ Strengths
- Identity confusion closed: Bearer-token project vs caller-supplied
x-project-idconflicts now 401FORGED_PROJECT_HEADER(auth.ts), plus strict/^[a-zA-Z0-9_-]{1,128}$/project-ID validation and trimmed signature handling. - Standardized error envelope everywhere (
sendError: statusCode/code/error/message/requestId) + FastifysetErrorHandlermapping (FST_ERR_CTP_BODY_TOO_LARGE→ 413PAYLOAD_TOO_LARGE, invalid JSON → 400) — exactly the #651 envelope ask, and API.md now documents every code. x-request-idpropagation: accepts caller/edge IDs (≤128 chars) or generates UUIDv4, echoed viaonSend+ embedded in all error envelopes — trace correlation finally exists.- Global 1MB
bodyLimitwith 413 handling — the #651 input-limit ask. - Deploy boundaries enforced and classified: cross-project version deploy → 404
VERSION_NOT_FOUND; URL:namevs version flow-name mismatch → 400FLOW_NAME_MISMATCH(project-scoped version lookup in store makes the cross-project case impossible to bypass). stripUntrustedProjectHeadersexported for edge gateways (deletesx-project-id/x-project-signature/x-gateway-signature), documented in SECURITY.md.- SECURITY.md honestly re-baselined from "current blockers" to concrete enforced controls.
🔴 Blocking — none.
services/flowscript/src/server.tstrigger-create catch: infra failures (e.g. pg outage increateFlowTrigger) still classify as 422TRIGGER_CREATION_FAILED— the codeant thread asked for 500 on internal errors. The cron/timezone/policy → 400 split is right; consider distinguishing DB/unique-constraint errors → 500INTERNAL_SERVER_ERRORnext pass. Same idea for the deploy catch's 422DEPLOYMENT_FAILED.
💡 Nits
- The
/v1/flows/:name/runs/:id/cancelroute still doesn't check:nameagainst the run's flow (inherited from #664, noted there — intra-project only).
Tests ✅ — tenant_isolation.test.ts (584 lines) is the right shape: full 401 sweep across every project-scoped route, forged-header/invalid-HMAC/identity-conflict/fails-closed cases with exact code assertions, cross-project deploy + run + trigger isolation (list leaks nothing; get/patch/rotate/delete all 404 with owner data intact), request-id echo + UUID generation, and a real 1.2MB body → 413 test. Negative paths everywhere — not tautologies.
Prior feedback status
- codeant server.ts:366 (DB outage → 422 misclassification) → partial (validation errors now 400; envelope + code stable; infra errors still 422 — see should-fix #1, non-blocking).
- Banked 16:30Z commit (missedTickPolicy validation, error taxonomy) → addressed in this delta.
Acceptance criteria (#651): gateway identity hardening ✅ · forged/identity-conflict rejection ✅ · project-scoped authorization on publish/deploy/run/trigger/run-inspection ✅ · deploy :name validation ✅ · normalized error envelope ✅ · source/input limits ✅. Deferred (reasonable): per-user membership model (project-level gateway identity is the current design), versioned DB migrations.
Merging now — #666 (the CI-job + E2E layer) is next on the stack.
— Hermes Agent, reviewing on behalf of @Mihir-Rabari
User description
Resolves #651
Summary of Changes
CodeAnt-AI Description
Make FlowScript runs retryable, cancellable, and isolated by project
What Changed
Impact
✅ Fewer transient flow failures✅ Fewer duplicate external actions✅ Blocked cross-project access💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.