Skip to content

Raid v2 improvments - #1054

Open
maximeroucher wants to merge 20 commits into
mainfrom
raidV2-improvments
Open

Raid v2 improvments#1054
maximeroucher wants to merge 20 commits into
mainfrom
raidV2-improvments

Conversation

@maximeroucher

Copy link
Copy Markdown
Member

Description

Summary

Updating Raid to match the first points for data security

Changes Made

  • Adding consent field to the security file
  • Adding read_medical_data permission gating the zip download (now only source of security file read)
  • Logging when a zip download is attempted
  • Adding course responsible as emergency contact into the security file, as the Raid requested

Additional Notes

First step toward a better security data handling.

Classification

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🔨 Refactor (non-breaking change that neither fixes a bug nor adds a feature)
  • 🔧 Infra CI/CD (changes to configs of workflows)
  • 💥 BREAKING CHANGE (fix or feature that require a new minimal version of the front-end)
  • 😶‍🌫️ No impact for the end-users

Impact & Scope

  • Core functionality changes
  • Single module changes
  • Multiple modules changes
  • Database migrations required
  • Other: ...

Testing

  • 1. Tested this locally
  • 2. Added/modified tests that pass the CI (or tested in a downstream fork)
  • 3. Tested in a deployed pre-prod
  • 0. Untestable (exceptionally), will be tested in prod directly

Documentation

  • Updated the docs accordingly :
  • " Docstrings
  • # Inline comments
  • No documentation needed

@Marc-Andrieu Marc-Andrieu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks promising! That's a clean start about the medical data issue

Comment thread app/modules/raid/coredata_raid.py
Comment thread app/modules/raid/endpoints_raid.py
@maximeroucher
maximeroucher force-pushed the raidV2-improvments branch 3 times, most recently from 88021b7 to d3331a4 Compare August 24, 2026 12:41
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.34783% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.95%. Comparing base (e9b5f53) to head (a6dcabb).

Files with missing lines Patch % Lines
app/modules/raid/endpoints_raid.py 70.73% 12 Missing ⚠️
app/modules/raid/cruds_raid.py 60.00% 6 Missing ⚠️
app/modules/raid/dependencies_raid.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1054      +/-   ##
==========================================
- Coverage   84.99%   84.95%   -0.05%     
==========================================
  Files         220      220              
  Lines       16273    16308      +35     
==========================================
+ Hits        13831    13854      +23     
- Misses       2442     2454      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Daihecyy Daihecyy left a comment

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.

Possible to split PR ?
consent_given and course_responsible have nothing to do with each other, comments will get muddled

Comment thread app/modules/raid/cruds_raid.py
Comment thread app/modules/raid/endpoints_raid.py Outdated
Comment thread app/modules/raid/endpoints_raid.py Outdated
Comment thread app/modules/raid/endpoints_raid.py Outdated
Comment on lines +760 to +765
if not security_file.consent_given:
raise HTTPException(
status_code=400,
detail="Consent must be given to register medical data",
)

@Daihecyy Daihecyy Aug 24, 2026

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.

❓ Could replace this with consent_given: Literal[True] in the schema ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure to get it either

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.

You are doing schema validation in the endpoint
you could replace this snippet by tightening the schema validator

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.

At this point, why even bother to put it in the schema, just put it at True no matter what

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I disagree with this point. Putting Literal[True] would return a 422 validation error.
In this endpoint, a value False should be accepted (in term of schema validation). It should however return a "400 Consent must be given to register medical data", as it violates a business rules: we can not proceed given a falsy consent. When receving this error, the frontend will explain to the user why it can not proceed

Comment thread app/modules/raid/endpoints_raid.py Outdated
Comment on lines +1182 to +1189
hyperion_security_logger.info(
"Medical data access",
extra={
"accessed_by_user_id": user.id,
"edition_id": str(edition.id),
"access_type": "download",
},
)

@Daihecyy Daihecyy Aug 24, 2026

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.

💡 Archi wise, get_all_security_files_zip should own the logging for me, not the endpoint, it is the one doing the critical step
This way, we futureproof it and won't forget to log elsewhere
I would also have put the permission check in it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't see any loggers in cruds, except those for a db error, so I stuck to that architecture, maybe need the opinion of someone with more knowledge on the backend, at least on my side

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@armanddidierjean Any advice on this one will be welcomed

emergency_person_name: Mapped[str | None]
emergency_person_phone: Mapped[str | None]
file_id: Mapped[str | None]
consent_given: Mapped[bool] = mapped_column(default=False)

@Daihecyy Daihecyy Aug 24, 2026

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.

🛑 consent_given as a boolean doesn't represent a consent for me
First, it is mandatory to fill in the mandatory security sheet so not free at all (in set_security_file)
Second, we could have wanted a timestamp and/or a version number of the consent text. Here, we don't know what the user consented to nor when
Retractation doesn't seem to be handled that well, especially considering we have no historization

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

It doesn't handle retractation either but it would be a step in the right direction

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What do we do if a user rectract after the data are exported ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And does versioning suppose to had their respective text in db as well ? If we change the text during a registering, what does happen, do we just remove registered info because the participant did not consent with the latest version, or do we consider that consenting to one imply consenting to all the following ones ?

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.

Well, it seems like medical consent is a freaking pain in the ass, who would have thought ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree, storing the datetime the consent was given at would be a good addition. I think automatic retractation is out of scope of this PR. I propose we start with manual suppression of data (including the deletion of files that were downloaded by the RAID association) if someone ask ECLAIR/the RAID for its data to be removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added the date, how would you design the retractation feature ? a simple endpoint marking consent as false and clearing the data ?

@maximeroucher

Copy link
Copy Markdown
Member Author

Possible to split PR ? consent_given and course_responsible have nothing to do with each other, comments will get muddled

Given the time constraint and the time taken to review and merge a PR, I decided to put all the changes in one. I acknowledge that it will be a bit harder to read, that's why I ensure to produce really thin commit to allow a good review

@armanddidierjean
armanddidierjean force-pushed the raidV2-improvments branch 2 times, most recently from 72f76e7 to ef26b01 Compare August 25, 2026 08:24
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.

4 participants