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

Linux disk encryption: frontend changes, backend error on update DE setting with missing private key #23714

Open
wants to merge 20 commits into
base: 22074-linux-encryption
Choose a base branch
from

Conversation

jacobshandling
Copy link
Contributor

@jacobshandling jacobshandling commented Nov 12, 2024

Addresses #22702, #23713, #23756, and #23747

-Note that much of this code as is will render as expected only once integrated with the backend or if manipulated manually for testing purposes

Frontend:

  • Update banners on my device page, tests
  • Build new logic for calling endpoint to trigger linux key escrow on clicking Create key
  • Add CreateLinuxKeyModal to inform user of next steps after clicking Create key
  • Update banners on host details page, tests
  • Update the Controls > OS settings section with new logic related to linux disk encryption
  • Expect and include counts of Linux hosts in aggregate disk encryption stats UI
  • Add "Linux" column to the disk encryption table
  • Show disk encryption related UI for supported Linux platforms
    • TODO: confirm platform string matching functionality in manual e2e testing
  • Expand capabilities of SectionHeader component, apply to new UI
  • Flash "missing private key" error, with clickable link, when trying to update disk encryption enabled while no server private key is present.
    • TODO: QA this once other endpoints on Controls > Disk encryption are enabled even when MDM not turned on

-Other TODO:

  • Update Disk encryption key modal copy - awaiting product guidance on changes being for linux only or for all platforms
  • Confirm when integrated with API:
    • Aggregate disk encryption counts
    • Disk encryption table Linux column
    • Show disk encryption key action on host details page when expected
    • Opens Disk encryption key modal, displays key as expected

Backend:

  • For "No team" and teams, error when trying to update disk encryption enabled while no server private key is present.

  • Changes file added for user-visible changes in changes/

  • Added/updated tests

  • Manual QA for all new/changed functionality

    • Full e2e testing to do when integrated with backend

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 57.69231% with 22 lines in your changes missing coverage. Please review.

Project coverage is 63.13%. Comparing base (59c85b6) to head (acc6e2d).
Report is 1 commits behind head on 22074-linux-encryption.

Files with missing lines Patch % Lines
...es/hosts/details/DeviceUserPage/DeviceUserPage.tsx 26.66% 11 Missing ⚠️
...erPage/CreateLinuxKeyModal/CreateLinuxKeyModal.tsx 33.33% 4 Missing ⚠️
frontend/services/entities/mdm.ts 0.00% 4 Missing ⚠️
frontend/utilities/endpoints.ts 0.00% 2 Missing ⚠️
...components/DeviceUserBanners/DeviceUserBanners.tsx 91.66% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           22074-linux-encryption   #23714      +/-   ##
==========================================================
- Coverage                   63.14%   63.13%   -0.01%     
==========================================================
  Files                        1557     1558       +1     
  Lines                      147617   147653      +36     
  Branches                     3687     3742      +55     
==========================================================
+ Hits                        93212    93227      +15     
- Misses                      47033    47053      +20     
- Partials                     7372     7373       +1     
Flag Coverage Δ
frontend 52.30% <57.69%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@jacobshandling jacobshandling changed the base branch from main to 22074-linux-encryption November 12, 2024 19:09
- Allows rendering of Disk Encryption section even when MDM is not enabled
@jacobshandling jacobshandling changed the title UI – Linux disk encryption Linux disk encryption: frontend changes, backend error on update DE setting with missing private key Nov 13, 2024
@jacobshandling jacobshandling requested a review from a team as a code owner November 13, 2024 01:24
@@ -1523,6 +1523,9 @@ func unmarshalWithGlobalDefaults(b *json.RawMessage) (fleet.Features, error) {
func (svc *Service) updateTeamMDMDiskEncryption(ctx context.Context, tm *fleet.Team, enable *bool) error {
var didUpdate, didUpdateMacOSDiskEncryption bool
if enable != nil {
if len(svc.config.Server.PrivateKey) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

more idiomatic to use == "" for string evaluation

Copy link
Contributor Author

@jacobshandling jacobshandling Nov 13, 2024

Choose a reason for hiding this comment

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

I had the same thought, but this follows a pattern set by folks on MDM team, see here, here, and here. Think it's worth changing all of those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After consulting with MDM, let's use == "" going forward, and update existing len-based checks as we come to them, no need to update now.

Copy link
Member

@iansltx iansltx left a comment

Choose a reason for hiding this comment

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

Looked through this PR to get my bearings about this feature. Some of the questions have probably been answered elsewhere; thanks in advance for answering these for the Nth time.

setup.
</li>
<li>
Close this window and select <b>Refetch</b> on your <b>My device</b>{" "}
Copy link
Member

Choose a reason for hiding this comment

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

@mostlikelee Can we force a refetch on Orbit when the passphrase is entered?

@@ -353,14 +374,15 @@ const DeviceUserPage = ({
mdmEnabledAndConfigured={
!!globalConfig?.mdm.enabled_and_configured
}
mdmConnectedToFleet={!!host.mdm.connected_to_fleet}
diskEncryptionStatus={
connectedToFleetMdm={!!host.mdm.connected_to_fleet}
Copy link
Member

Choose a reason for hiding this comment

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

Need to verify that this doesn't show up for Linux hosts as there isn't a concept of Linux MDM the same way there is for Mac/Win.

Copy link
Member

Choose a reason for hiding this comment

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

This should be testable now with a Linux host as nothing we're doing on the backend changes the fact that there's no Linux MDM.

Copy link
Contributor Author

@jacobshandling jacobshandling Nov 13, 2024

Choose a reason for hiding this comment

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

This prop is only used in conjunction with (a) macDiskEncryptionStatus === "action_required" to determine whether to (b) showMacDiskEncryptionKeyResetRequired – since (a) should only be possible for darwin hosts, there shouldn't be any issue here.

Here's a clarifying rename that should make those relationships more clear.

Does that make sense or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will, as noted, test all of this today

},
});
}
return sendRequest("PATCH", teamsEndpoint, {
return sendRequest("POST", teamsEndpoint, {
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating this call from using a deprecated endpoint to using the latest – see here

Copy link
Member

Choose a reason for hiding this comment

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

Actually looks like we can unify logic for which endpoint to hit here, as the new endpoint supports a nil team ID for editing no-team config, vs. needing to split between a team-specific endpoint and a no-team-specific endpoint. Does that match what you're seeing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, nice!

// TODO: API INTEGRATION: remove macos_settings when API change is merged in.
macos_settings: { enable_disk_encryption: enableDiskEncryption },
// enable_disk_encryption: enableDiskEncryption,
enable_disk_encryption: enableDiskEncryption,
Copy link
Member

Choose a reason for hiding this comment

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

Is this supported on the backend, or does this tweak need to be built so we don't lose support for macOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Above should answer this question as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(yes, it's supported 🙂)

@@ -706,8 +706,8 @@ func attachFleetAPIRoutes(r *mux.Router, svc fleet.Service, config config.FleetC

// Deprecated: GET /mdm/profiles/summary is now deprecated, replaced by the
// GET /configuration_profiles/summary endpoint.
mdmAnyMW.GET("/api/_version_/fleet/mdm/profiles/summary", getMDMProfilesSummaryEndpoint, getMDMProfilesSummaryRequest{})
mdmAnyMW.GET("/api/_version_/fleet/configuration_profiles/summary", getMDMProfilesSummaryEndpoint, getMDMProfilesSummaryRequest{})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TIL 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants