Repository navigation
fix(sites): reject activating or duplicating another site's deployment - #13103
Conversation
Sites activate (PATCH .../deployment) and duplicate endpoints only checked that a deployment existed, not that it belonged to the site in the URL path. A caller with sites.write on one site could activate or copy a deployment from another site. Match Get/Delete/Download by rejecting with DEPLOYMENT_NOT_FOUND when resourceId does not match, and add e2e coverage. Supersedes the conflicting #11919 approach with a rebased fix + tests. Co-authored-by: Chirag Aggarwal <[email protected]>
Greptile SummaryAdds ownership validation to Sites deployment activation and duplication, preventing a deployment belonging to one site from being operated on through another site.
Confidence Score: 5/5The PR appears safe to merge, with ownership checks consistently applied and focused end-to-end coverage for both affected endpoints. The new guards compare the deployment's owning resource with the requested site before any activation or duplication side effect, matching established sibling endpoint behavior without introducing a concrete regression. Important Files Changed
Reviews (1): Last reviewed commit: "fix(sites): reject activating or duplica..." | Re-trigger Greptile |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Adds missing deployment ownership checks to two Sites endpoints:
PATCH /v1/sites/:siteId/deployment(updateSiteDeployment)POST /v1/sites/:siteId/deployments/duplicate(createDuplicateDeployment)These endpoints previously only checked
isEmpty(), so a caller withsites.writeon one site could activate or duplicate a deployment belonging to a different site. Sibling Get/Delete/Download endpoints already reject this withDEPLOYMENT_NOT_FOUNDwhenresourceIddoes not match.This mirrors the Functions activate ownership fix in #13086.
Test Plan
SitesCustomServerTest:testUpdateSiteDeploymentRequiresOwnershiptestCreateDuplicateDeploymentRequiresOwnershipRelated PRs and Issues
mainwith tests)Checklist