Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f30a292
Added new abstract method `fetchAgentPolicyInfo()` to base class and …
paul-tavares Apr 4, 2025
052bb8b
Added `spaceId` option to Response Actions clients and adjusted stori…
paul-tavares Apr 4, 2025
7366645
Fleet: add log when running external callback fails
paul-tavares Apr 7, 2025
002f702
Merge remote-tracking branch 'upstream/main' into task/olm-11225-stor…
paul-tavares Apr 7, 2025
b3482d0
Revert "Fleet: add log when running external callback fails"
paul-tavares Apr 8, 2025
b70f3dc
Add `fetchAgentPolicyInfo()` to Endpoint response actions client
paul-tavares Apr 8, 2025
6b5f953
Implementation of `fetchAgentPolicyInfo()` for S1
paul-tavares Apr 8, 2025
8e18f9e
remove comment
paul-tavares Apr 9, 2025
f597e67
Added `fetchFleetInfoForAgents()` to base class and refactored S1 and…
paul-tavares Apr 10, 2025
3444532
Added `fetchAgentPolicyInfo()` implementation to MS defender client
paul-tavares Apr 10, 2025
e2f3b37
Added implementation of `fetchAgentPolicyInfo()` to crowdstrike
paul-tavares Apr 10, 2025
a06b59f
Changed S1 and MS Defender run scripts to include the space id in the…
paul-tavares Apr 10, 2025
62746f7
Added new method `getIntegrationNamespaces()` to internal fleet services
paul-tavares Apr 14, 2025
46ad24f
Refactor response actions clients to ensure policy info. is retrieved…
paul-tavares Apr 14, 2025
f9e1fe1
Fix generator and tests to include new `agent.policy`
paul-tavares Apr 14, 2025
04e0198
Tests for `getIntegrationNamespaces()`
paul-tavares Apr 15, 2025
d710fba
Fix test for `fetchActionRequests()`
paul-tavares Apr 15, 2025
151ff88
Test for base class write of action to index
paul-tavares Apr 15, 2025
8b3865b
Added additional mock generators for sentinelOne
paul-tavares Apr 15, 2025
7f9ff2d
Added support for index patterns in `applyEsClientSearchMock()` utility
paul-tavares Apr 15, 2025
5ae36a5
Update mocks
paul-tavares Apr 16, 2025
48f024d
tests for S1 when spaces is enabled
paul-tavares Apr 16, 2025
9c62359
tests for endpoint write of request when spaces is enabled
paul-tavares Apr 16, 2025
6961214
Tests for MS Defender
paul-tavares Apr 16, 2025
c3310ce
Tests for crowdstrike
paul-tavares Apr 16, 2025
f3989cb
Add missing test to MS Defender client
paul-tavares Apr 16, 2025
6cc71e9
Merge remote-tracking branch 'upstream/main' into task/olm-11225-stor…
paul-tavares Apr 16, 2025
a735127
Improvement to wrap errors utility
paul-tavares Apr 16, 2025
1283e07
Adjustments to HTTP error codes and messages
paul-tavares Apr 16, 2025
fdb9f36
Adjust mock utility use of `fromKueryExpression()`
paul-tavares Apr 17, 2025
18137cf
Clean up utils.mock.ts
paul-tavares Apr 17, 2025
929ce46
Fix failing tests
paul-tavares Apr 17, 2025
fa8f49d
Merge branch 'main' into task/olm-11225-store-policy-id-in-action-req…
paul-tavares Apr 17, 2025
af22a7a
Change API route error handler to handle `500` errors instead of dele…
paul-tavares Apr 17, 2025
7d36a91
Add additional validation to external EDR clients
paul-tavares Apr 17, 2025
317971a
Merge remote-tracking branch 'origin/task/olm-11225-store-policy-id-i…
paul-tavares Apr 17, 2025
08c7630
Fix in S1
paul-tavares Apr 17, 2025
6a3d122
Fix test
paul-tavares Apr 17, 2025
df5507e
Merge branch 'main' into task/olm-11225-store-policy-id-in-action-req…
paul-tavares Apr 21, 2025
a90a129
Apply suggestions from code review
paul-tavares Apr 22, 2025
5241583
Merge remote-tracking branch 'upstream/main' into task/olm-11225-stor…
paul-tavares Apr 22, 2025
47daa45
Update type to use `unknown`
paul-tavares Apr 22, 2025
d1b6b15
Fix spelling and tests
paul-tavares Apr 22, 2025
e029581
Merge branch 'main' into task/olm-11225-store-policy-id-in-action-req…
paul-tavares Apr 22, 2025
057068f
Merge branch 'main' into task/olm-11225-store-policy-id-in-action-req…
paul-tavares Apr 23, 2025
6f5407e
Apply suggestions from code review
paul-tavares Apr 23, 2025
28fcab4
Update x-pack/solutions/security/plugins/security_solution/common/end…
paul-tavares Apr 23, 2025
a07ed42
Merge branch 'main' into task/olm-11225-store-policy-id-in-action-req…
paul-tavares Apr 23, 2025
76f9d08
Fix insights tests
paul-tavares Apr 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ export class EndpointActionGenerator extends BaseDataGenerator {
overrides: DeepPartial<LogsEndpointAction<TParameters, TOutputContent, TMeta>> = {}
): LogsEndpointAction<TParameters, TOutputContent, TMeta> {
const timeStamp = overrides['@timestamp'] ? new Date(overrides['@timestamp']) : new Date();
const agent = (overrides.agent?.id ?? [
this.seededUUIDv4(),
]) as LogsEndpointAction['agent']['id'];
const agentId = Array.isArray(agent) ? (agent[0] as string) : agent;
const doc: LogsEndpointAction<TParameters, TOutputContent, TMeta> = {
'@timestamp': timeStamp.toISOString(),
agent: {
id: [this.seededUUIDv4()],
id: agent,
policy: [
{
agentId,
elasticAgentId: agentId,
integrationPolicyId: 'integration-policy-1',
agentPolicyId: 'agent-policy-1',
},
],
},
EndpointActions: {
action_id: this.seededUUIDv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,141 +5,167 @@
* 2.0.
*/

import type { DeepPartial } from 'utility-types';
import { merge } from 'lodash';
import type { SearchHit } from '@elastic/elasticsearch/lib/api/types';
import { buildIndexNameWithNamespace } from '../utils/index_name_utilities';
import { MICROSOFT_DEFENDER_ENDPOINT_LOG_INDEX_PATTERN } from '../service/response_actions/microsoft_defender';
import { BaseDataGenerator } from './base_data_generator';
import type { MicrosoftDefenderEndpointLogEsDoc } from '../types';

export class MicrosoftDefenderDataGenerator extends BaseDataGenerator {
/**
* Generates a MS Defender endpoint log as ingested by the Microsoft Defender for Endpoint
* integration into the `logs-microsoft_defender_endpoint.log` index.
* If adding this generated document to ES, make sure that the integration has been installed.
*/
generateEndpointLog() {
generateEndpointLog(
overrides: DeepPartial<MicrosoftDefenderEndpointLogEsDoc> = {}
): MicrosoftDefenderEndpointLogEsDoc {
const now = new Date().toISOString();

return {
agent: {
name: 'ptavares-agentless-integrations-default-8511',
id: 'a572fc2e-0276-494a-b693-6e907bc2a78b',
ephemeral_id: 'e7d70430-d25e-4d72-863e-918ac36bbbf7',
type: 'filebeat',
version: '9.0.0',
},
process: {
parent: {
return merge(
{
agent: {
name: 'ptavares-agentless-integrations-default-8511',
id: 'a572fc2e-0276-494a-b693-6e907bc2a78b',
ephemeral_id: 'e7d70430-d25e-4d72-863e-918ac36bbbf7',
type: 'filebeat',
version: '9.0.0',
},
process: {
parent: {
start: now,
pid: 9901,
},
start: now,
pid: 9901,
pid: 10083,
command_line: '-bash',
},
start: now,
pid: 10083,
command_line: '-bash',
},
elastic_agent: {
id: 'a572fc2e-0276-494a-b693-6e907bc2a78b',
version: '9.0.0',
snapshot: true,
},
rule: {
description:
'Remote file transfer activity was observed on this device. Attackers might be attempting to steal data from the device or move laterally on the network.',
},
message: 'Remote exfiltration activity',
microsoft: {
defender_endpoint: {
evidence: {
accountName: 'ubuntu',
detectionStatus: 'Detected',
parentProcessFileName: 'bash',
entityType: 'Process',
evidenceCreationTime: now,
domainName: 'discerning-spaniel',
elastic_agent: {
id: 'a572fc2e-0276-494a-b693-6e907bc2a78b',
version: '9.0.0',
snapshot: true,
},
rule: {
description:
'Remote file transfer activity was observed on this device. Attackers might be attempting to steal data from the device or move laterally on the network.',
},
message: 'Remote exfiltration activity',
microsoft: {
defender_endpoint: {
evidence: {
accountName: 'ubuntu',
detectionStatus: 'Detected',
parentProcessFileName: 'bash',
entityType: 'Process',
evidenceCreationTime: now,
domainName: 'discerning-spaniel',
},
mitreTechniques: [
'T1005',
'T1020',
'T1041',
'T1048',
'T1071',
'T1071.001',
'T1204.001',
'T1567',
'T1570',
],
detectorId: this.seededUUIDv4(),
investigationState: 'UnsupportedOs',
incidentId: '4',
lastUpdateTime: now,
status: 'New',
},
mitreTechniques: [
'T1005',
'T1020',
'T1041',
'T1048',
'T1071',
'T1071.001',
'T1204.001',
'T1567',
'T1570',
},
tags: ['microsoft-defender-endpoint', 'forwarded'],
cloud: {
instance: {
id: '7bcf55e03728756dbf02ba7979a0c6218321ade7',
},
provider: 'azure',
account: {
id: 'c38d90f4-369c-4815-ab69-4663a1f5c115',
},
},
input: {
type: 'httpjson',
},
observer: {
product: 'Defender for Endpoint',
vendor: 'Microsoft',
name: 'WindowsDefenderAtp',
},
'@timestamp': now,
file: {
path: '/usr/bin/',
name: 'bash',
hash: {
sha1: 'ce4fbd66c02e235bbc8dfa4a512c51414d8e0e67',
sha256: 'c5f8a98c674631609902846fae6df219b3b16d97db58cf1c1334f8eb14962bde',
},
},
ecs: {
version: '8.11.0',
},
related: {
hosts: ['discerning-spaniel'],
hash: [
'ce4fbd66c02e235bbc8dfa4a512c51414d8e0e67',
'c5f8a98c674631609902846fae6df219b3b16d97db58cf1c1334f8eb14962bde',
],
detectorId: this.seededUUIDv4(),
investigationState: 'UnsupportedOs',
incidentId: '4',
lastUpdateTime: now,
status: 'New',
},
},
tags: ['microsoft-defender-endpoint', 'forwarded'],
cloud: {
instance: {
id: '7bcf55e03728756dbf02ba7979a0c6218321ade7',
data_stream: {
namespace: 'default',
type: 'logs',
dataset: 'microsoft_defender_endpoint.log',
},
provider: 'azure',
account: {
id: 'c38d90f4-369c-4815-ab69-4663a1f5c115',
host: {
hostname: 'discerning-spaniel',
name: 'discerning-spaniel',
},
},
input: {
type: 'httpjson',
},
observer: {
product: 'Defender for Endpoint',
vendor: 'Microsoft',
name: 'WindowsDefenderAtp',
},
'@timestamp': now,
file: {
path: '/usr/bin/',
name: 'bash',
hash: {
sha1: 'ce4fbd66c02e235bbc8dfa4a512c51414d8e0e67',
sha256: 'c5f8a98c674631609902846fae6df219b3b16d97db58cf1c1334f8eb14962bde',
threat: {
framework: 'MITRE ATT&CK',
technique: {
name: ['Exfiltration'],
},
},
},
ecs: {
version: '8.11.0',
},
related: {
hosts: ['discerning-spaniel'],
hash: [
'ce4fbd66c02e235bbc8dfa4a512c51414d8e0e67',
'c5f8a98c674631609902846fae6df219b3b16d97db58cf1c1334f8eb14962bde',
],
},
data_stream: {
namespace: 'default',
type: 'logs',
dataset: 'microsoft_defender_endpoint.log',
},
host: {
hostname: 'discerning-spaniel',
name: 'discerning-spaniel',
},
threat: {
framework: 'MITRE ATT&CK',
technique: {
name: ['Exfiltration'],
event: {
severity: 3,
created: now,
kind: 'alert',
timezone: 'UTC',
start: now,
type: ['start'],
duration: 5253721000,
agent_id_status: 'verified',
ingested: now,
provider: 'defender_endpoint',
action: 'Exfiltration',
end: now,
id: this.seededUUIDv4(),
category: ['host', 'process'],
dataset: 'microsoft_defender_endpoint.log',
},
},
event: {
severity: 3,
created: now,
kind: 'alert',
timezone: 'UTC',
start: now,
type: ['start'],
duration: 5253721000,
agent_id_status: 'verified',
ingested: now,
provider: 'defender_endpoint',
action: 'Exfiltration',
end: now,
id: this.seededUUIDv4(),
category: ['host', 'process'],
dataset: 'microsoft_defender_endpoint.log',
},
};
overrides
);
}

generateEndpointLogEsHit(
overrides: DeepPartial<MicrosoftDefenderEndpointLogEsDoc> = {}
): SearchHit<MicrosoftDefenderEndpointLogEsDoc> {
return this.toEsSearchHit(
this.generateEndpointLog(overrides),
buildIndexNameWithNamespace(MICROSOFT_DEFENDER_ENDPOINT_LOG_INDEX_PATTERN, 'default')
);
}

generateEndpointLogEsSearchResponse(
docs: Array<SearchHit<MicrosoftDefenderEndpointLogEsDoc>> = [this.generateEndpointLogEsHit()]
) {
return this.toEsSearchResponse(docs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
SentinelOneGetRemoteScriptStatusApiResponse,
SentinelOneRemoteScriptExecutionStatus,
} from '@kbn/stack-connectors-plugin/common/sentinelone/types';
import { buildIndexNameWithNamespace } from '../utils/index_name_utilities';
import { EndpointActionGenerator } from './endpoint_action_generator';
import { SENTINEL_ONE_ACTIVITY_INDEX_PATTERN } from '../..';
import type {
Expand All @@ -26,7 +27,9 @@ import type {
EndpointActionDataParameterTypes,
EndpointActionResponseDataOutput,
SentinelOneActivityDataForType80,
SentinelOneAgentEsDoc,
} from '../types';
import { SENTINEL_ONE_AGENT_INDEX_PATTERN } from '../service/response_actions/sentinel_one';

export class SentinelOneDataGenerator extends EndpointActionGenerator {
static readonly scriptExecutionStatusValues: Readonly<
Expand Down Expand Up @@ -428,6 +431,45 @@ export class SentinelOneDataGenerator extends EndpointActionGenerator {
pagination: { totalItems: 1, nextCursor: undefined },
};
}

/**
* Generate a SentinelOne Agent record that is ingested into Elasticsearch by the
* integration into `logs-sentinel_one.agent-`
*/
generateAgentEsDoc(overrides: DeepPartial<SentinelOneAgentEsDoc> = {}): SentinelOneAgentEsDoc {
return merge(
{
agent: {
id: '1-2-3',
type: 'filebeat',
version: '9.1.0',
},
sentinel_one: {
agent: {
agent: {
id: 's1-agent-1',
},
},
},
},
overrides
);
}

generateAgentEsSearchHit(
overrides: DeepPartial<SentinelOneAgentEsDoc> = {}
): SearchHit<SentinelOneAgentEsDoc> {
return this.toEsSearchHit(
this.generateAgentEsDoc(overrides),
buildIndexNameWithNamespace(SENTINEL_ONE_AGENT_INDEX_PATTERN, 'default')
);
}

generateAgentEsSearchResponse(
docs: Array<SearchHit<SentinelOneAgentEsDoc>> = [this.generateAgentEsSearchHit()]
): SearchResponse<SentinelOneAgentEsDoc> {
return this.toEsSearchResponse<SentinelOneAgentEsDoc>(docs);
}
}

// Activity types from SentinelOne. Values can be retrieved from the SentineOne API at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ export const RESPONSE_ACTIONS_ALERT_AGENT_ID_FIELDS: Readonly<
],
crowdstrike: ['device.id'],
microsoft_defender_endpoint: [
'cloud.instance.id',
Copy link
Member

Choose a reason for hiding this comment

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

🙇🏼 Thanks for sorting!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😄

FYI:
I actually did not sort it on purpose. I only moved cloud.instance.id up so that it is the first one we try to find in MS documents. thats because I'm still not 100% sure of the other fields defined below because we never really set up the M365 integration. I got these values from an Env. that Raquel has where she did setup M365.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. Well, sorted values are always nice to maintain. 🌞

'm365_defender.alerts.entities.deviceId',
'm365_defender.alerts.devices.mdatpDeviceId',
'm365_defender.incident.alert.evidence.mde_device_id',
'cloud.instance.id',
],
});

Expand Down
Loading