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

Filter out audit logs that a user cannot see #570

Merged
merged 13 commits into from
Jul 26, 2024
Merged

Conversation

bloodearnest
Copy link
Member

@bloodearnest bloodearnest commented Jul 22, 2024

This change ensures that users don't see audit messages that they shouldn't see.

It uses exactly same logic as previous work hiding comments/votes from users. So, this means

  • Request author and other non-output-checkers cannot see private comment audit logs from any turn
  • When in INDEPENDENT phase, output-checkers cannot see each others audit logs for votes/comments from the current turn
  • When in CONSOLIDATING phase, output-checkers can see each others audit logs for votes/comments from the current turn, but the author cannot
  • When in AUTHOR phase, authors can now see the audit logs votes and public comment from the previous turn.
  • When in COMPLETE phase, all items from all turns are visible, subject to private/public rules

Fixes #534

Copy link
Contributor

@rebkwok rebkwok left a comment

Choose a reason for hiding this comment

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

I realise that some of the questions are about previous comment-visibility functionality that isn't specific to the audit log, but given that this is refactoring the previous visibility code, I think it's probably worth fixing here.

Some notes in pictures:

  1. Here an author (researcher_1) has made a public comment before submitting the request. It's visible to everyone, but to the output-checkers it says "only visible to you until reviews are complete"
    1  author's public comment says only visible to you (but is visible to other checkers)

  2. Here 2 output-checkers have completed their review, but haven't returned/rejected yet. Status is REVIEWED, so the public comment from output-checker 1 is NOT visible to the researcher yet, but it says it's visible to all.
    2  output-checker 1 comment is still hidden to the researcher but shows as public

  3. Just to confirm - this is researcher 1's view. They can only see their initial, pre-submission comment.
    3  output checker 1 comment in turn 1 not visible to author

  4. This is the author's view after an output-checker rejected the request. The turn has not incremented, and the author doesn't see any of the public comments that were made before rejection. I think this is incorrect - otherwise there's no notification to the researcher on the reason for the rejection (presumably less important when it moves to released, but for withdrawn, the user could make a comment to say why they withdrew it, which would never be exposed to anyone else)
    4  request rejected - author never sees public comments from turn 1

airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
tests/unit/test_business_logic.py Show resolved Hide resolved
tests/unit/test_business_logic.py Show resolved Hide resolved
@bloodearnest
Copy link
Member Author

I realise that some of the questions are about previous comment-visibility functionality that isn't specific to the audit log, but given that this is refactoring the previous visibility code, I think it's probably worth fixing here.

Right, there is separate ticket for this, think #512

For the first 3 screen shots, I think the actual visiblity is correct (i.e. whether its shown or not)? But the text explaining the visibility is all kinds of wrong, which the issue above is tracking.

For the 4th screenshot, that is a bug, as noted in my reply to another comment: #570 (comment)

@bloodearnest bloodearnest force-pushed the audit-visibility branch 2 times, most recently from cb67667 to eb60083 Compare July 23, 2024 14:38
@bloodearnest
Copy link
Member Author

bloodearnest commented Jul 23, 2024

I have renamed and clarified things with comments as suggested.

I have added coverage and fixed the interaction between reject/approved/release and visible comments by taking COMPLETE status into account.

I have also fixed #512 I think by only blinding comments from the current round.

Copy link
Contributor

@rebkwok rebkwok left a comment

Choose a reason for hiding this comment

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

A few nits, that's all

airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
airlock/business_logic.py Outdated Show resolved Hide resolved
This will allow us to use the exact same logic for filtering the audit
log for visibility as well.
It's doesn't provide much value, and the logic of filtering for
visibility when we may have multiple active requests is quite complex.

We can revisit this later, perhaps.
This will bypass visibilty filtering, which is desirable in tests, as we
mostly want to check that our audits were persisted.

It allow use to repurpose the BLL get_audit_log message return logs
filtered for visibility, which is the normal production use case.
This reflects the changes made in earlier commits, and that we are only
using this BLL method for request/group pages.
We make AuditEvent satisfy use the VisibleItem protocol, so we can use
`filter_visible_items` to filter the audit log appropriately.

We record the review_turn an AuditEvent is generated in to facilitate
this.

Exposed we'd couple in technically incorrectly constructed AuditEvents
in tests, which were fixed.
This meant extending the big multi-round walk through test to assert
audit log visibilties. This ended up adding a supportting VisibleItems
helper to keep the many many assertions readable.

The large test is even bigger now, but given the complexity of setting
up the state, I think this is still the best way to test this.
Add more comments, and rename can_see_private to user_can_review
Now its being used in the generic filter_visible_items logic, it applies
to audit logs as well as comments
Previously, our test case didn't get the request state over the line to
where the phase was COMPLETE, so we missed the fact that final comments
might not be shown.

So I changed the big test to reject instead of return, which moves us to
COMPLETE phase, and then added the logic handling correctly to
filter_visible_items.
Previously, whilst in INDEPENDANT phase, all comments would be shown
with the independent description, for researchers or output checkers

Now, that logic only applies to comments from the current round, which
are the only ones subject to blinding.

Additionally, I noticed that blinded comment text didn't make it clear
whether it was a public or private comment, so it now builds on that
information.

Added an explicit test to cover this logic.

Fixes #512
The language was too long to fit inside the pill.

Given these comment visibilites are only shown to output-checkers, we
just used the "Private", or "Public", and an optional "Blinded" one.

I tried to add tooltips for these with the text description, but they
don't current work properly inside pill components. Thomas is looking at
tooltips, so we can fix that then.  I've left the machinery for
displaying them intact, but have commented out in the template.

I'll add a ticket to renable the tooltips once they work inside a pill.
bloodearnest and others added 2 commits July 25, 2024 18:30
Co-authored-by: Becky Smith <becky.smith@thedatalab.org>
@bloodearnest bloodearnest merged commit 415eb2c into main Jul 26, 2024
10 checks passed
@bloodearnest bloodearnest deleted the audit-visibility branch July 26, 2024 08:44
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.

Extend visibility logic to audit log
2 participants