Repository navigation
fix: add missing ownership checks to tag, report-log, and dataset-schema endpoints #43390
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
Changes from all commits
599697b
6ee4820
13af5cc
816b98f
c91505e
345d7c3
0dbd0df
d0861c3
0ceacde
bf4a781
b8ffd8d
9da5553
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,19 +18,22 @@ | |
| from functools import partial | ||
| from typing import Any | ||
|
|
||
| from marshmallow import ValidationError | ||
|
|
||
| from superset import security_manager | ||
| from superset.commands.base import BaseCommand | ||
| from superset.commands.exceptions import TagNotFoundValidationError | ||
| from superset.commands.tag.exceptions import ( | ||
| TagDeleteFailedError, | ||
| TagDeleteForbiddenValidationError, | ||
| TaggedObjectDeleteFailedError, | ||
| TaggedObjectNotFoundError, | ||
| TagInvalidError, | ||
| TagNotFoundError, | ||
| ) | ||
| from superset.commands.tag.utils import to_object_model, to_object_type | ||
| from superset.daos.tag import TagDAO | ||
| from superset.exceptions import SupersetSecurityException | ||
| from superset.tags.models import ObjectType | ||
| from superset.tags.models import ObjectType, TagType | ||
| from superset.utils.decorators import on_error, transaction | ||
| from superset.views.base import DeleteMixin | ||
|
|
||
|
|
@@ -134,10 +137,42 @@ def run(self) -> None: | |
| TagDAO.delete_tags(self._tags) | ||
|
|
||
| def validate(self) -> None: | ||
| exceptions = [] | ||
| # Validate tag exists | ||
| for tag in self._tags: | ||
| if not TagDAO.find_by_name(tag): | ||
| exceptions.append(TagNotFoundError(tag)) | ||
| # Every item appended here must be a ValidationError (or subclass), | ||
| # since TagInvalidError.normalized_messages() calls | ||
| # .normalized_messages() on each one to build the aggregated 422 | ||
| # response. | ||
| exceptions: list[ValidationError] = [] | ||
| for tag_name in self._tags: | ||
| tag_name = tag_name.strip() | ||
| tag = TagDAO.find_by_name(tag_name) | ||
| # Validate tag exists | ||
| if not tag: | ||
| exceptions.append( | ||
| TagNotFoundValidationError(f"Tag with name {tag_name} not found.") | ||
| ) | ||
| continue | ||
| # System-generated tags (type:*, editor:*, favorited_by:*) are | ||
| # maintained by Superset itself and must not be deletable through | ||
| # the bulk route. | ||
| if tag.type is not None and tag.type != TagType.custom: | ||
| exceptions.append( | ||
| TagDeleteForbiddenValidationError( | ||
| f"Tag {tag_name} is a system tag and cannot be deleted" | ||
| ) | ||
| ) | ||
| continue | ||
|
Comment on lines
+154
to
+163
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, while I was working on the Subject feature, I noticed these system generated tags are apparently not used anywhere(!). So while we're at it, I suggest we consider removing them all together if they're not used at all.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh... I'll take a look into that. Might merge this as-is, then do a sweep on a fresh PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got a bot on it now.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed and followed up on: nothing in the UI ever surfaced these (every tags list/filter in the frontend explicitly excludes non-custom tags), so it was pure write-side overhead — 13 event listeners across 5 models on every save/favorite. Removed the generation, kept the |
||
| # Deleting a tag cascades removal of all of its associations | ||
| # org-wide, so existence is not enough: require the user to be an | ||
| # admin or the tag's creator (the single-association route | ||
| # enforces per-object access in DeleteTaggedObjectCommand). | ||
| if not ( | ||
|
rusackas marked this conversation as resolved.
Resolved
|
||
| security_manager.is_admin() | ||
| or (tag.created_by and tag.created_by == security_manager.current_user) | ||
| ): | ||
| exceptions.append( | ||
| TagDeleteForbiddenValidationError( | ||
| f"Access denied to tag {tag_name}" | ||
| ) | ||
| ) | ||
| if exceptions: | ||
| raise TagInvalidError(exceptions=exceptions) | ||
Uh oh!
There was an error while loading. Please reload this page.