Skip to content

Commit

Permalink
[Stack Connectors][SentinelOne + Crowdstrike] Update Crowdstrike and …
Browse files Browse the repository at this point in the history
…Sentinelone connectors to NOT validate API responses (elastic#202515)

## Summary

- Changed Crowdstrike and SentinelOne connectors to no longer validate
API responses from the external system
  • Loading branch information
paul-tavares authored and CAWilson94 committed Dec 9, 2024
1 parent f7a02f7 commit c6cd428
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/stack_connectors/common/crowdstrike/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const CrowdstrikeSecretsSchema = schema.object({
clientSecret: schema.string(),
});

export const RelaxedCrowdstrikeBaseApiResponseSchema = schema.object({}, { unknowns: 'allow' });
export const RelaxedCrowdstrikeBaseApiResponseSchema = schema.maybe(
schema.object({}, { unknowns: 'allow' })
);
export const CrowdstrikeBaseApiResponseSchema = schema.object(
{
resources: schema.arrayOf(schema.any()),
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/stack_connectors/common/sentinelone/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const SentinelOneSecretsSchema = schema.object({
token: schema.string(),
});

export const SentinelOneBaseApiResponseSchema = schema.object({}, { unknowns: 'allow' });
export const SentinelOneBaseApiResponseSchema = schema.maybe(
schema.object({}, { unknowns: 'allow' })
);

export const SentinelOneGetAgentsResponseSchema = schema.object(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ export class CrowdstrikeConnector extends SubActionConnector<
const response = await this.request<R>(
{
...req,
// We don't validate responses from Crowdstrike API's because we do not want failures for cases
// 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'],
headers: {
...req.headers,
Authorization: `Bearer ${CrowdstrikeConnector.token}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
SentinelOneGetActivitiesParams,
} from '../../../common/sentinelone/types';
import { API_PATH } from './sentinelone';
import { SentinelOneGetActivitiesResponseSchema } from '../../../common/sentinelone/schema';
import { ConnectorUsageCollector } from '@kbn/actions-plugin/server/types';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';

Expand Down Expand Up @@ -107,7 +106,7 @@ describe('SentinelOne Connector', () => {
params: {
APIToken: 'token-abc',
},
responseSchema: SentinelOneGetActivitiesResponseSchema,
responseSchema: expect.any(Object),
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
SentinelOneGetRemoteScriptResultsParamsSchema,
SentinelOneDownloadRemoteScriptResultsParamsSchema,
SentinelOneDownloadRemoteScriptResultsResponseSchema,
SentinelOneBaseApiResponseSchema,
} from '../../../common/sentinelone/schema';
import { SUB_ACTION } from '../../../common/sentinelone/constants';
import {
Expand Down Expand Up @@ -400,6 +401,11 @@ export class SentinelOneConnector extends SubActionConnector<
const response = await this.request<R>(
{
...req,
// We don't validate responses from SentinelOne API's because we do not want failures for cases
// 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'],
params: {
...req.params,
APIToken: this.secrets.token,
Expand Down

0 comments on commit c6cd428

Please sign in to comment.