Repository navigation
Conversation
…ection Patch copied the connectionId from the URL into the request body and saved it, so PATCHing a scope config through another connection's URL returned 200 and silently moved the scope config to that connection. Verify the ownership first and return 404 when the scope config belongs to a different connection. Signed-off-by: Goldloli <39011904+Goldloli@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DsScopeConfigApiHelper.Patchcopied theconnectionIdfrom the URL into the request body and then saved the scope config. The scope config itself is looked up by its own primary key only, so a PATCH sent through another connection's URL returned 200 and silently reassigned the scope config to that connection.This PR verifies the ownership before writing anything and returns 404 when the scope config belongs to a different connection, which matches what the issue asks for. The request body is still forced to the URL's
connectionId, so a PATCH cannot change the owning connection.Does this close any open issues?
Closes #9417
Screenshots
No UI change.
Other Information
Change —
backend/helpers/pluginhelper/api/ds_scope_config_api_helper.goThe check is generic, so it covers every plugin that routes
PATCH .../connections/:connectionId/scope-configs/:scopeConfigIdthroughDsScopeConfigApiHelper.Tests — new
backend/helpers/pluginhelper/api/ds_scope_config_api_helper_test.goTestPatchScopeConfigRejectsForeignConnection: a scope config owned by connection 1, PATCHed through connection 2, now fails withNotFound; the stored record keeps its connection and name and noUpdatereaches the database.TestPatchScopeConfigAcceptsOwningConnection: the same PATCH through the owning connection still updates the record.Verification
Re-running the two new tests against the pre-fix
PatchmakesTestPatchScopeConfigRejectsForeignConnectionfail as expected (erris nil and the record is written), so the test does exercise the reported behaviour.go test ./helpers/...additionally fails inhelpers/e2ehelper, which panics inNewDataFlowTesterbefore any of this code runs; it needs a MySQL instance and fails the same way on a clean checkout ofmain.I did not add an e2e case: the existing
TestUpdateScopeConfiginbackend/test/e2e/remote/python_plugin_test.goalways PATCHes through the owning connection, so its expectations are unchanged.