🔒(fullstack) harden download flow and address review findings#11
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR replaces ChangesBackend/Frontend Functional Changes
Security Header Hardening
Metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
@coderabbitai review |
✅ Action performedReview finished.
|
423adb2 to
b108f0f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/backend/core/models.py`:
- Around line 87-90: The code silently handles the MultipleObjectsReturned
exception without logging the issue. Add a WARNING level log statement in the
except block that catches self.model.MultipleObjectsReturned to record that
duplicate email entries were found and a stable one was selected. Ensure the
logger is defined at module level using logging.getLogger(__name__) if not
already present, and include the email value in the log message to help admins
identify and investigate the data-quality issue.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7a15fb6f-2316-4308-aa89-2026104bb3b9
📒 Files selected for processing (13)
src/backend/core/api/serializers.pysrc/backend/core/api/viewsets/download.pysrc/backend/core/migrations/0004_alter_user_sub.pysrc/backend/core/models.pysrc/backend/core/services/s3.pysrc/backend/core/tasks.pysrc/backend/core/tests/test_api_downloads.pysrc/backend/core/tests/test_s3_content_disposition.pysrc/backend/pyproject.tomlsrc/backend/transferts/settings.pysrc/frontend/caddy/Caddyfilesrc/frontend/src/features/api/types.tssrc/frontend/src/routes/t/$token.tsx
e7c2c0e to
804cbcc
Compare
- drop owner identity email (PII) from the public download payload; compute is_owner server-side - keep transfers PENDING_FILE_DELETION when an S3 purge partially fails instead of orphaning bytes - record the expiry audit event only when the expiry sweep wins the deactivation race - escape download filenames via RFC 6266 Content-Disposition to prevent filename spoofing - add a strict CSP and security headers (HSTS, Referrer-Policy, X-Frame-Options, nosniff) in Caddy - match users by email case-insensitively to avoid duplicate accounts - raise HSTS max-age from 60s to 1 year - point pyproject repository URL to suitenumerique/st-transfers - fix sub validator regex range bug that admitted ',' and '/' - document first-download auto-archive as "first access" semantics (backend) log when duplicate email is found
804cbcc to
c5bcdff
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/backend/core/models.py`:
- Around line 94-98: The logger.warning call is exposing a raw email address
(PII) in the log message, which violates coding guidelines. Replace the email
parameter being logged with the user IDs of the duplicate accounts instead. This
allows admins to still identify and reconcile the duplicate accounts while
keeping sensitive email data out of the logs. Modify the warning message and its
formatting argument to reference user IDs rather than the email variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4072cf8d-ddb3-44ef-9919-2ba5c30521f8
📒 Files selected for processing (2)
src/backend/core/models.pysrc/backend/pyproject.toml
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/backend/core/migrations/0004_alter_user_sub.py`:
- Line 17: The help_text and the RegexValidator message in the field definition
both claim that forward slash `/` is an allowed character, but the regex pattern
`^[\w.@+\-:]+\Z` does not actually permit forward slashes. Update both the
help_text and the message parameter in the RegexValidator to remove the forward
slash `/` from the character list so they accurately describe only the
characters that the regex actually allows: letters, numbers, and @, ., +, -, _,
and : characters.
In `@src/backend/core/tests/test_api_downloads.py`:
- Around line 38-47: The test_is_owner_true_for_authenticated_owner method
validates that is_owner is True for authenticated owners but does not enforce
the privacy contract for the response. Add an assertion after the is_owner check
to verify that owner_email is not present in the response data (check that it is
either absent from response.data or explicitly None) to ensure no email
information leaks to the client, consistent with the privacy guarantees stated
in the test comment.
In `@src/backend/core/tests/test_models.py`:
- Around line 64-65: The test assertion on line 73 depends on ordering by the
created_at field, but the UserFactory calls for the older and newer variables do
not explicitly set created_at timestamps, causing the test to be flaky across
different database backends with varying timestamp resolutions. Add explicit
created_at parameters to both the UserFactory call for older and the UserFactory
call for newer, ensuring the older variable has an earlier timestamp than the
newer variable (for example, using datetime values where older precedes newer).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8287de16-a82f-4000-922d-44e78c0c31fe
📒 Files selected for processing (14)
src/backend/core/api/serializers.pysrc/backend/core/api/viewsets/download.pysrc/backend/core/migrations/0004_alter_user_sub.pysrc/backend/core/models.pysrc/backend/core/services/s3.pysrc/backend/core/tasks.pysrc/backend/core/tests/test_api_downloads.pysrc/backend/core/tests/test_models.pysrc/backend/core/tests/test_s3_content_disposition.pysrc/backend/pyproject.tomlsrc/backend/transferts/settings.pysrc/frontend/caddy/Caddyfilesrc/frontend/src/features/api/types.tssrc/frontend/src/routes/t/$token.tsx
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary by CodeRabbit
Bug Fixes
Security & Privacy
is_ownerboolean.Improvements