-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Case] ServiceNow ITSM: Add category & subcategory fields #90547
Conversation
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
487df89
to
d6bfcef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alerting related changes LGTM
d6bfcef
to
ce779a1
Compare
ce779a1
to
d709227
Compare
Pinging @elastic/uptime (Team:uptime) |
1cea661
to
663aa0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -119,6 +119,8 @@ function getServiceNowActionParams(): ServiceNowActionParams { | |||
impact: '2', | |||
severity: '2', | |||
urgency: '2', | |||
category: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to update our UI to allow users to actually set these without using the API directly. I'm creating a follow-up issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinkambic FWIW, there is an API call (subaction) where you can get dynamically all available choices (impact, priority, severity, category, subcategory) for a specific instance. If you are interested to this please ping me on Slack!
663aa0f
to
0b8436e
Compare
@elasticmachine merge upstream |
ba6e698
to
8962df3
Compare
b745780
to
0a794b6
Compare
test('it should set subcategory to null when changing category', async () => { | ||
await waitFor(() => { | ||
const select = wrapper.find(EuiSelect).filter(`[data-test-subj="categorySelect"]`)!; | ||
select.prop('onChange')!({ | ||
target: { | ||
value: 'network', | ||
}, | ||
} as React.ChangeEvent<HTMLSelectElement>); | ||
}); | ||
wrapper.update(); | ||
expect(onChange).toHaveBeenCalledWith({ | ||
...fields, | ||
subcategory: null, | ||
category: 'network', | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I know the other tests here dont follow this and it passes as is without, but the correct way would be:
test('it should set subcategory to null when changing category', async () => { | |
await waitFor(() => { | |
const select = wrapper.find(EuiSelect).filter(`[data-test-subj="categorySelect"]`)!; | |
select.prop('onChange')!({ | |
target: { | |
value: 'network', | |
}, | |
} as React.ChangeEvent<HTMLSelectElement>); | |
}); | |
wrapper.update(); | |
expect(onChange).toHaveBeenCalledWith({ | |
...fields, | |
subcategory: null, | |
category: 'network', | |
}); | |
}); | |
test('it should set subcategory to null when changing category', async () => { | |
const select = wrapper.find(EuiSelect).filter(`[data-test-subj="categorySelect"]`)!; | |
select.prop('onChange')!({ | |
target: { | |
value: 'network', | |
}, | |
} as React.ChangeEvent<HTMLSelectElement>); | |
wrapper.update(); | |
await waitFor(() => { | |
expect(onChange).toHaveBeenCalledWith({ | |
...fields, | |
subcategory: null, | |
category: 'network', | |
}); | |
}); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the await waitFor should be surrounding the expect after the async change. it definitely does not always work this way, but alas we're using enzyme with react-testing-library
disabled={isLoadingChoices} | ||
options={categoryOptions} | ||
value={incident.category ?? undefined} | ||
onChange={(e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do a useCallback here since you have the incident
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no difference if we use the incident or not. The callback function will always be a new reference for the prop no matter what we do inside the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual testing went perfectly. Just a few nits on the code, other than that LGTM. very clean, nicely done! 🎸
0a794b6
to
81cfa31
Compare
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
Summary
The PR adds two new fields for the ServiceNow ITSM connector. Specifically,
category
andsubcategory
. It also fixes a bug when changing categories and subcategories in ServiceNow SIR connector.Create Case
ITSM.-.Create.Case.mov
Alerts & Detections
Meta: https://github.com/elastic/security-team/issues/477
Depends on: #88655
Checklist
Delete any items that are not applicable to this PR.
For maintainers