Skip to content

feat: non-root self hosted images for standard deployment #5701

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

Merged
merged 39 commits into from
May 30, 2025

Conversation

tangowithfoxtrot
Copy link
Contributor

@tangowithfoxtrot tangowithfoxtrot commented Apr 23, 2025

🎟️ Tracking

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

Update our self-hosted standard deployment images (this work excludes Unified) to allow running in non-root contexts, such as kubernetes deployments using runAsNonRoot or specifying user: ${PUID}:${PGID} in a container compose override file.

Note that this work excludes the MSSQL and Nginx images, so a fully non-rootful deployment will require hosting those services separately. Also note that the images are intended to run as non-root users on an opt-in basis. They are not rootless by default, as we want to avoid making breaking changes to existing rootful deployments for the time being.

📔 Objective

📸 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

tangowithfoxtrot and others added 4 commits April 23, 2025 11:25
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Apr 23, 2025

Logo
Checkmarx One – Scan Summary & Details492f2df2-814f-4cea-a6d4-a03aa0b750e0

New Issues (1)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
CRITICAL Stored_XSS /util/Server/Startup.cs: 57
detailsThe method Lambda embeds untrusted data in generated output with WriteAsync, at line 59 of /util/Server/Startup.cs. This untrusted data is embedd...
ID: eVLjqrGrhR8bX6vH49rf3sR1lsU%3D
Attack Vector

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 47.51%. Comparing base (31b6b47) to head (c3f4a96).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
src/Core/Utilities/CoreHelpers.cs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5701   +/-   ##
=======================================
  Coverage   47.51%   47.51%           
=======================================
  Files        1662     1662           
  Lines       75215    75216    +1     
  Branches     6761     6761           
=======================================
+ Hits        35737    35738    +1     
  Misses      38015    38015           
  Partials     1463     1463           

☔ 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.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Checkmarx One found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@justindbaur justindbaur force-pushed the feat/pm-14496-non-root-self-hosted-images branch from e47a1bb to 2e156c2 Compare May 1, 2025 12:57
@justindbaur justindbaur force-pushed the feat/pm-14496-non-root-self-hosted-images branch from 2e156c2 to 284501a Compare May 1, 2025 12:59
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good to me, though we'll need to make sure this is well tested by QA to ensure everything is working.

I've left some suggestions simplify the Dockerfiles a bit more. We have a lot of them so any extra code that we require gets multiplied by 10.

@trmartin4 trmartin4 requested a review from dani-garcia May 20, 2025 01:23
dani-garcia
dani-garcia previously approved these changes May 20, 2025
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

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

LGTM, we'll need to make sure this is throroughly tested to ensure everything works as expected

@tangowithfoxtrot
Copy link
Contributor Author

There's a merge conflict in the build workflow. I'm reworking things to reduce the changes between the workflow on this branch and main.

@tangowithfoxtrot
Copy link
Contributor Author

Apologies for the re-review requests. I think I've reduced the build workflow changes to bring it more inline with main.

Copy link
Contributor

@Eeebru Eeebru left a comment

Choose a reason for hiding this comment

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

With the branch check step removed, was this image build tested?

Comment on lines +51 to 52
dotnet: true
node: true
Copy link
Contributor

@Eeebru Eeebru May 21, 2025

Choose a reason for hiding this comment

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

This project is built for node in the artifact job and also build for dotnet in the docker image job, removing the artifact job will build this image for both node and dotnet, is that the intended behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I'm misunderstanding your concern, Admin needs node to build the static files and dotnet to build the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just ensuring it's not a mistake

Comment on lines -69 to -70
- project_name: Server
base_path: ./util
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why we are removing this image name in the build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We previously only needed a dedicated bitwarden/server image for attachments. Since we're using multi-stage builds, we no longer require it.

Comment on lines -200 to -205
- name: Check branch to publish
env:
PUBLISH_BRANCHES: "main,rc,hotfix-rc"
id: publish-branch-check
run: |
IFS="," read -a publish_branches <<< $PUBLISH_BRANCHES
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we not checking for branch to publish anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was removed by mistake. Thanks for catching it. Added it back in 88848e6.

@tangowithfoxtrot tangowithfoxtrot requested a review from Eeebru May 22, 2025 16:36
Copy link

@tangowithfoxtrot tangowithfoxtrot merged commit 63f5811 into main May 30, 2025
38 of 39 checks passed
@tangowithfoxtrot tangowithfoxtrot deleted the feat/pm-14496-non-root-self-hosted-images branch May 30, 2025 17:29
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.

4 participants