fix(datasource): align access validation in legacy views#38647
Draft
sha174n wants to merge 2 commits intoapache:masterfrom
Draft
fix(datasource): align access validation in legacy views#38647sha174n wants to merge 2 commits intoapache:masterfrom
sha174n wants to merge 2 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #38647 +/- ##
==========================================
- Coverage 64.99% 64.24% -0.75%
==========================================
Files 1819 2532 +713
Lines 72515 129547 +57032
Branches 23149 29905 +6756
==========================================
+ Hits 47128 83231 +36103
- Misses 25387 44864 +19477
- Partials 0 1452 +1452
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ource view Add `security_manager.raise_for_access(datasource=datasource)` to the `get` and `external_metadata` view methods immediately after the datasource is retrieved from the DAO. For `external_metadata_by_name`, call `raise_for_access(datasource=...)` when a known datasource is found, and `raise_for_access(database=..., table=...)` when resolving an unregistered table via the SQLAlchemy inspector. In `save`, remove the `if "owners" in datasource_dict` guard so that `raise_for_ownership` is always evaluated, regardless of whether the caller omits the `owners` field from the payload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7eaf8f0 to
1d67c49
Compare
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
This PR updates the legacy datasource views to ensure consistent resource-level validation across metadata and save endpoints.
Changes:
security_manager.raise_for_accessinto theget,external_metadata, andexternal_metadata_by_namemethods to align with standard application patterns.savemethod to ensure resource ownership is validated for all update requests, regardless of the specific structure of the request payload./datasourceendpoints follow the same validation protocols used in the modern REST API layers.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
(Note: Please re-attach the screenshots/GIFs that were previously in this section.)
TESTING INSTRUCTIONS
Automated Tests:
Verify the authorization logic by running the unit test suite:
Manual Verification:
getorexternal_metadataendpoints using a datasource ID that the current user is not authorized to view./datasource/save/endpoint with an update to a datasource the user does not own, and verify the request is blocked even if theownersfield is omitted from the request data.ADDITIONAL INFORMATION