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

[Threat Hunting Investigations] Migrate all timeline routes to OpenAPI types #190238

Conversation

janmonschke
Copy link
Contributor

@janmonschke janmonschke commented Aug 9, 2024

Summary

fixes: https://github.com/elastic/security-team/issues/10235
fixes: https://github.com/elastic/security-team/issues/10237

This is the final PR for migrating over all timeline-related schemas and types to the new generated zod schemas from our OpenAPI specs. (see https://github.com/elastic/security-team/issues/10110)
On top of moving to the new schemas/types, this PR also cleans up usage of now outdated types.

I'm aware of the size of this PR but rest assured, the changes are easy to review and for most teams, only a handful of files need to be reviewed:

### elastic/security-defend-workflows

* x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_solution_integrations.ts

### elastic/security-detection-rule-management

* x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.ts
* x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts

### elastic/security-detections-response

* x-pack/test/security_solution_cypress/cypress/objects/timeline.ts

### elastic/security-engineering-productivity

* x-pack/test/security_solution_cypress/cypress/objects/timeline.ts
* x-pack/test/security_solution_cypress/cypress/tasks/api_calls/timelines.ts

Checklist

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

Copy link
Contributor

@kqualters-elastic kqualters-elastic left a comment

Choose a reason for hiding this comment

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

lgtm (but mostly ci) 👍

Copy link
Contributor

@tomsonpl tomsonpl left a comment

Choose a reason for hiding this comment

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

Defend Workflows LGTM 🚀

Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@janmonschke Thanks for addressing my previous comments and integrating generated Zod types into the code 🙏

I left some non critical comments. Feel free to reach me if it's necessary to discuss them.

@@ -306,6 +357,11 @@ export const SortFieldTimeline = z.enum(['title', 'description', 'updated', 'cre
export type SortFieldTimelineEnum = typeof SortFieldTimeline.enum;
export const SortFieldTimelineEnum = SortFieldTimeline.enum;

export type SortDirection = z.infer<typeof SortDirection>;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Interesting if we could reuse SortDirection for consistency. I see pros and cons in that. The point if it's not reused it should be namespaced to TimelineSortDirection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point but it would mean rename a bunch more types in this file and then all over security solution. We could think of, in a future PR, to streamline usage of these types. I see occurrences of asc and desc and enums for these, all over security solution, not just in timeline.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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 20.5MB 20.5MB -5.5KB
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 543 539 -4

Total ESLint disabled count

id before after diff
securitySolution 628 624 -4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @janmonschke

Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@janmonschke Thanks for addressing my comments 👍

@janmonschke janmonschke merged commit 0078960 into elastic:main Sep 30, 2024
41 checks passed
janmonschke added a commit to janmonschke/kibana that referenced this pull request Oct 1, 2024
…I types (elastic#190238)

fixes: elastic/security-team#10235
fixes: elastic/security-team#10237

This is the final PR for migrating over all timeline-related schemas and
types to the new generated zod schemas from our OpenAPI specs. (see
elastic/security-team#10110)
On top of moving to the new schemas/types, this PR also cleans up usage
of now outdated types.

I'm aware of the size of this PR but rest assured, the changes are easy
to review and for most teams, only a handful of files need to be
reviewed:

```markdown

* x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_solution_integrations.ts

* x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.ts
* x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts

* x-pack/test/security_solution_cypress/cypress/objects/timeline.ts

* x-pack/test/security_solution_cypress/cypress/objects/timeline.ts
* x-pack/test/security_solution_cypress/cypress/tasks/api_calls/timelines.ts
```

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit 0078960)
@janmonschke
Copy link
Contributor Author

💚 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

janmonschke added a commit that referenced this pull request Oct 1, 2024
…OpenAPI types (#190238) (#194606)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Threat Hunting Investigations] Migrate all timeline routes to
OpenAPI types (#190238)](#190238)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Jan
Monschke","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-30T18:55:23Z","message":"[Threat
Hunting Investigations] Migrate all timeline routes to OpenAPI types
(#190238)\n\n## Summary\r\n\r\nfixes:
https://github.com/elastic/security-team/issues/10235\r\nfixes:
https://github.com/elastic/security-team/issues/10237\r\n\r\nThis is the
final PR for migrating over all timeline-related schemas and\r\ntypes to
the new generated zod schemas from our OpenAPI specs.
(see\r\nhttps://github.com/elastic/security-team/issues/10110)\r\nOn top
of moving to the new schemas/types, this PR also cleans up usage\r\nof
now outdated types.\r\n\r\nI'm aware of the size of this PR but rest
assured, the changes are easy\r\nto review and for most teams, only a
handful of files need to be\r\nreviewed:\r\n\r\n```markdown\r\n###
elastic/security-defend-workflows\r\n\r\n*
x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_solution_integrations.ts\r\n\r\n###
elastic/security-detection-rule-management\r\n\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.ts\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts\r\n\r\n###
elastic/security-detections-response\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n\r\n###
elastic/security-engineering-productivity\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n*
x-pack/test/security_solution_cypress/cypress/tasks/api_calls/timelines.ts\r\n```\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"00789609ad663efffd7b3997ca773fe3ea5511e2","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.0"],"number":190238,"url":"https://github.com/elastic/kibana/pull/190238","mergeCommit":{"message":"[Threat
Hunting Investigations] Migrate all timeline routes to OpenAPI types
(#190238)\n\n## Summary\r\n\r\nfixes:
https://github.com/elastic/security-team/issues/10235\r\nfixes:
https://github.com/elastic/security-team/issues/10237\r\n\r\nThis is the
final PR for migrating over all timeline-related schemas and\r\ntypes to
the new generated zod schemas from our OpenAPI specs.
(see\r\nhttps://github.com/elastic/security-team/issues/10110)\r\nOn top
of moving to the new schemas/types, this PR also cleans up usage\r\nof
now outdated types.\r\n\r\nI'm aware of the size of this PR but rest
assured, the changes are easy\r\nto review and for most teams, only a
handful of files need to be\r\nreviewed:\r\n\r\n```markdown\r\n###
elastic/security-defend-workflows\r\n\r\n*
x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_solution_integrations.ts\r\n\r\n###
elastic/security-detection-rule-management\r\n\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.ts\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts\r\n\r\n###
elastic/security-detections-response\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n\r\n###
elastic/security-engineering-productivity\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n*
x-pack/test/security_solution_cypress/cypress/tasks/api_calls/timelines.ts\r\n```\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"00789609ad663efffd7b3997ca773fe3ea5511e2"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/190238","number":190238,"mergeCommit":{"message":"[Threat
Hunting Investigations] Migrate all timeline routes to OpenAPI types
(#190238)\n\n## Summary\r\n\r\nfixes:
https://github.com/elastic/security-team/issues/10235\r\nfixes:
https://github.com/elastic/security-team/issues/10237\r\n\r\nThis is the
final PR for migrating over all timeline-related schemas and\r\ntypes to
the new generated zod schemas from our OpenAPI specs.
(see\r\nhttps://github.com/elastic/security-team/issues/10110)\r\nOn top
of moving to the new schemas/types, this PR also cleans up usage\r\nof
now outdated types.\r\n\r\nI'm aware of the size of this PR but rest
assured, the changes are easy\r\nto review and for most teams, only a
handful of files need to be\r\nreviewed:\r\n\r\n```markdown\r\n###
elastic/security-defend-workflows\r\n\r\n*
x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_solution_integrations.ts\r\n\r\n###
elastic/security-detection-rule-management\r\n\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/get_prebuilt_rules_and_timelines_status_route.ts\r\n*
x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts\r\n\r\n###
elastic/security-detections-response\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n\r\n###
elastic/security-engineering-productivity\r\n\r\n*
x-pack/test/security_solution_cypress/cypress/objects/timeline.ts\r\n*
x-pack/test/security_solution_cypress/cypress/tasks/api_calls/timelines.ts\r\n```\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"00789609ad663efffd7b3997ca773fe3ea5511e2"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants