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

[PM-14406] Security Task Notifications #5344

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

nick-livefront
Copy link
Contributor

@nick-livefront nick-livefront commented Jan 29, 2025

🎟️ Tracking

PM-14406
Client side PR: bitwarden/clients#13135
Stacked on top of: #5188

πŸ“” Objective

Adds notifications for newly created security tasks for all users within an organization that have manage permissions for the applicable ciphers.

  • I tried to follow/pick up naming patterns, if I missed any please point them out πŸ˜„
  • Adds an email template & a new security task layout.
    • A new layout might not be necessary and could be done later if we wish. I'd be happy to pull this into a single template. I figured that this could be the first of many emails sent out regarding security tasks.
    • The template currently links to a page that hasn't been built yet. That will be handled by PM-17564.
  • Adds stored queries for finding all users that have Manage permissions for the ciphers that are associated with the security tasks.
    • The query returns the UserId, their Email and the applicable cipher id for the security task.
  • Add push notification that is sent to the client side for handling
    • Client side PR. This only processes the notification, there is no handling as of yet. This is only to avoid any errors.
    • There is work slated to handle that in PM-10610

Edit: @shane-melton pointed me to some work that the KM team is doing and I have refactored to use their CreateNotificationCommand rather than the one that I put together.

πŸ“Έ Screenshots

Steps in video

  1. Bulk create endpoint is hit (work done in [PM-14381] Add POST /tasks/bulk-create endpointΒ #5188)
  2. Email notifications received
  3. Push notifications received No longer applicable
security-task-notification.mov

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 4.85437% with 196 lines in your changes missing coverage. Please review.

Project coverage is 44.40%. Comparing base (f4c37df) to head (2b9bc05).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ories/Queries/UserSecurityTasksByCipherIdsQuery.cs 0.00% 54 Missing ⚠️
...ult/Commands/CreateManyTaskNotificationsCommand.cs 0.00% 42 Missing ⚠️
...tyFramework/Vault/Repositories/CipherRepository.cs 0.00% 35 Missing ⚠️
...ture.Dapper/Vault/Repositories/CipherRepository.cs 0.00% 16 Missing ⚠️
.../Services/Implementations/HandlebarsMailService.cs 21.05% 15 Missing ⚠️
...ueries/GetSecurityTasksNotificationDetailsQuery.cs 0.00% 13 Missing ⚠️
...rc/Api/Vault/Controllers/SecurityTaskController.cs 0.00% 4 Missing ⚠️
...e/Models/Mail/SecurityTaskNotificationViewModel.cs 0.00% 4 Missing ⚠️
...c/Core/Vault/Models/Data/UserSecurityTaskCipher.cs 0.00% 4 Missing ⚠️
...re/Services/NoopImplementations/NoopMailService.cs 0.00% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5344      +/-   ##
==========================================
- Coverage   44.56%   44.40%   -0.17%     
==========================================
  Files        1505     1514       +9     
  Lines       69896    70202     +306     
  Branches     6285     6310      +25     
==========================================
+ Hits        31150    31170      +20     
- Misses      37414    37699     +285     
- Partials     1332     1333       +1     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@nick-livefront nick-livefront marked this pull request as draft January 29, 2025 20:25
@nick-livefront
Copy link
Contributor Author

Moving to a draft while I hash out some of the overlap push notifications work.

Copy link
Contributor

github-actions bot commented Jan 29, 2025

Logo
Checkmarx One – Scan Summary & Details – a5cd75c3-90ec-436c-8d0a-c2ed5bf8c641

New Issues (2)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/Billing/Controllers/AccountsBillingController.cs: 83
detailsMethod PreviewInvoiceAsync at line 83 of /src/Api/Billing/Controllers/AccountsBillingController.cs gets a parameter from a user request from Previe...
Attack Vector
LOW Unsafe_Use_Of_Target_blank /src/Core/MailTemplates/Handlebars/SecurityTasksNotification.html.hbs: 21
detailsUsing <a href="{{ReviewPasswordsUrl}}" clicktracking=off target="_blank" style="display: inline-block; color: #ffffff; text-decoration: non...
Attack Vector

@nick-livefront nick-livefront marked this pull request as ready for review January 30, 2025 21:10
Base automatically changed from vault/PM-14381 to main February 5, 2025 21:56
@nick-livefront nick-livefront force-pushed the vault/pm-14406/security-task-notifications branch from b43b131 to 7c18edf Compare February 10, 2025 21:23
…ore the security task id on the notification entry
Copy link
Member

@shane-melton shane-melton left a comment

Choose a reason for hiding this comment

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

This is looking really good, nice work! I just have a few suggestions and an change we'll need to make to the CreateNotificationCommand.

src/Api/Vault/Controllers/SecurityTaskController.cs Outdated Show resolved Hide resolved
src/Core/Vault/Models/Data/UserSecurityTaskCipher.cs Outdated Show resolved Hide resolved
src/Api/Vault/Controllers/SecurityTaskController.cs Outdated Show resolved Hide resolved
src/Api/Vault/Controllers/SecurityTaskController.cs Outdated Show resolved Hide resolved
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.

3 participants