-
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
TheHive Case Connector #180138
TheHive Case Connector #180138
Changes from 1 commit
9d1522e
8a527cc
b5d8164
1c8d856
0eeed1b
4f2cc46
5f96889
86c87fd
d6b7ae3
a31e7b8
f576b5f
c5eee3f
fa74245
57bb7fe
51d4bea
c9636fe
beb6a40
f5a5a60
3ee54d4
103d1a9
d5c5eca
c269aee
a6c054e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const THEHIVE_TITLE = i18n.translate( | ||
'xpack.stackConnectors.components.thehive.connectorTypeTitle', | ||
{ | ||
defaultMessage: 'TheHive', | ||
} | ||
); | ||
export const THEHIVE_CONNECTOR_ID = '.thehive'; | ||
|
||
export enum SUB_ACTION { | ||
PUSH_TO_SERVICE = 'pushToService', | ||
CREATE_ALERT = 'createAlert', | ||
} | ||
export enum TheHiveSeverity { | ||
LOW = 1, | ||
MEDIUM = 2, | ||
HIGH = 3, | ||
CRITICAL = 4, | ||
} | ||
export enum TheHiveTLP { | ||
CLEAR = 0, | ||
GREEN = 1, | ||
AMBER = 2, | ||
AMBER_STRICT = 3, | ||
RED = 4, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { TheHiveSeverity, TheHiveTLP, SUB_ACTION } from './constants'; | ||
|
||
export const TheHiveConfigSchema = schema.object({ | ||
url: schema.string(), | ||
organisation: schema.nullable(schema.string()), | ||
}); | ||
|
||
export const TheHiveSecretsSchema = schema.object({ | ||
api_key: schema.string() | ||
}); | ||
|
||
export const ExecutorSubActionPushParamsSchema = schema.object({ | ||
incident: schema.object({ | ||
title: schema.string(), | ||
description: schema.string(), | ||
externalId: schema.nullable(schema.string()), | ||
severity: schema.nullable(schema.number({ defaultValue: TheHiveSeverity.MEDIUM })), | ||
tlp: schema.nullable(schema.number({ defaultValue: TheHiveTLP.AMBER })), | ||
tags: schema.nullable(schema.arrayOf(schema.string())), | ||
}), | ||
comments: schema.nullable( | ||
schema.arrayOf( | ||
schema.object({ | ||
comment: schema.string(), | ||
commentId: schema.string(), | ||
}) | ||
) | ||
), | ||
}); | ||
|
||
export const ExecutorSubActionGetIncidentParamsSchema = schema.object({ | ||
externalId: schema.string(), | ||
}); | ||
|
||
export const ExecutorSubActionCreateAlertParamsSchema = schema.object({ | ||
title: schema.string(), | ||
description: schema.string(), | ||
type: schema.string(), | ||
source: schema.string(), | ||
sourceRef: schema.string(), | ||
severity: schema.nullable(schema.number({ defaultValue: TheHiveSeverity.MEDIUM })), | ||
tlp: schema.nullable(schema.number({ defaultValue: TheHiveTLP.AMBER })), | ||
tags: schema.nullable(schema.arrayOf(schema.string())), | ||
}); | ||
|
||
export const ExecutorParamsSchema = schema.oneOf([ | ||
schema.object({ | ||
subAction: schema.literal(SUB_ACTION.PUSH_TO_SERVICE), | ||
subActionParams: ExecutorSubActionPushParamsSchema, | ||
}), | ||
schema.object({ | ||
subAction: schema.literal(SUB_ACTION.CREATE_ALERT), | ||
subActionParams: ExecutorSubActionCreateAlertParamsSchema, | ||
}), | ||
]); | ||
|
||
|
||
export const TheHiveIncidentResponseSchema = schema.object( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure that we need all the fields to be listed in the schema? Do we use them all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we don't use all of them. However, I've included them all as a precaution for future needs. LMK your thoughts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what is best tbh. Assuming TheHIve will not introduce any breaking changes in the fields I do not see any harm in keeping them. If they do then our validation will start failing. The more field we have the more the chance for this to happen. If they are documented here https://docs.strangebee.com/thehive/api-docs/#operation/Create%20case then I think it is fine to keep them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, They are documented. |
||
{ | ||
_id: schema.string(), | ||
_type: schema.string(), | ||
_createdBy: schema.string(), | ||
_updatedBy: schema.nullable(schema.string()), | ||
_createdAt: schema.number(), | ||
_updatedAt: schema.nullable(schema.number()), | ||
number: schema.number(), | ||
title: schema.string(), | ||
description: schema.string(), | ||
severity: schema.number(), | ||
severityLabel: schema.string(), | ||
startDate: schema.number(), | ||
endDate: schema.nullable(schema.number()), | ||
tags: schema.nullable(schema.arrayOf(schema.string())), | ||
flag: schema.boolean(), | ||
tlp: schema.number(), | ||
tlpLabel: schema.string(), | ||
pap: schema.number(), | ||
papLabel: schema.string(), | ||
status: schema.string(), | ||
stage: schema.string(), | ||
summary: schema.nullable(schema.string()), | ||
impactStatus: schema.nullable(schema.string()), | ||
assignee: schema.nullable(schema.string()), | ||
customFields: schema.nullable(schema.arrayOf(schema.object({}, { unknowns: 'allow' }))), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of |
||
userPermissions: schema.nullable(schema.arrayOf(schema.string())), | ||
extraData: schema.object({}, { unknowns: 'allow' }), | ||
newDate: schema.number(), | ||
inProgressDate: schema.nullable(schema.number()), | ||
closedDate: schema.nullable(schema.number()), | ||
alertDate: schema.nullable(schema.number()), | ||
alertNewDate: schema.nullable(schema.number()), | ||
alertInProgressDate: schema.nullable(schema.number()), | ||
alertImportedDate: schema.nullable(schema.number()), | ||
timeToDetect: schema.number(), | ||
timeToTriage: schema.nullable(schema.number()), | ||
timeToQualify: schema.nullable(schema.number()), | ||
timeToAcknowledge: schema.nullable(schema.number()), | ||
timeToResolve: schema.nullable(schema.number()), | ||
handlingDuration: schema.nullable(schema.number()), | ||
}, | ||
{ unknowns: 'ignore' } | ||
); | ||
|
||
export const TheHiveUpdateIncidentResponseSchema = schema.any(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Do you know if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will check and update. |
||
|
||
export const TheHiveAddCommentResponseSchema = schema.object( | ||
{ | ||
_id: schema.string(), | ||
_type: schema.string(), | ||
createdBy: schema.string(), | ||
createdAt: schema.number(), | ||
updatedAt: schema.nullable(schema.number()), | ||
updatedBy: schema.nullable(schema.string()), | ||
message: schema.string(), | ||
isEdited: schema.boolean(), | ||
extraData: schema.object({}, { unknowns: 'allow' }), | ||
}, | ||
{ unknowns: 'ignore' } | ||
); | ||
|
||
export const TheHiveCreateAlertResponseSchema = schema.object( | ||
{ | ||
_id: schema.string(), | ||
_type: schema.string(), | ||
_createdBy: schema.string(), | ||
_updatedBy: schema.nullable(schema.string()), | ||
_createdAt: schema.number(), | ||
_updatedAt: schema.nullable(schema.number()), | ||
type: schema.string(), | ||
source: schema.string(), | ||
sourceRef: schema.string(), | ||
externalLink: schema.nullable(schema.string()), | ||
title: schema.string(), | ||
description: schema.string(), | ||
severity: schema.number(), | ||
severityLabel: schema.string(), | ||
date: schema.number(), | ||
tags: schema.nullable(schema.arrayOf(schema.string())), | ||
tlp: schema.number(), | ||
tlpLabel: schema.string(), | ||
pap: schema.number(), | ||
papLabel: schema.string(), | ||
follow: schema.nullable(schema.boolean()), | ||
customFields: schema.nullable(schema.arrayOf(schema.object({}, { unknowns: 'allow' }))), | ||
caseTemplate: schema.nullable(schema.string()), | ||
observableCount: schema.number(), | ||
caseId: schema.nullable(schema.string()), | ||
status: schema.string(), | ||
stage: schema.string(), | ||
assignee: schema.nullable(schema.string()), | ||
summary: schema.nullable(schema.string()), | ||
extraData: schema.object({}, { unknowns: 'allow' }), | ||
newDate: schema.number(), | ||
inProgressDate: schema.nullable(schema.number()), | ||
closedDate: schema.nullable(schema.number()), | ||
importedDate: schema.nullable(schema.number()), | ||
timeToDetect: schema.number(), | ||
timeToTriage: schema.nullable(schema.number()), | ||
timeToQualify: schema.nullable(schema.number()), | ||
timeToAcknowledge: schema.nullable(schema.number()), | ||
}, | ||
{ unknowns: 'ignore' } | ||
); | ||
|
||
export const TheHiveFailureResponseSchema = schema.object( | ||
{ | ||
type: schema.number(), | ||
message: schema.string(), | ||
}, | ||
{ unknowns: 'allow' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove it. |
||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TypeOf } from '@kbn/config-schema'; | ||
import { | ||
TheHiveConfigSchema, | ||
TheHiveSecretsSchema, | ||
ExecutorParamsSchema, | ||
ExecutorSubActionPushParamsSchema, | ||
ExecutorSubActionCreateAlertParamsSchema, | ||
TheHiveFailureResponseSchema, | ||
} from './schema'; | ||
|
||
export type TheHiveConfig = TypeOf<typeof TheHiveConfigSchema>; | ||
export type TheHiveSecrets = TypeOf<typeof TheHiveSecretsSchema>; | ||
|
||
export type ExecutorParams = TypeOf<typeof ExecutorParamsSchema>; | ||
export type ExecutorSubActionPushParams = TypeOf<typeof ExecutorSubActionPushParamsSchema>; | ||
export type ExecutorSubActionCreateAlertParams = TypeOf<typeof ExecutorSubActionCreateAlertParamsSchema>; | ||
|
||
export type TheHiveFailureResponse = TypeOf<typeof TheHiveFailureResponseSchema>; | ||
|
||
export interface ExternalServiceIncidentResponse { | ||
id: string; | ||
title: string; | ||
url: string; | ||
pushedDate: string; | ||
} | ||
|
||
export interface ExternalServiceCommentResponse { | ||
commentId: string; | ||
pushedDate: string; | ||
externalCommentId?: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import { getXmattersConnectorType } from './xmatters'; | |
import { getD3SecurityConnectorType } from './d3security'; | ||
import { ExperimentalFeaturesService } from '../common/experimental_features_service'; | ||
import { getSentinelOneConnectorType } from './sentinelone'; | ||
import { getTheHiveConnectorType } from './thehive'; | ||
|
||
export interface RegistrationServices { | ||
validateEmailAddresses: ( | ||
|
@@ -68,6 +69,7 @@ export function registerConnectorTypes({ | |
connectorTypeRegistry.register(getTorqConnectorType()); | ||
connectorTypeRegistry.register(getTinesConnectorType()); | ||
connectorTypeRegistry.register(getD3SecurityConnectorType()); | ||
connectorTypeRegistry.register(getTheHiveConnectorType()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @cnasikas, does the new convention to put new connectors under a feature flag apply to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey! Yes, we need to follow the new intermediate release process for all new connectors. |
||
|
||
if (ExperimentalFeaturesService.get().sentinelOneConnectorOn) { | ||
connectorTypeRegistry.register(getSentinelOneConnectorType()); | ||
|
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 remember discussing it but just to be sure, are we sure that the severity and the TLP values are fixed and cannot be changed by users in TheHive?
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.
Correct, users can't change or add new enum for severity and TLP in TheHive.
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 confirm, the TLP, PAP and Severity are static values in TheHive