Skip to content

fix: prevent cross-org ObjectTags from being created#633

Merged
pomegranited merged 3 commits intojill/tagging-less-queriesfrom
jill/tagging-cross-org
Feb 15, 2024
Merged

fix: prevent cross-org ObjectTags from being created#633
pomegranited merged 3 commits intojill/tagging-less-queriesfrom
jill/tagging-cross-org

Conversation

@pomegranited
Copy link

@pomegranited pomegranited commented Feb 14, 2024

Addresses this comment openedx#34146 (comment) about disallowing cross-org tagging and tagging using "no org" taxonomies.

Testing instructions

These changes should be validated by the unit tests.

A "cross-org" ObjectTag is when the object_id references an org that is
not in the taxonomy's allowed list of orgs.

Similarly, we forbid creating object tags for a taxonomy with no allowed
orgs listed.

This change adds a rules check for this case, and updates the tests.
Copy link

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me @pomegranited ! I just had similar question regarding the assert.

  • I tested this: I checked the updated tests and confirmed they are passing
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository.

if not is_all_org:
# object_id is valid, else it would have thrown in can_change_object_tag_objectid
context_key = get_context_key_from_key_string(perm_obj.object_id)
assert context_key.org

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the question I had on openedx#34200 (comment) , if we should handle the AssertionError and return False or does the @rules.predicate or elsewhere handle it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll handle it and return False.

@pomegranited pomegranited merged commit eac1f26 into jill/tagging-less-queries Feb 15, 2024
@pomegranited pomegranited deleted the jill/tagging-cross-org branch February 15, 2024 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants