Skip to content
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

[Stack Connectors][SentinelOne + Crowdstrike] Fix the validation of external API responses that return non-JSON (ex. stream) #203820

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
2 changes: 2 additions & 0 deletions x-pack/plugins/stack_connectors/common/crowdstrike/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const CrowdstrikeSecretsSchema = schema.object({
clientSecret: schema.string(),
});

export const CrowdstrikeApiDoNotValidateResponsesSchema = schema.any();

export const RelaxedCrowdstrikeBaseApiResponseSchema = schema.maybe(
schema.object({}, { unknowns: 'allow' })
);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/stack_connectors/common/sentinelone/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const SentinelOneSecretsSchema = schema.object({
token: schema.string(),
});

export const SentinelOneApiDoNotValidateResponsesSchema = schema.any();

export const SentinelOneBaseApiResponseSchema = schema.maybe(
schema.object({}, { unknowns: 'allow' })
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import type {
import {
CrowdstrikeHostActionsParamsSchema,
CrowdstrikeGetAgentsParamsSchema,
CrowdstrikeGetTokenResponseSchema,
CrowdstrikeHostActionsResponseSchema,
RelaxedCrowdstrikeBaseApiResponseSchema,
CrowdstrikeRTRCommandParamsSchema,
CrowdstrikeExecuteRTRResponseSchema,
CrowdstrikeGetScriptsParamsSchema,
CrowdStrikeExecuteRTRResponse,
CrowdstrikeApiDoNotValidateResponsesSchema,
CrowdstrikeGetTokenResponseSchema,
} from '../../../common/crowdstrike/schema';
import { SUB_ACTION } from '../../../common/crowdstrike/constants';
import { CrowdstrikeError } from './error';
Expand Down Expand Up @@ -229,7 +230,8 @@ export class CrowdstrikeConnector extends SubActionConnector<
'Content-Type': 'application/x-www-form-urlencoded',
authorization: 'Basic ' + CrowdstrikeConnector.base64encodedToken,
},
responseSchema: CrowdstrikeGetTokenResponseSchema,
responseSchema:
CrowdstrikeApiDoNotValidateResponsesSchema as unknown as typeof CrowdstrikeGetTokenResponseSchema,
},
connectorUsageCollector
);
Expand Down Expand Up @@ -265,7 +267,7 @@ export class CrowdstrikeConnector extends SubActionConnector<
// where the external system might add/remove/change values in the response that we have no
// control over.
responseSchema:
RelaxedCrowdstrikeBaseApiResponseSchema as unknown as SubActionRequestParams<R>['responseSchema'],
CrowdstrikeApiDoNotValidateResponsesSchema as unknown as SubActionRequestParams<R>['responseSchema'],
headers: {
...req.headers,
Authorization: `Bearer ${CrowdstrikeConnector.token}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
SentinelOneGetRemoteScriptResultsParamsSchema,
SentinelOneDownloadRemoteScriptResultsParamsSchema,
SentinelOneDownloadRemoteScriptResultsResponseSchema,
SentinelOneBaseApiResponseSchema,
SentinelOneApiDoNotValidateResponsesSchema,
} from '../../../common/sentinelone/schema';
import { SUB_ACTION } from '../../../common/sentinelone/constants';
import {
Expand Down Expand Up @@ -405,7 +405,7 @@ export class SentinelOneConnector extends SubActionConnector<
// where the external system might add/remove/change values in the response that we have no
// control over.
responseSchema:
SentinelOneBaseApiResponseSchema as unknown as SubActionRequestParams<R>['responseSchema'],
SentinelOneApiDoNotValidateResponsesSchema as unknown as SubActionRequestParams<R>['responseSchema'],
params: {
...req.params,
APIToken: this.secrets.token,
Expand Down
Loading