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

[EDR Workflows] Add Signer option to Mac trusted apps #197821

Merged
merged 23 commits into from
Nov 18, 2024

Conversation

szwarckonrad
Copy link
Contributor

@szwarckonrad szwarckonrad commented Oct 25, 2024

This PR adds a Signer condition for trusted apps on macOS. Previously, users could only build conditions using hash, path, and signer options on Windows. With these changes, macOS also supports the Signer option, leaving only Linux limited to Path and Hash options.

Screen.Recording.2024-10-28.at.10.16.05.mov

@szwarckonrad szwarckonrad added v9.0.0 Team:Defend Workflows “EDR Workflows” sub-team of Security Solution release_note:feature Makes this part of the condensed release notes backport:version Backport to applied version labels v8.17.0 labels Oct 25, 2024
@szwarckonrad szwarckonrad self-assigned this Oct 25, 2024
@szwarckonrad szwarckonrad added the ci:cloud-deploy Create or update a Cloud deployment label Oct 28, 2024
@szwarckonrad szwarckonrad marked this pull request as ready for review October 28, 2024 09:18
@szwarckonrad szwarckonrad requested a review from a team as a code owner October 28, 2024 09:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

Did also you verify that the signer entries made for mac os are correctly generated in the endpoint artifact?

@szwarckonrad
Copy link
Contributor Author

szwarckonrad commented Oct 28, 2024

Did also you verify that the signer entries made for mac os are correctly generated in the endpoint artifact?

@ashokaditya
I did observe the artifact id change. Could you help me out with a way to validate it further?

We do plan on testing it E2E with an agent installed on MacOS though ;)

@szwarckonrad szwarckonrad added the ci:cloud-redeploy Always create a new Cloud deployment label Oct 28, 2024
Copy link
Contributor

@gergoabraham gergoabraham left a comment

Choose a reason for hiding this comment

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

looks and works great! 🚀 (not e2e, just UI test and looked at SOs)
there's only some nitpicking

Copy link
Contributor

@gergoabraham gergoabraham 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 the changes! 🚀

@ashokaditya
Copy link
Member

Did also you verify that the signer entries made for mac os are correctly generated in the endpoint artifact?

@ashokaditya I did observe the artifact id change. Could you help me out with a way to validate it further?

We do plan on testing it E2E with an agent installed on MacOS though ;)

You can use the artifact downloader to test that the entries are correctly generated.

@szwarckonrad szwarckonrad requested a review from a team as a code owner November 4, 2024 12:27
Copy link
Contributor

@gergoabraham gergoabraham 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 the changes, @szwarckonrad!

there's a small hiccup with the form when changing OS when windows/macOS and Signature is selected:

  • if you switch to Linux, the field defaults back to Hash,
  • but if you switch between win/mac, the field simply goes blank

also, when you try to save it, it shows that API input validation works perfect! 😄 🚀

Screen.Recording.2024-11-05.at.11.27.39.mov

Comment on lines 407 to 420
| (T & {
effectScope: { type: string };
entries: TrustedAppConditionEntry[];
os: OperatingSystem.WINDOWS;
name: string;
description: string;
})
| {
effectScope: { type: string };
entries: TrustedAppConditionEntry[];
os: OperatingSystem.WINDOWS;
name: string;
description: string;
} => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

i've been thinking about this change. i can't put my finger on it why there is a type error without this change, but it feels broken. i mean - we cannot assign an array of TrustedAppConditionEntry type to NewTrustedApp['entries']? it just doesn't seem right

i'll think about this a bit more. do you have any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like the problem roots around using enums as generics, where we want to create a type where only a partial set of the enum elements are should be used

when we create TrustedAppConditionEntry, we want its field: T to possibly have the values ot the ConditionEntryField enum, but in cases, only a subset of those (e.g. Linux only has path and hash)

export interface TrustedAppConditionEntry<T extends ConditionEntryField = ConditionEntryField>

but, in the test, we fall back to the default generic type, ConditionEntryField, that has all enum elements

so far it has worked, because accidentally one of the derived types contained all elements of the enum:

export type WindowsConditionEntry = TrustedAppConditionEntry<
  ConditionEntryField.HASH | ConditionEntryField.PATH | ConditionEntryField.SIGNER
>;

which ensured that there is a possibility, using the default of the generic (i.e. ConditionEntryField), to meet this criteria

but, with your modification, now neither of the derived types contains all of the enum elements, hence the error message. and i have no idea how to fix it either in the generic rule, or defining the generics type in the test file

still, looks like there's a nice quick fix to avoid the type mess: type assertion! i'll add it in a new comment


btw, i was worried about this issue, bc type system is one of our guard on code quality, and although automated and manual tests showed that everything works fine, still didn't want to throw out the typing

Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't add it in a suggestion, bc the lines are out of your modifications, so here it is simply:

    const createNewTrustedApp = <T>(data?: T): NewTrustedApp =>
      ({
        name: 'Some Anti-Virus App',
        description: 'this one is ok',
        os: OperatingSystem.WINDOWS,
        effectScope: { type: 'global' },
        entries: [createConditionEntry()],
        ...(data || {}),
      } as NewTrustedApp);

simply asserting the created object as NewTrustedApp solves the type error, while ensures that the created object aligns with the expectations in both places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes total sense! Thanks for looking into this, I appreciate it! 9d39376

Copy link
Contributor

@vitaliidm vitaliidm left a comment

Choose a reason for hiding this comment

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

Detection Engine LGTM

There are changes not directly used in our part of app, but triggered review request, due to entire utils folder belonging to the team.
Which we'll revise on team sync, what could be the best approach here

packages/kbn-securitysolution-utils @elastic/security-detection-engine

Copy link
Contributor

@gergoabraham gergoabraham 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 the fixes, i confirm that switching between windows and mac works perfect now! 👍

i'll be happy if you fix the type issue, but independently from that, nice work! 🚀

#197821 (comment)

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 18, 2024

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 13.4MB 13.4MB +865.0B
Unknown metric groups

References to deprecated APIs

id before after diff
securitySolution 448 438 -10

History

cc @szwarckonrad

@szwarckonrad szwarckonrad merged commit 55134ab into elastic:main Nov 18, 2024
45 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11893336148

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 18, 2024
This PR adds a Signer condition for trusted apps on macOS. Previously,
users could only build conditions using hash, path, and signer options
on Windows. With these changes, macOS also supports the Signer option,
leaving only Linux limited to Path and Hash options.

https://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b
(cherry picked from commit 55134ab)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 18, 2024
…#200566)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[EDR Workflows] Add Signer option to Mac trusted apps
(#197821)](#197821)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Konrad
Szwarc","email":"konrad.szwarc@elastic.co"},"sourceCommit":{"committedDate":"2024-11-18T13:20:54Z","message":"[EDR
Workflows] Add Signer option to Mac trusted apps (#197821)\n\nThis PR
adds a Signer condition for trusted apps on macOS. Previously,\r\nusers
could only build conditions using hash, path, and signer options\r\non
Windows. With these changes, macOS also supports the Signer
option,\r\nleaving only Linux limited to Path and Hash
options.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b","sha":"55134abbedaf64dba41455b8f8fb6f97f162a0d6","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","Team:Defend
Workflows","release_note:feature","ci:cloud-deploy","ci:cloud-redeploy","backport:version","v8.17.0"],"title":"[EDR
Workflows] Add Signer option to Mac trusted
apps","number":197821,"url":"https://github.com/elastic/kibana/pull/197821","mergeCommit":{"message":"[EDR
Workflows] Add Signer option to Mac trusted apps (#197821)\n\nThis PR
adds a Signer condition for trusted apps on macOS. Previously,\r\nusers
could only build conditions using hash, path, and signer options\r\non
Windows. With these changes, macOS also supports the Signer
option,\r\nleaving only Linux limited to Path and Hash
options.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b","sha":"55134abbedaf64dba41455b8f8fb6f97f162a0d6"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197821","number":197821,"mergeCommit":{"message":"[EDR
Workflows] Add Signer option to Mac trusted apps (#197821)\n\nThis PR
adds a Signer condition for trusted apps on macOS. Previously,\r\nusers
could only build conditions using hash, path, and signer options\r\non
Windows. With these changes, macOS also supports the Signer
option,\r\nleaving only Linux limited to Path and Hash
options.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b","sha":"55134abbedaf64dba41455b8f8fb6f97f162a0d6"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Konrad Szwarc <konrad.szwarc@elastic.co>
jesuswr pushed a commit to jesuswr/kibana that referenced this pull request Nov 18, 2024
This PR adds a Signer condition for trusted apps on macOS. Previously,
users could only build conditions using hash, path, and signer options
on Windows. With these changes, macOS also supports the Signer option,
leaving only Linux limited to Path and Hash options.


https://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
This PR adds a Signer condition for trusted apps on macOS. Previously,
users could only build conditions using hash, path, and signer options
on Windows. With these changes, macOS also supports the Signer option,
leaving only Linux limited to Path and Hash options.


https://github.com/user-attachments/assets/ea8fb734-7884-451d-8873-e3a29861876b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:cloud-deploy Create or update a Cloud deployment ci:cloud-redeploy Always create a new Cloud deployment release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants