Skip to content

Commit

Permalink
Add closures options
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Mar 6, 2020
1 parent 7e42a5d commit 6449515
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
59 changes: 57 additions & 2 deletions x-pack/legacy/plugins/siem/public/lib/connectors/servicenow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EuiFlexItem,
EuiFormRow,
EuiFieldPassword,
EuiRadioGroup,
} from '@elastic/eui';
import {
ActionConnectorFieldsProps,
Expand Down Expand Up @@ -81,13 +82,53 @@ export function getActionType(): ActionTypeModel {
const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsProps<
ServiceNowActionConnector
>> = ({ action, editActionConfig, editActionSecrets, errors }) => {
const { apiUrl } = action.config;
const { apiUrl, casesConfiguration } = action.config;
const { username, password } = action.secrets;

const closure = casesConfiguration?.closure ?? 'manual';

const isApiUrlInvalid: boolean = errors.apiUrl.length > 0 && apiUrl !== undefined;
const isUsernameInvalid: boolean = errors.username.length > 0 && username !== undefined;
const isPasswordInvalid: boolean = errors.password.length > 0 && password !== undefined;

if (!casesConfiguration) {
editActionConfig('casesConfiguration', {
closure: 'manual',
mapping: [
{
source: 'title',
target: 'description',
onEditAndUpdate: 'nothing',
},
{
source: 'description',
target: 'short_description',
onEditAndUpdate: 'nothing',
},
{
source: 'comments',
target: 'work_notes',
onEditAndUpdate: 'nothing',
},
],
});
}

const radios = [
{
id: 'manual',
label: 'Manually close SIEM cases',
},
{
id: 'newIncident',
label: 'Automatically close SIEM cases when pushing new incident to third-party',
},
{
id: 'closedIncident',
label: 'Automatically close SIEM cases when incident is closed in third-party',
},
];

return (
<>
<EuiFlexGroup>
Expand All @@ -105,7 +146,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
name="apiUrl"
value={apiUrl}
data-test-subj="apiUrlFromInput"
placeholder="https://<instance>.service-now.com/api/now/v1/table/incident"
placeholder="https://<instance>.service-now.com"
onChange={e => {
editActionConfig('apiUrl', e.target.value);
}}
Expand Down Expand Up @@ -172,6 +213,20 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow id="closure" fullWidth label={'Case closure options'}>
<EuiRadioGroup
options={radios}
idSelected={closure}
onChange={(val: string) => {
editActionConfig('casesConfiguration', { ...casesConfiguration, closure: val });
}}
name="closure"
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</>
);
};
Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/siem/public/lib/connectors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

interface ServiceNowConfig {
apiUrl: string;
casesConfiguration: {
closure: string;
};
}

interface ServiceNowSecrets {
Expand Down

0 comments on commit 6449515

Please sign in to comment.