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

Split LimitCollectionCreationDeletion into two database columns #4709

Conversation

addisonbeck
Copy link
Contributor

@addisonbeck addisonbeck commented Aug 28, 2024

🎟️ Tracking

🧵 Jira Ticket: PM-10863

📚 Stacked PRs

  1. server: Split LimitCollectionCreationDeletion into two database columns #4709
    ⬆️ YOU ARE HERE
  2. server: Split Organization.LimitCollectionCreationDeletion into two separate business rules #4730
  3. clients: Split Organization.LimitCollectionCreationDeletion into two separate business rules clients#11223
  4. server: Turn on LimitCollectionCreationDeletionSplit for self host #4808
  5. server: [PM-14821] [PM-14822] Remove LimitCollectionCreationDeletionSplit feature flag #4809
  6. clients: [PM-14821] Remove LimitCollectionCreationDeletionSplit feature flag clients#11258
  7. server: Drop LimitCollectionCreationDeletion from the database #4810

📔 Objective

🤳 The Bigger Picture

There is an option in the Admin Console that removes collection creation and
deletion controls from all organization members that are not in the Owner and
Admin roles. This PR stack splits this conjoined option into two separate
controls: one to block create operations and one to block delete
operations. This is a part of an effort to make these settings better align
with what customers expect it to do.

👉 This Pull Request 👍

This pull request submits an initial migration & a transition migration for
introducing a dbo.Organization.LimitCollectionCreation column and a
dbo.Organization.LimitCollectionDeletion column that will split
dbo.Organization.LimitCollectionCreationDeletion into two individual data
points.

I've include the data-syncing UPDATE script that copies the existing
column's data over to the new column as a separate script from the initial
migration. This UPDATE script seems like it might fit the criteria of a
"transition" phase migration in EDD. I think it would be fine to run with the
initial migration, but I am unsure if (quoting the contributing docs)

[the script would] be too slow or put too much load on the database, or
otherwise make it unsuitable for the Initial migration

It seems like it wouldn't be too much to me, but let me know!

The same updates have been made to the entity framework database
implementations. The entity fields are synced by a hand written migration,
and are get and set to pull from LimitCollectionCreationDeletion until
the next phase of this work that will fade that field out of use in the
server project.

🧮 Side Effects

  • I deleted a test class that was meant to be ephemeral and was blocking new
    EF migrations from being properly handled by tests.
  • I changed the default value of LimitCollectionCreationDeletion from
    true to false in Entity Framework. This is already the default in
    MSSQL, and I think it was missed in EF.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.81%. Comparing base (7368e57) to head (af50aac).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4709   +/-   ##
=======================================
  Coverage   41.80%   41.81%           
=======================================
  Files        1320     1320           
  Lines       62687    62689    +2     
  Branches     5774     5774           
=======================================
+ Hits        26209    26211    +2     
  Misses      35267    35267           
  Partials     1211     1211           

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

Copy link
Contributor

github-actions bot commented Aug 28, 2024

Logo
Checkmarx One – Scan Summary & Detailsa414d158-691e-4598-b08d-20951f835b63

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Missing_HSTS_Header /src/Admin/Startup.cs: 40 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/TwoFactorController.cs: 488 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/WebAuthnController.cs: 178 Attack Vector
MEDIUM Privacy_Violation /src/Api/Controllers/DevicesController.cs: 132 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 863 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 560 Attack Vector
MEDIUM Privacy_Violation /src/Api/Vault/Controllers/CiphersController.cs: 906 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 845 Attack Vector
MEDIUM Privacy_Violation /src/Api/Auth/Controllers/AccountsController.cs: 412 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 274 Attack Vector
MEDIUM Privacy_Violation /src/Api/Controllers/DevicesController.cs: 158 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 365 Attack Vector
MEDIUM Privacy_Violation /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 418 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 68 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 153 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/WebAuthnController.cs: 85 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 404 Attack Vector
LOW Log_Forging /src/Api/Vault/Controllers/CiphersController.cs: 898 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 855 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 837 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 552 Attack Vector
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 123 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 254 Attack Vector
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 149 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 330 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 393 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 176
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 164
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 455
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 689
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164

@addisonbeck addisonbeck force-pushed the ac/addison/pm-10863/rename-limit-collection-creation-deletion branch 8 times, most recently from f0d5365 to 44278dd Compare August 30, 2024 18:16
@addisonbeck
Copy link
Contributor Author

@r-tome @eliykat @vincentsalucci This isn't ready for merge yet. I want to get a bit further and manually test. That said: if anyone finds time for a review I'd appreciate it. I haven't done a formally processed EDD migration yet, and I do not want to miss anything. Thanks!

Copy link
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.

You need to refresh OrganizationView after adding the column; but this otherwise looks right to me, including EDD considerations.

To confirm, I expect the timeline would be:

  1. Merge this PR
    -- rc cut --
  2. Update the code to use the new column
    -- rc cut --
  3. Drop the old column

@addisonbeck
Copy link
Contributor Author

addisonbeck commented Sep 3, 2024

Thanks! I added a refresh to OrganizationView on 725dbfd.

r-tome
r-tome previously approved these changes Sep 3, 2024
Copy link
Contributor

@r-tome r-tome left a comment

Choose a reason for hiding this comment

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

LGTM!

@addisonbeck addisonbeck force-pushed the ac/addison/pm-10863/rename-limit-collection-creation-deletion branch 4 times, most recently from c79d627 to 0f44cb7 Compare September 6, 2024 23:50
@addisonbeck addisonbeck changed the title Introduce LimitCollectionCreation & deprecate LimitCollectionCreationDeletion Introduce Organization.Settings & deprecate LimitCollectionCreationDeletion Sep 6, 2024
@addisonbeck addisonbeck force-pushed the ac/addison/pm-10863/rename-limit-collection-creation-deletion branch 6 times, most recently from c32c1a2 to 78dcd6d Compare September 7, 2024 01:09
@addisonbeck addisonbeck requested a review from eliykat September 19, 2024 10:05
eliykat
eliykat previously approved these changes Sep 23, 2024
Copy link
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.

This looks good to me! Thanks for taking the time to navigate EDD issues.

@addisonbeck addisonbeck force-pushed the ac/addison/pm-10863/rename-limit-collection-creation-deletion branch from baf2684 to 24be4d2 Compare September 25, 2024 20:28
@addisonbeck
Copy link
Contributor Author

I rebased this on main to update migration script dates and keep everything in sync for branches further down the tree than this one like #4730

No functional changes were made.

@addisonbeck
Copy link
Contributor Author

addisonbeck commented Sep 25, 2024

I'd also like to ignore the failing SonarCloud action run on this PR. It seems mostly upset about tests, but this is entirely database operations.

@withinfocus
Copy link
Contributor

I opened up the Sonar report finding, and there's one thing listed:

https://sonarcloud.io/project/issues?severities=BLOCKER&sinceLeakPeriod=true&issueStatuses=OPEN%2CCONFIRMED&types=BUG&id=bitwarden_server&open=AZH6gLSYkzQSuElBzVms

It suggests a WHERE with your update.

@addisonbeck
Copy link
Contributor Author

addisonbeck commented Sep 25, 2024

Thank you @withinfocus, that's helpful and did give me an idea. I do want to update every record on the table, so a WHERE clause isn't wrong logically. But, it cuts down the amount of records accessed to only check for rows that don't match the default value of the column being updated. That sounds like a good enough reason to add one.

@eliykat this does mark a small functional change since review. When you get to it: please give a review to the very small change on c37f77f.

Copy link
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.

LGTM, also note my recent database changes in #4701 just in case you need to re-do any of your EF migrations. (You may have already done this)

@addisonbeck addisonbeck force-pushed the ac/addison/pm-10863/rename-limit-collection-creation-deletion branch from c37f77f to af50aac Compare September 30, 2024 20:16
@eliykat eliykat requested a review from rkac-bw October 1, 2024 04:18
Copy link
Contributor

@rkac-bw rkac-bw left a comment

Choose a reason for hiding this comment

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

lgtm

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.

5 participants