Prune login_activities older than 13 months (stored IPs and typed emails are kept forever)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu từ app/models/metrics_report.rb (active_users_by_type, ALLOWED_RANGES) để xác nhận khoảng thời gian 12 tháng, sau đó xem lib/tasks/expire_case_contact_drafts.rake để nắm kiểu viết tác vụ rake. Thêm app/services/prune_login_activities_service.rb dùng in_batches.delete_all trên LoginActivity, với khoảng thời gian có thể cấu hình tối thiểu 13 tháng. Hoàn thành khi các spec trong spec/models/metrics_report_spec.rb và spec mới của service đều pass, và tác vụ rake in ra số bản ghi đã xóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
login_activities (written by the authtrail gem on every Devise sign-in attempt) is never pruned. It's the second-largest table in production (~8 MB, behind only case_contacts), and every row holds personal data:
identity: the email that was typed, including failed attempts, which can be mistyped emails or other people's addressesip,user_agent,referreruser_id,success,failure_reason,created_at
(Geocoding is off in config/initializers/authtrail.rb, so city/region/country/latitude/longitude are empty.)
Keeping this forever adds privacy risk without benefit. The only reader in the app is the all-CASA-admin Metrics page: "Monthly active users", MetricsReport#active_users_by_type in app/models/metrics_report.rb. Its widest range is 12 months (ALLOWED_RANGES = [3, 6, 12]).
Related: #7263 (PII in logs and Bugsnag).
Proposal
Keep 13 months of login activity (the 12-month metrics window plus the partial current month) and delete older rows daily.
- A service, e.g.
app/services/prune_login_activities_service.rb, that deletesLoginActivity.where(created_at: ...13.months.ago)within_batches.delete_allso a large first run doesn't hold one long transaction. It returns the count deleted. Make the window configurable (LOGIN_ACTIVITY_RETENTION_MONTHS, default 13, minimum 13) so it can never cut into the metrics window. - A rake task
rake prune_login_activitiesthat calls it and prints the count. Follow the style oflib/tasks/expire_case_contact_drafts.rake. - Specs:
- deletes rows older than the window
- keeps rows inside it
- refuses a window under 13 months
- the Metrics page's 12-month monthly-active-users numbers are unchanged after pruning (
spec/models/metrics_report_spec.rb)
- Note in the PR description that a maintainer must add the task to Heroku Scheduler (daily).
Out of scope
Changing what authtrail records, e.g. not storing identity for failed attempts. That's worth a separate discussion under #7263.
Difficulty: beginner. One service, one rake task, specs.
- Ngôn ngữ chính
- Ruby
- Star
- 384
- Fork
- 558
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 63
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rubyforgood/casa
-
⛓️ Security Difficulty: Easy Good First Issue Help Wanted ruby Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rubyforgood/casa#7404 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Difficulty: Easy Good First Issue Help Wanted ruby Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
rubyforgood/casa#7402 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Remove the bin/bundle binstub (Heroku warns it can break Bundler on deploy)Có thể đã có người làm @Akash-Dhanwate đã nhận 8 ngày trước. Đang mởdependencies Difficulty: Easy Good First Issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
rubyforgood/casa#7325 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Reports page: move export-button disable/re-enable into a Stimulus controllerCó thể làm lại được @Akash-Dhanwate đã nhận 9 ngày trước và không có pull request nào đang mở. Đang mởDifficulty: Easy Good First Issue Help Wanted javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rubyforgood/casa#7311 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
New case: use Stimulus for the "I don't know the court date yet" toggleCó thể làm lại được @Aryankn29 đã nhận 9 ngày trước và không có pull request nào đang mở. Đang mởDifficulty: Easy Good First Issue Help Wanted javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rubyforgood/casa#7310 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rubyforgood/casa
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
internetee/registry#2984 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configuredCó thể đã có người làm @mimosa đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
riscv/riscv-unified-db#2829 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
docker-library/ruby#534 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100