Skip to content

Commit 23a5c6d

Browse files
[ResponseOps] Granular Connector RBAC (#203503)
Part of #180908 ## Summary **EDR Connector Subfeature Privilege** This PR creates a new EDR connector sub-feature privilege under the read privilege for connectors. The read privilege currently allows users to execute connectors, and this new privilege will limit some of the connectors that can be executed. When the EDR privilege is turned on, users will be able to execute EDR connectors, and when it is off they will not execute. This new privilege includes SentinelOne and Crowdstrike connectors. To determine which connectors are considered EDR connectors, we leverage`getKibanaPrivileges` in the connector type definition. I removed the restrictions to use this field only for system actions and renamed `getSystemActionKibanaPrivileges` to `getActionKibanaPrivileges`. I also added a field, `subFeatureType `, to the connector type definition to help disable testing/executing an connectors that are restricted under a sub-feature. **EDR Connector Execution for Testing** The execution of EDR connectors using the API is limited to a single sub-action for testing purposes. This ensures users can still configure/test EDR connectors. In a separate [PR](#204804), I added back the SentinelOne and Crowdstrike params UIs with options restricted to one sub-action. **Rule API and Feature Configuration Updates** Validation has been added to the rule APIs to enforce restrictions on adding EDR connectors. The connector feature configuration has been updated to include a new feature ID, EdrForSecurityFeature, which ensures that EDR connectors are hidden on the rule form. Note: I saw that EDR connectors are also temporarily restricted in the Security Solution UI. To streamline this, I removed the `isBidirectionalConnectorType` check in `action_type_registry.ts`. Instead, I removed `SecurityConnectorFeatureId` from the `supportedFeatureIds` of the SentinelOne connector type definition. ### Checklist Check the PR satisfies following conditions. - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ## To test **EDR Connector Subfeature Privilege** 1. Create a new role and disable EDR connectors under the Actions and Connectors privilege 2. Create a new user and assign that role to user 3. Create a Sentinel One connector (It doesn't need to work, you can use fake values for the url and token) 4. Login as the new user and run the following in Dev Tools to verify that you aren't authorized execute the Sentinel One connector ``` POST kbn:/api/actions/connector/$CONNECTOR_ID/_execute { "params": { "subAction": "getAgents", "subActionParams": {} } } ``` 7. Update the role to enable EDR connectors and repeat the steps to verify that you are authorized to run the connector. (It will fail but verify it's not Unauthorized) **EDR Connector Execution for Testing** 1. Enable the EDR connectors privilege in the role you created above and log in as the user you created above. 2. Run the following in Dev Tools to verify that you are authorized execute the Sentinel One connector using only the `getAgents` sub-action. (It will fail but verify it's not `Unauthorized`) ``` POST kbn:/api/actions/connector/$CONNECTOR_ID/_execute { "params": { "subAction": "getAgents", "subActionParams": {} } } ``` 3. Run it again but replace the `subAction` with `isolateHost`. Verify that you get an unauthorized error. **Rule API and Feature Configuration Updates** 1. 1. Enable the EDR connectors privilege in the role you created above and log in as the user you created above. 2. Go to Stack Management 3. Try to create a rule, and verify that you don't see the SentinelOne connector. 4. Try to create a rule using the API and add your SentinelOne connector, verify that the API throws an error. ``` POST kbn:/api/alerting/rule { "tags": [], "params": {}, "schedule": { "interval": "1m" }, "consumer": "alerts", "name": "Always firing rule", "rule_type_id": "example.always-firing", "actions": [ { "group": "small", "id": "$CONNECTOR_ID", "params": { "subAction": "isolateAgent", "subActionParams": {} }, "frequency": { "notify_when": "onActionGroupChange", "throttle": null, "summary": false } } ], "alert_delay": { "active": 1 } } ``` 5. You can test the same behaviors when trying to add a SentinelOne connector to existing rules. --------- Co-authored-by: kibanamachine <[email protected]>
1 parent 5409631 commit 23a5c6d

File tree

49 files changed

+790
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+790
-286
lines changed

src/platform/packages/shared/kbn-actions-types/action_types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
import type { LicenseType } from '@kbn/licensing-plugin/common/types';
1111

12+
export enum SUB_FEATURE {
13+
endpointSecurity,
14+
}
15+
export type SubFeature = keyof typeof SUB_FEATURE;
16+
1217
export interface ActionType {
1318
id: string;
1419
name: string;
@@ -18,4 +23,5 @@ export interface ActionType {
1823
minimumLicenseRequired: LicenseType;
1924
supportedFeatureIds: string[];
2025
isSystemActionType: boolean;
26+
subFeature?: SubFeature;
2127
}

src/platform/packages/shared/kbn-alerts-ui-shared/src/common/apis/fetch_connector_types/transform_connector_types_response.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('transformConnectorTypesResponse', () => {
2121
minimum_license_required: 'basic',
2222
supported_feature_ids: ['stackAlerts'],
2323
is_system_action_type: true,
24+
sub_feature: 'endpointSecurity',
2425
},
2526
{
2627
id: 'actionType2Id',
@@ -44,6 +45,7 @@ describe('transformConnectorTypesResponse', () => {
4445
minimumLicenseRequired: 'basic',
4546
supportedFeatureIds: ['stackAlerts'],
4647
isSystemActionType: true,
48+
subFeature: 'endpointSecurity',
4749
},
4850
{
4951
id: 'actionType2Id',

src/platform/packages/shared/kbn-alerts-ui-shared/src/common/apis/fetch_connector_types/transform_connector_types_response.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ const transformConnectorType: RewriteRequestCase<ActionType> = ({
1515
minimum_license_required: minimumLicenseRequired,
1616
supported_feature_ids: supportedFeatureIds,
1717
is_system_action_type: isSystemActionType,
18+
sub_feature: subFeature,
1819
...res
1920
}: AsApiContract<ActionType>) => ({
2021
enabledInConfig,
2122
enabledInLicense,
2223
minimumLicenseRequired,
2324
supportedFeatureIds,
2425
isSystemActionType,
26+
subFeature,
2527
...res,
2628
});
2729

src/platform/packages/shared/kbn-alerts-ui-shared/src/common/types/action_types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { ComponentType, ReactNode } from 'react';
1111
import type { RuleActionParam, ActionVariable } from '@kbn/alerting-types';
1212
import { IconType, RecursivePartial } from '@elastic/eui';
1313
import { PublicMethodsOf } from '@kbn/utility-types';
14+
import { SubFeature } from '@kbn/actions-types';
1415
import { TypeRegistry } from '../type_registry';
1516
import { RuleFormParamsErrors } from './rule_types';
1617

@@ -130,6 +131,7 @@ export interface ActionTypeModel<ActionConfig = any, ActionSecrets = any, Action
130131
hideInUi?: boolean;
131132
modalWidth?: number;
132133
isSystemActionType?: boolean;
134+
subFeature?: SubFeature;
133135
}
134136

135137
export type ActionTypeRegistryContract<Connector = unknown, Params = unknown> = PublicMethodsOf<

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/mock/connectors.ts

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const mockActionTypes = [
1818
minimumLicenseRequired: 'basic',
1919
isSystemActionType: true,
2020
supportedFeatureIds: ['generativeAI'],
21+
subFeature: undefined,
2122
} as ActionType,
2223
{
2324
id: '.bedrock',
@@ -28,6 +29,7 @@ export const mockActionTypes = [
2829
minimumLicenseRequired: 'basic',
2930
isSystemActionType: true,
3031
supportedFeatureIds: ['generativeAI'],
32+
subFeature: undefined,
3133
} as ActionType,
3234
{
3335
id: '.gemini',
@@ -38,6 +40,7 @@ export const mockActionTypes = [
3840
minimumLicenseRequired: 'basic',
3941
isSystemActionType: true,
4042
supportedFeatureIds: ['generativeAI'],
43+
subFeature: undefined,
4144
} as ActionType,
4245
];
4346

x-pack/platform/plugins/shared/actions/common/connector_feature_config.ts

+15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export const SecurityConnectorFeatureId = 'siem';
2828
export const GenerativeAIForSecurityConnectorFeatureId = 'generativeAIForSecurity';
2929
export const GenerativeAIForObservabilityConnectorFeatureId = 'generativeAIForObservability';
3030
export const GenerativeAIForSearchPlaygroundConnectorFeatureId = 'generativeAIForSearchPlayground';
31+
export const EndpointSecurityConnectorFeatureId = 'endpointSecurity';
32+
33+
const compatibilityEndpointSecurity = i18n.translate(
34+
'xpack.actions.availableConnectorFeatures.compatibility.endpointSecurity',
35+
{
36+
defaultMessage: 'Endpoint Security',
37+
}
38+
);
3139

3240
const compatibilityGenerativeAIForSecurity = i18n.translate(
3341
'xpack.actions.availableConnectorFeatures.compatibility.generativeAIForSecurity',
@@ -120,6 +128,12 @@ export const GenerativeAIForSearchPlaygroundFeature: ConnectorFeatureConfig = {
120128
compatibility: compatibilityGenerativeAIForSearchPlayground,
121129
};
122130

131+
export const EndpointSecurityConnectorFeature: ConnectorFeatureConfig = {
132+
id: EndpointSecurityConnectorFeatureId,
133+
name: compatibilityEndpointSecurity,
134+
compatibility: compatibilityEndpointSecurity,
135+
};
136+
123137
const AllAvailableConnectorFeatures = {
124138
[AlertingConnectorFeature.id]: AlertingConnectorFeature,
125139
[CasesConnectorFeature.id]: CasesConnectorFeature,
@@ -128,6 +142,7 @@ const AllAvailableConnectorFeatures = {
128142
[GenerativeAIForSecurityFeature.id]: GenerativeAIForSecurityFeature,
129143
[GenerativeAIForObservabilityFeature.id]: GenerativeAIForObservabilityFeature,
130144
[GenerativeAIForSearchPlaygroundFeature.id]: GenerativeAIForSearchPlaygroundFeature,
145+
[EndpointSecurityConnectorFeature.id]: EndpointSecurityConnectorFeature,
131146
};
132147

133148
export function areValidFeatures(ids: string[]) {

x-pack/platform/plugins/shared/actions/common/routes/connector/response/schemas/v1.ts

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ export const connectorTypesResponseSchema = schema.object({
9797
is_system_action_type: schema.boolean({
9898
meta: { description: 'Indicates whether the action is a system action.' },
9999
}),
100+
sub_feature: schema.maybe(
101+
schema.oneOf([schema.literal('endpointSecurity')], {
102+
meta: {
103+
description: 'Indicates the sub-feature type the connector is grouped under.',
104+
},
105+
})
106+
),
100107
});
101108

102109
export const connectorExecuteResponseSchema = schema.object({

x-pack/platform/plugins/shared/actions/common/routes/connector/response/types/v1.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface ConnectorTypesResponse {
4141
minimum_license_required: ConnectorTypesResponseSchemaType['minimum_license_required'];
4242
supported_feature_ids: ConnectorTypesResponseSchemaType['supported_feature_ids'];
4343
is_system_action_type: ConnectorTypesResponseSchemaType['is_system_action_type'];
44+
sub_feature?: ConnectorTypesResponseSchemaType['sub_feature'];
4445
}
4546

4647
type ConnectorExecuteResponseSchemaType = TypeOf<typeof connectorExecuteResponseSchema>;

x-pack/platform/plugins/shared/actions/common/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* 2.0.
66
*/
77

8+
import { SUB_FEATURE } from '@kbn/actions-types';
89
import { LicenseType } from '@kbn/licensing-plugin/common/types';
910
import { TaskErrorSource } from '@kbn/task-manager-plugin/common';
1011

@@ -15,6 +16,9 @@ export {
1516
SecurityConnectorFeatureId,
1617
GenerativeAIForSecurityConnectorFeatureId,
1718
} from './connector_feature_config';
19+
20+
export type SubFeature = keyof typeof SUB_FEATURE;
21+
1822
export interface ActionType {
1923
id: string;
2024
name: string;
@@ -24,6 +28,7 @@ export interface ActionType {
2428
minimumLicenseRequired: LicenseType;
2529
supportedFeatureIds: string[];
2630
isSystemActionType: boolean;
31+
subFeature?: SubFeature;
2732
}
2833

2934
export enum InvalidEmailReason {

x-pack/platform/plugins/shared/actions/server/action_type_registry.mock.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const createActionTypeRegistryMock = () => {
1919
isActionExecutable: jest.fn(),
2020
isSystemActionType: jest.fn(),
2121
getUtils: jest.fn(),
22-
getSystemActionKibanaPrivileges: jest.fn(),
22+
getActionKibanaPrivileges: jest.fn(),
23+
hasSubFeature: jest.fn(),
2324
};
2425
return mocked;
2526
};

0 commit comments

Comments
 (0)