Disallow PII access to restricted patients in ops tools#6469
Open
Disallow PII access to restricted patients in ops tools#6469
Conversation
- Fix bug where user selects no parameters for an event type so it reverts to the default - Fix bug where a non-PII user could view PII by modifying the URL
thomasleese
reviewed
Apr 7, 2026
| show_pii: | ||
| ).load_timeline_events(@event_names) | ||
|
|
||
| # binding.irb |
Contributor
There was a problem hiding this comment.
I think we can delete this this line.
Comment on lines
+72
to
+82
| def show_pii | ||
| @show_pii ||= | ||
| begin | ||
| @pii_access_requested_by_user = params[:show_pii] || SHOW_PII_BY_DEFAULT | ||
| @patient_accessed_is_sensitive = | ||
| @patient.restricted? || @compare_patient&.restricted? | ||
| @user_is_allowed_to_access_pii = policy(:inspect).show_pii? | ||
|
|
||
| @user_is_allowed_to_access_pii && !@patient_accessed_is_sensitive && | ||
| @pii_access_requested_by_user | ||
| end |
Contributor
There was a problem hiding this comment.
I think the structure of this method is a little unusual where its name would suggest that it has no side-effects (as it simply calculates and returns a value), but it does set member variables other than @show_pii.
If we want to keep this method, I would suggest extracting pii_access_requested_by_user, patient_accessed_is_sensitive and user_is_allowed_to_access_pii in to separate memoized methods which can then be called here.
Comment on lines
+55
to
+59
| @sensitive_patient_in_graph = | ||
| graph_with_pii.patients_with_pii_in_graph.any?(&:restricted?) | ||
| @pii_access_requested_by_user = | ||
| params[:show_pii] || SHOW_PII_BY_DEFAULT | ||
| @user_is_allowed_to_access_pii = policy(:inspect).show_pii? |
Contributor
There was a problem hiding this comment.
Similar here, I think these could be extracted in to separate methods.
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.
This disallows PII access to restricted patients for ops users, and fixes some small bugs related to the ops tools:
One test still requires fixing.
Jira Issue - MAV-3019