Skip to content

[PM-29129] Add Policy Update Event README#7159

Open
JimmyVo16 wants to merge 15 commits intomainfrom
ac/pm-29129/add-policy-update-event-readme
Open

[PM-29129] Add Policy Update Event README#7159
JimmyVo16 wants to merge 15 commits intomainfrom
ac/pm-29129/add-policy-update-event-readme

Conversation

@JimmyVo16
Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-29129

📔 Objective

  1. Add README so devs and AI can easily implement new handlers to hook into Policy Update Events.

📸 Screenshots

No code changes, just a markdown file.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

Logo
Checkmarx One – Scan Summary & Detailsad26a942-c097-4bd4-85f2-3cd705f6ac88


New Issues (3) Checkmarx found the following issues in this Pull Request
# Severity Issue Source File / Package Checkmarx Insight
1 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 217
detailsMethod at line 217 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
2 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 291
detailsMethod at line 291 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
3 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 452
detailsMethod at line 452 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector

Fixed Issues (4) Great job! The following issues were fixed in this Pull Request
Severity Issue Source File / Package
MEDIUM CSRF /src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs: 146
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 531
MEDIUM CSRF /src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs: 105
MEDIUM Use_Of_Hardcoded_Password /src/Core/Constants.cs: 171

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.88%. Comparing base (3cf94a9) to head (5d18fa7).
⚠️ Report is 84 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7159   +/-   ##
=======================================
  Coverage   56.88%   56.88%           
=======================================
  Files        2028     2028           
  Lines       88830    88830           
  Branches     7918     7918           
=======================================
+ Hits        50532    50533    +1     
+ Misses      36468    36467    -1     
  Partials     1830     1830           

☔ View full report in Codecov by Sentry.
📢 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.

@JimmyVo16 JimmyVo16 self-assigned this Mar 6, 2026
@JimmyVo16 JimmyVo16 marked this pull request as ready for review March 6, 2026 16:42
@JimmyVo16 JimmyVo16 requested a review from a team as a code owner March 6, 2026 16:42
@JimmyVo16 JimmyVo16 requested a review from eliykat March 6, 2026 16:42
Copy link
Copy Markdown
Member

@eliykat eliykat left a comment

Choose a reason for hiding this comment

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

Thanks for coming back to this!

Comment thread src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyUpdateEvents/README.md Outdated
Comment thread src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyUpdateEvents/README.md Outdated
Comment on lines +29 to +34
## Limitations

1. We don't have a way to keep this whole process idempotent, so if there is an exception at any point that is not being handled, the state will stay where the process failed.



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.

Section appears to be unfinished? Also, this is a good callout, but I think it's more about it not being atomic than idempotent. A failure does not roll back any changes already made.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Also, this is completed. This is the only issue I'm aware of. I'm happy to add more if you know of anything else. I used a bullet list so we can easily add new ones.

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 think it should only be a list if there is more than 1 item. For now it should just be a single paragraph.

Comment thread src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyUpdateEvents/README.md Outdated
Comment thread src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyUpdateEvents/README.md Outdated
Comment thread src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyUpdateEvents/README.md Outdated
JimmyVo16 and others added 6 commits March 9, 2026 10:15
…teEvents/README.md

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
…teEvents/README.md

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
…teEvents/README.md

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
…teEvents/README.md

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
@JimmyVo16 JimmyVo16 requested a review from eliykat March 9, 2026 15:24
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 9, 2026

When an organization policy is created or updated, the save workflow runs a series of ordered steps. A policy handler can hook into any step by implementing the corresponding Policy Update Event interface.

Note: If you don’t want to hook into these events, you don’t need to create a handler, and your policy will simply upsert to the database with log events.
Note: If you do not need to hook into any step, you do not need to create a policy handler. The policy will simply upsert to the database with an audit log event.
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.

Non-blocking: I misspoke before. Contractions (e.g. "don't") are OK, abbreviations (e.g. "org" instead of "organization") should be minimized.


Typical uses: creating collections, sending notifications that depend on the new policy state.

Note: This is more useful for enabling a policy than for disabling a policy, since when the policy is disabled, there is no easy way to find the users the policy should be enforced on.
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.

OK good point, I see now. Maybe something like this?

Note: This is more useful for enabling a policy than for disabling a policy, since when the policy is disabled, it does not have any effect.

Comment on lines +29 to +34
## Limitations

1. We don't have a way to keep this whole process idempotent, so if there is an exception at any point that is not being handled, the state will stay where the process failed.



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 think it should only be a list if there is more than 1 item. For now it should just be a single paragraph.


### `IOnPolicyPreUpdateEvent`

Executes side effects **before** the policy is upserted to the database.
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.

It's the expected behaviour for normal imperative code flow, but here we've built a little system to handle this process, so it's not necessarily obvious how we've designed the error handling. This is alerting the dev to the fact that we will not handle their errors for them, so if they want the update to continue they would have to do that themselves. Or alternatively, it gives them a way of aborting the operation.

@eliykat
Copy link
Copy Markdown
Member

eliykat commented Mar 20, 2026

My comments above are mostly replying to threads inline, you may have to scroll up for proper context.

@eliykat eliykat added ai-review-vnext Request a Claude code review using the vNext workflow and removed ai-review-vnext Request a Claude code review using the vNext workflow labels Mar 20, 2026
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.

2 participants