Skip to content

Disallow PII access to restricted patients in ops tools#6469

Open
samcoy3 wants to merge 2 commits intonextfrom
ops-tools-restricted-records
Open

Disallow PII access to restricted patients in ops tools#6469
samcoy3 wants to merge 2 commits intonextfrom
ops-tools-restricted-records

Conversation

@samcoy3
Copy link
Copy Markdown
Contributor

@samcoy3 samcoy3 commented Mar 30, 2026

This disallows PII access to restricted patients for ops users, and fixes some small bugs related to the ops tools:

  • 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

One test still requires fixing.

Jira Issue - MAV-3019

samcoy3 added 2 commits March 30, 2026 17:33
- 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
@samcoy3 samcoy3 requested a review from a team as a code owner March 30, 2026 16:42
@thomasleese thomasleese added the operations Improving live support label Mar 31, 2026
@thomasleese thomasleese modified the milestones: v7.7.0, v7.8.0, v7.9.0 Mar 31, 2026
show_pii:
).load_timeline_events(@event_names)

# binding.irb
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar here, I think these could be extracted in to separate methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

operations Improving live support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants