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

[ResponseOps] Granular Connector RBAC #203503

Merged
merged 59 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
36a8907
Adding EDR feature privilege
doakalexi Oct 22, 2024
fdf7212
Updating the ui
doakalexi Oct 23, 2024
5384fa9
Rename to action instead of connector
doakalexi Oct 23, 2024
96ccb6d
Fix boolean
doakalexi Oct 23, 2024
c274951
Removing changes from email connector
doakalexi Oct 23, 2024
4f29da8
Updating canExecute
doakalexi Oct 23, 2024
ef4ba21
Merge branch 'main' into poc/connector-rbac
doakalexi Oct 23, 2024
5b79db1
Merge branch 'main' of github.com:elastic/kibana into poc/connector-rbac
doakalexi Nov 19, 2024
30c7260
Fixing a bad change from merge conflicts
doakalexi Nov 19, 2024
3e5f43f
Update EDR connectors to only allow testing for one sub action
doakalexi Nov 22, 2024
394a8af
Adding validation to rule creation
doakalexi Dec 3, 2024
a5cefc0
Merge branch 'main' of github.com:elastic/kibana into poc/connector-rbac
doakalexi Dec 3, 2024
613381a
Removing changes from merge conflicts
doakalexi Dec 3, 2024
6403e6b
Adding api key info to the event log
doakalexi Dec 3, 2024
a2d2079
Removing some changes that arent needed
doakalexi Dec 4, 2024
372012a
Removing consumer
doakalexi Dec 4, 2024
243cacc
Adding back rbac
doakalexi Dec 4, 2024
bf19980
Fixing typo
doakalexi Dec 5, 2024
be23b06
Merge branch 'main' of github.com:elastic/kibana into poc/connector-rbac
doakalexi Dec 9, 2024
5a7b3dd
Creating a new sub-feature field in the connector type
doakalexi Dec 9, 2024
7b34ca5
Adding back the api key
doakalexi Dec 10, 2024
68dc60f
Adding tests
doakalexi Dec 11, 2024
3830696
Removing api key code
doakalexi Dec 12, 2024
f7c006d
Adding functional tests
doakalexi Dec 12, 2024
886abec
Merge branch 'main' of github.com:elastic/kibana into connector-rbac
doakalexi Dec 12, 2024
3e4853d
Updating the subfeaturetype
doakalexi Dec 12, 2024
e40c39a
Fixing lint
doakalexi Dec 12, 2024
cf0884a
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 12, 2024
cf1b80c
Removing circular dependency
doakalexi Dec 13, 2024
524649b
Merge branch 'main' of github.com:elastic/kibana into connector-rbac
doakalexi Dec 13, 2024
68d725f
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 13, 2024
8f11152
Merge branch 'main' of github.com:elastic/kibana into connector-rbac
doakalexi Dec 13, 2024
d29771b
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Dec 13, 2024
2fad33b
Removing from tsconfig
doakalexi Dec 13, 2024
cb380ea
Fixing type check failures
doakalexi Dec 13, 2024
36c03ab
Fixing type check again
doakalexi Dec 13, 2024
936cab9
Fixing test failures
doakalexi Dec 13, 2024
0903096
Merge branch 'main' into connector-rbac
doakalexi Dec 13, 2024
2151a50
Fixing update rule tests
doakalexi Dec 16, 2024
988484c
Removing UI changes
doakalexi Dec 16, 2024
cde862f
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Dec 16, 2024
71ba4f9
Merge branch 'main' into connector-rbac
doakalexi Dec 16, 2024
923fc9a
Fixing bulk edit test
doakalexi Dec 16, 2024
b60de78
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Dec 16, 2024
60b0f65
Merge branch 'main' into connector-rbac
doakalexi Dec 16, 2024
11ad095
Fixing ai assistant privileges tests
doakalexi Dec 16, 2024
12a0c82
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Dec 16, 2024
f62d3e8
Removing so from subfeature
doakalexi Dec 19, 2024
83203e5
Merge branch 'main' into connector-rbac
doakalexi Dec 19, 2024
09f56a5
Merge branch 'main' of github.com:elastic/kibana into connector-rbac
doakalexi Dec 19, 2024
d12aa20
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Dec 19, 2024
7d000b3
Merge branch 'main' into connector-rbac
doakalexi Dec 26, 2024
a0a14ac
Merge branch 'main' of github.com:elastic/kibana into connector-rbac
doakalexi Dec 30, 2024
be33125
Merge branch 'main' into connector-rbac
doakalexi Jan 2, 2025
aa216e6
Renaming from PR feedback
doakalexi Jan 6, 2025
b1701a9
Merge branch 'main' into connector-rbac
doakalexi Jan 6, 2025
c8754b9
Fixing test failure
doakalexi Jan 6, 2025
6855741
Merge branch 'connector-rbac' of github.com:doakalexi/kibana into con…
doakalexi Jan 6, 2025
66103c8
Fixing test failure
doakalexi Jan 6, 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 @@ -9,10 +9,10 @@

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

export enum SUB_FEATURE_TYPE {
edr,
export enum SUB_FEATURE {
endpointSecurity,
}
export type SubFeatureType = keyof typeof SUB_FEATURE_TYPE;
export type SubFeature = keyof typeof SUB_FEATURE;

export interface ActionType {
id: string;
Expand All @@ -23,5 +23,5 @@ export interface ActionType {
minimumLicenseRequired: LicenseType;
supportedFeatureIds: string[];
isSystemActionType: boolean;
subFeatureType?: SubFeatureType;
subFeature?: SubFeature;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('transformConnectorTypesResponse', () => {
minimum_license_required: 'basic',
supported_feature_ids: ['stackAlerts'],
is_system_action_type: true,
sub_feature_type: 'edr',
sub_feature: 'endpointSecurity',
},
{
id: 'actionType2Id',
Expand All @@ -45,7 +45,7 @@ describe('transformConnectorTypesResponse', () => {
minimumLicenseRequired: 'basic',
supportedFeatureIds: ['stackAlerts'],
isSystemActionType: true,
subFeatureType: 'edr',
subFeature: 'endpointSecurity',
},
{
id: 'actionType2Id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const transformConnectorType: RewriteRequestCase<ActionType> = ({
minimum_license_required: minimumLicenseRequired,
supported_feature_ids: supportedFeatureIds,
is_system_action_type: isSystemActionType,
sub_feature_type: subFeatureType,
sub_feature: subFeature,
...res
}: AsApiContract<ActionType>) => ({
enabledInConfig,
enabledInLicense,
minimumLicenseRequired,
supportedFeatureIds,
isSystemActionType,
subFeatureType,
subFeature,
...res,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ComponentType, ReactNode } from 'react';
import type { RuleActionParam, ActionVariable } from '@kbn/alerting-types';
import { IconType, RecursivePartial } from '@elastic/eui';
import { PublicMethodsOf } from '@kbn/utility-types';
import { SubFeatureType } from '@kbn/actions-types';
import { SubFeature } from '@kbn/actions-types';
import { TypeRegistry } from '../type_registry';
import { RuleFormParamsErrors } from './rule_types';

Expand Down Expand Up @@ -131,7 +131,7 @@ export interface ActionTypeModel<ActionConfig = any, ActionSecrets = any, Action
hideInUi?: boolean;
modalWidth?: number;
isSystemActionType?: boolean;
subFeatureType?: SubFeatureType;
subFeature?: SubFeature;
}

export type ActionTypeRegistryContract<Connector = unknown, Params = unknown> = PublicMethodsOf<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const mockActionTypes = [
minimumLicenseRequired: 'basic',
isSystemActionType: true,
supportedFeatureIds: ['generativeAI'],
subFeatureType: undefined,
subFeature: undefined,
} as ActionType,
{
id: '.bedrock',
Expand All @@ -29,7 +29,7 @@ export const mockActionTypes = [
minimumLicenseRequired: 'basic',
isSystemActionType: true,
supportedFeatureIds: ['generativeAI'],
subFeatureType: undefined,
subFeature: undefined,
} as ActionType,
{
id: '.gemini',
Expand All @@ -40,7 +40,7 @@ export const mockActionTypes = [
minimumLicenseRequired: 'basic',
isSystemActionType: true,
supportedFeatureIds: ['generativeAI'],
subFeatureType: undefined,
subFeature: undefined,
} as ActionType,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export const SecurityConnectorFeatureId = 'siem';
export const GenerativeAIForSecurityConnectorFeatureId = 'generativeAIForSecurity';
export const GenerativeAIForObservabilityConnectorFeatureId = 'generativeAIForObservability';
export const GenerativeAIForSearchPlaygroundConnectorFeatureId = 'generativeAIForSearchPlayground';
export const EdrConnectorFeatureId = 'edr';
export const EndpointSecurityConnectorFeatureId = 'endpointSecurity';

const compatibilityEdr = i18n.translate(
'xpack.actions.availableConnectorFeatures.compatibility.edr',
const compatibilityEndpointSecurity = i18n.translate(
'xpack.actions.availableConnectorFeatures.compatibility.endpointSecurity',
{
defaultMessage: 'Endpoint Security',
}
Expand Down Expand Up @@ -128,10 +128,10 @@ export const GenerativeAIForSearchPlaygroundFeature: ConnectorFeatureConfig = {
compatibility: compatibilityGenerativeAIForSearchPlayground,
};

export const EdrConnectorFeature: ConnectorFeatureConfig = {
id: EdrConnectorFeatureId,
name: compatibilityEdr,
compatibility: compatibilityEdr,
export const EndpointSecurityConnectorFeature: ConnectorFeatureConfig = {
id: EndpointSecurityConnectorFeatureId,
name: compatibilityEndpointSecurity,
compatibility: compatibilityEndpointSecurity,
};

const AllAvailableConnectorFeatures = {
Expand All @@ -142,7 +142,7 @@ const AllAvailableConnectorFeatures = {
[GenerativeAIForSecurityFeature.id]: GenerativeAIForSecurityFeature,
[GenerativeAIForObservabilityFeature.id]: GenerativeAIForObservabilityFeature,
[GenerativeAIForSearchPlaygroundFeature.id]: GenerativeAIForSearchPlaygroundFeature,
[EdrConnectorFeature.id]: EdrConnectorFeature,
[EndpointSecurityConnectorFeature.id]: EndpointSecurityConnectorFeature,
};

export function areValidFeatures(ids: string[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const connectorTypesResponseSchema = schema.object({
is_system_action_type: schema.boolean({
meta: { description: 'Indicates whether the action is a system action.' },
}),
sub_feature_type: schema.maybe(
schema.oneOf([schema.literal('edr')], {
sub_feature: schema.maybe(
schema.oneOf([schema.literal('endpointSecurity')], {
meta: {
description: 'Indicates the sub-feature type the connector is grouped under.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface ConnectorTypesResponse {
minimum_license_required: ConnectorTypesResponseSchemaType['minimum_license_required'];
supported_feature_ids: ConnectorTypesResponseSchemaType['supported_feature_ids'];
is_system_action_type: ConnectorTypesResponseSchemaType['is_system_action_type'];
sub_feature_type?: ConnectorTypesResponseSchemaType['sub_feature_type'];
sub_feature?: ConnectorTypesResponseSchemaType['sub_feature'];
}

type ConnectorExecuteResponseSchemaType = TypeOf<typeof connectorExecuteResponseSchema>;
Expand Down
6 changes: 3 additions & 3 deletions x-pack/platform/plugins/shared/actions/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SUB_FEATURE_TYPE } from '@kbn/actions-types';
import { SUB_FEATURE } from '@kbn/actions-types';
import { LicenseType } from '@kbn/licensing-plugin/common/types';
import { TaskErrorSource } from '@kbn/task-manager-plugin/common';

Expand All @@ -17,7 +17,7 @@ export {
GenerativeAIForSecurityConnectorFeatureId,
} from './connector_feature_config';

export type SubFeatureType = keyof typeof SUB_FEATURE_TYPE;
export type SubFeature = keyof typeof SUB_FEATURE;

export interface ActionType {
id: string;
Expand All @@ -28,7 +28,7 @@ export interface ActionType {
minimumLicenseRequired: LicenseType;
supportedFeatureIds: string[];
isSystemActionType: boolean;
subFeatureType?: SubFeatureType;
subFeature?: SubFeature;
}

export enum InvalidEmailReason {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createActionTypeRegistryMock = () => {
isSystemActionType: jest.fn(),
getUtils: jest.fn(),
getActionKibanaPrivileges: jest.fn(),
hasSubFeatureType: jest.fn(),
hasSubFeature: jest.fn(),
};
return mocked;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,13 @@ describe('actionTypeRegistry', () => {
]);
});

test('sets the subFeatureType correctly for sub-feature type actions', () => {
test('sets the subFeature correctly for sub-feature type actions', () => {
mockedLicenseState.isLicenseValidForActionType.mockReturnValue({ isValid: true });
const actionTypeRegistry = new ActionTypeRegistry(actionTypeRegistryParams);

actionTypeRegistry.register({
id: 'test.sub-feature-action',
name: 'EDR',
name: 'Test',
minimumLicenseRequired: 'platinum',
supportedFeatureIds: ['siem'],
getKibanaPrivileges: () => ['test/create-sub-feature'],
Expand All @@ -437,7 +437,7 @@ describe('actionTypeRegistry', () => {
secrets: { schema: schema.object({}) },
params: { schema: schema.object({}) },
},
subFeatureType: 'edr',
subFeature: 'endpointSecurity',
executor,
});

Expand All @@ -451,8 +451,8 @@ describe('actionTypeRegistry', () => {
id: 'test.sub-feature-action',
isSystemActionType: false,
minimumLicenseRequired: 'platinum',
name: 'EDR',
subFeatureType: 'edr',
name: 'Test',
subFeature: 'endpointSecurity',
supportedFeatureIds: ['siem'],
},
]);
Expand Down Expand Up @@ -803,13 +803,13 @@ describe('actionTypeRegistry', () => {
});
});

describe('hasSubFeatureType()', () => {
describe('hasSubFeature()', () => {
it('should return true if the action type has a sub-feature type', () => {
const registry = new ActionTypeRegistry(actionTypeRegistryParams);

registry.register({
id: 'test.sub-feature-action',
name: 'EDR',
name: 'Test',
minimumLicenseRequired: 'platinum',
supportedFeatureIds: ['siem'],
getKibanaPrivileges: () => ['test/create-sub-feature'],
Expand All @@ -818,11 +818,11 @@ describe('actionTypeRegistry', () => {
secrets: { schema: schema.object({}) },
params: { schema: schema.object({}) },
},
subFeatureType: 'edr',
subFeature: 'endpointSecurity',
executor,
});

const result = registry.hasSubFeatureType('test.sub-feature-action');
const result = registry.hasSubFeature('test.sub-feature-action');
expect(result).toBe(true);
});

Expand All @@ -847,7 +847,7 @@ describe('actionTypeRegistry', () => {
const allTypes = registry.getAllTypes();
expect(allTypes.length).toBe(1);

const result = registry.hasSubFeatureType('foo');
const result = registry.hasSubFeature('foo');
expect(result).toBe(false);
});

Expand All @@ -857,7 +857,7 @@ describe('actionTypeRegistry', () => {
const allTypes = registry.getAllTypes();
expect(allTypes.length).toBe(0);

const result = registry.hasSubFeatureType('not-exist');
const result = registry.hasSubFeature('not-exist');
expect(result).toBe(false);
});
});
Expand All @@ -882,7 +882,7 @@ describe('actionTypeRegistry', () => {
});
registry.register({
id: 'test.sub-feature-action',
name: 'EDR',
name: 'Test',
minimumLicenseRequired: 'platinum',
supportedFeatureIds: ['siem'],
getKibanaPrivileges: () => ['test/create-sub-feature'],
Expand All @@ -891,7 +891,7 @@ describe('actionTypeRegistry', () => {
secrets: { schema: schema.object({}) },
params: { schema: schema.object({}) },
},
subFeatureType: 'edr',
subFeature: 'endpointSecurity',
executor,
});

Expand Down Expand Up @@ -919,15 +919,15 @@ describe('actionTypeRegistry', () => {
});
registry.register({
id: 'test.sub-feature-action',
name: 'EDR',
name: 'Test',
minimumLicenseRequired: 'platinum',
supportedFeatureIds: ['siem'],
validate: {
config: { schema: schema.object({}) },
secrets: { schema: schema.object({}) },
params: { schema: schema.object({}) },
},
subFeatureType: 'edr',
subFeature: 'endpointSecurity',
executor,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export class ActionTypeRegistry {
/**
* Returns true if the connector type has a sub-feature type defined
*/
public hasSubFeatureType = (actionTypeId: string): boolean =>
Boolean(this.actionTypes.get(actionTypeId)?.subFeatureType);
public hasSubFeature = (actionTypeId: string): boolean =>
Boolean(this.actionTypes.get(actionTypeId)?.subFeature);

/**
* Returns the kibana privileges
Expand All @@ -132,7 +132,7 @@ export class ActionTypeRegistry {
): string[] {
const actionType = this.actionTypes.get(actionTypeId);

if (!actionType?.isSystemActionType && !actionType?.subFeatureType) {
if (!actionType?.isSystemActionType && !actionType?.subFeature) {
return [];
}
return actionType?.getKibanaPrivileges?.({ params, source }) ?? [];
Expand Down Expand Up @@ -187,7 +187,7 @@ export class ActionTypeRegistry {

if (
!actionType.isSystemActionType &&
!actionType.subFeatureType &&
!actionType.subFeature &&
actionType.getKibanaPrivileges
) {
throw new Error(
Expand Down Expand Up @@ -260,7 +260,7 @@ export class ActionTypeRegistry {
enabledInLicense: !!this.licenseState.isLicenseValidForActionType(actionType).isValid,
supportedFeatureIds: actionType.supportedFeatureIds,
isSystemActionType: !!actionType.isSystemActionType,
subFeatureType: actionType.subFeatureType,
subFeature: actionType.subFeature,
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export const connectorTypeSchema = schema.object({
]),
supportedFeatureIds: schema.arrayOf(schema.string()),
isSystemActionType: schema.boolean(),
subFeatureType: schema.maybe(schema.oneOf([schema.literal('edr')])),
subFeature: schema.maybe(schema.oneOf([schema.literal('endpointSecurity')])),
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export interface ConnectorType {
minimumLicenseRequired: ConnectorTypeSchemaType['minimumLicenseRequired'];
supportedFeatureIds: ConnectorTypeSchemaType['supportedFeatureIds'];
isSystemActionType: ConnectorTypeSchemaType['isSystemActionType'];
subFeatureType?: ConnectorTypeSchemaType['subFeatureType'];
subFeature?: ConnectorTypeSchemaType['subFeature'];
}
Loading