Skip to content
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

Rework how supersearch fields permissions are handled #6764

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

willkg
Copy link
Contributor

@willkg willkg commented Oct 23, 2024

In PR #6741, we're moving the code where we convert between the processed crash schema permissions in super search fields to webapp permissions to the general Socorro code. We try really hard to not have webapp things leak into the general Socorro code, so I wanted to experiment with other ways of solving the problem of having two elasticsearch crash storage implementations in respects to super search fields.

This tests that out by adding a get_supersearch_fields() function to webapp/crashstats/supersearch/libsupersearch.py which imports the specified Elasticsearch crashstorage, gets SUPERSEARCH_FIELDS from it, converts the permissions and returns it.

While doing that, I fixed some clarity issues in the code. convert_permissions will never have a case where the field has permissions ["public", "protected"]--that's nonsensical so we shouldn't test that. Also, convert_permissions shouldn't stomp on the permissions_needed value. Instead, it should put the webapp permissions in a new key and then webapp code should look there.

Previously, the code in the webapp that managed the permissions for
supersearch fields was kind of clunky. This fixes it so it's easier to
continue with the Elasticsearch migration and also improves code clarity
around how permissions are converted and checked.
@willkg willkg requested a review from a team as a code owner October 23, 2024 18:46
@willkg willkg requested a review from relud October 23, 2024 18:46
@@ -15,22 +15,25 @@ def test_convert_permissions():
"permissions_needed": ["public"],
},
"version": {
"permissions_needed": ["public", "protected"],
Copy link
Contributor Author

@willkg willkg Oct 23, 2024

Choose a reason for hiding this comment

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

This is nonsensical. We shouldn't test this case like this, so I changed to to just "protected".

Copy link
Member

@relud relud left a comment

Choose a reason for hiding this comment

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

I like this better than my solution 💯

@willkg willkg added this pull request to the merge queue Oct 24, 2024
Merged via the queue into main with commit 9b425e5 Oct 24, 2024
1 check passed
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.

2 participants