Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ export enum MICROSOFT_DEFENDER_ENDPOINT_SUB_ACTION {
ISOLATE_HOST = 'isolateHost',
RELEASE_HOST = 'releaseHost',
GET_ACTIONS = 'getActions',
GET_LIBRARY_FILES = 'getLibraryFiles',
RUN_SCRIPT = 'runScript',
GET_ACTION_RESULTS = 'getActionResults',
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const MicrosoftDefenderEndpointBaseApiResponseSchema = schema.maybe(
schema.object({}, { unknowns: 'allow' })
);

export const MicrosoftDefenderEndpointEmptyParamsSchema = schema.object({});

export const TestConnectorParamsSchema = schema.object({});

export const AgentDetailsParamsSchema = schema.object({
Expand Down Expand Up @@ -146,6 +148,15 @@ export const ReleaseHostParamsSchema = schema.object({
comment: schema.string({ minLength: 1 }),
});

export const RunScriptParamsSchema = schema.object({
id: schema.string({ minLength: 1 }),
comment: schema.maybe(schema.string({ minLength: 1 })),
parameters: schema.object({
scriptName: schema.string({ minLength: 1 }),
args: schema.maybe(schema.string({ minLength: 1 })),
}),
});

const MachineActionTypeSchema = schema.oneOf([
schema.literal('RunAntiVirusScan'),
schema.literal('Offboard'),
Expand Down Expand Up @@ -207,6 +218,37 @@ export const GetActionsParamsSchema = schema.object({
sortDirection: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])),
});

export const GetActionResultsParamsSchema = schema.object({
id: schema.maybe(
schema.oneOf([
schema.string({ minLength: 1 }),
schema.arrayOf(schema.string({ minLength: 1 }), { minSize: 1 }),
])
),
});

export const MSDefenderLibraryFileSchema = schema.object(
{
fileName: schema.maybe(schema.string()),
sha256: schema.maybe(schema.string()),
description: schema.maybe(schema.string()),
creationTime: schema.maybe(schema.string()),
lastUpdatedTime: schema.maybe(schema.string()),
createdBy: schema.maybe(schema.string()),
hasParameters: schema.maybe(schema.boolean()),
parametersDescription: schema.maybe(schema.nullable(schema.string())),
},
{ unknowns: 'allow' }
);

export const GetLibraryFilesResponse = schema.object(
{
'@odata.context': schema.maybe(schema.string()),
value: schema.maybe(schema.arrayOf(MSDefenderLibraryFileSchema)),
},
{ unknowns: 'allow' }
);

// ----------------------------------
// Connector Sub-Actions
// ----------------------------------
Expand All @@ -225,9 +267,14 @@ const ReleaseHostSchema = schema.object({
subAction: schema.literal(MICROSOFT_DEFENDER_ENDPOINT_SUB_ACTION.RELEASE_HOST),
subActionParams: ReleaseHostParamsSchema,
});
const RunScriptSchema = schema.object({
subAction: schema.literal(MICROSOFT_DEFENDER_ENDPOINT_SUB_ACTION.RUN_SCRIPT),
subActionParams: RunScriptParamsSchema,
});

export const MicrosoftDefenderEndpointActionParamsSchema = schema.oneOf([
TestConnectorSchema,
IsolateHostSchema,
ReleaseHostSchema,
RunScriptSchema,
]);
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type {
AgentDetailsParamsSchema,
GetActionsParamsSchema,
AgentListParamsSchema,
GetLibraryFilesResponse,
RunScriptParamsSchema,
} from './schema';

export type MicrosoftDefenderEndpointConfig = TypeOf<typeof MicrosoftDefenderEndpointConfigSchema>;
Expand Down Expand Up @@ -60,6 +62,11 @@ export interface MicrosoftDefenderEndpointGetActionsResponse {
value: MicrosoftDefenderEndpointMachineAction[];
}

export interface MicrosoftDefenderEndpointGetActionResultsResponse {
'@odata.context': string;
value: string[]; // Downloadable link
}

/**
* @see https://learn.microsoft.com/en-us/defender-endpoint/api/machine
*/
Expand Down Expand Up @@ -177,6 +184,7 @@ export type MicrosoftDefenderEndpointTestConnectorParams = TypeOf<typeof TestCon
export type MicrosoftDefenderEndpointIsolateHostParams = TypeOf<typeof IsolateHostParamsSchema>;

export type MicrosoftDefenderEndpointReleaseHostParams = TypeOf<typeof ReleaseHostParamsSchema>;
export type MicrosoftDefenderEndpointRunScriptParams = TypeOf<typeof RunScriptParamsSchema>;

export type MicrosoftDefenderEndpointActionParams = TypeOf<
typeof MicrosoftDefenderEndpointActionParamsSchema
Expand All @@ -188,3 +196,5 @@ export interface MicrosoftDefenderEndpointApiTokenResponse {
expires_in: number;
access_token: string;
}

export type MicrosoftDefenderGetLibraryFilesResponse = TypeOf<typeof GetLibraryFilesResponse>;
Loading