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

[Security Solution][Alerts][Rules] Force optional fields to be accounted for in conversion to rule response schema #136910

Closed
marshallmain opened this issue Jul 21, 2022 · 1 comment · Fixed by #137628
Labels
8.5 candidate Team:Detection Alerts Security Detection Alerts Area Team Team:Detection Rule Management Security Detection Rule Management Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture

Comments

@marshallmain
Copy link
Contributor

#136774 fixes a bug where an optional field was missed in the conversion between the internal rule schema and the HTTP API response schema. The internal schema defines all optional fields as [field]: <type> | undefined instead of truly optional like [field]?: <type>, which causes a type error in the conversion function between HTTP request and internal schema if a field is not explicitly accounted for in the conversion function. (example: try removing savedId from the conversion function here - TS reports an error)

However, the response schema uses t.partial on the optional fields still, which means that when converting between internal schema and HTTP response, optional fields can be completely omitted from the conversion function. In this case when the optional field does actually have a value, it won't be included in the response.

Ideally, we should have the response schema use a similar mechanism to the internal schema to enforce all fields being accounted for when converting from internal to response schema.

@marshallmain marshallmain added technical debt Improvement of the software architecture and operational architecture Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team Team:Detection Alerts Security Detection Alerts Area Team 8.5 candidate labels Jul 21, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.5 candidate Team:Detection Alerts Security Detection Alerts Area Team Team:Detection Rule Management Security Detection Rule Management Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture
Projects
None yet
2 participants