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

[Security Solution] Fix assistant settings availability for non-superuser role #182322

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d54982e
[Security AI Assistant] Improve clear conversation requests efficiency.
YulNaumenko Mar 28, 2024
37d4136
Merge remote-tracking branch 'upstream/main'
YulNaumenko Mar 29, 2024
9cbb124
Merge remote-tracking branch 'upstream/main'
YulNaumenko Apr 11, 2024
6bdfa7c
Merge remote-tracking branch 'upstream/main'
YulNaumenko Apr 23, 2024
845589c
Merge remote-tracking branch 'upstream/main'
YulNaumenko Apr 25, 2024
6f72d06
Merge remote-tracking branch 'upstream/main'
YulNaumenko Apr 29, 2024
38a4a33
Merge remote-tracking branch 'upstream/main'
YulNaumenko Apr 30, 2024
a19ec28
Merge remote-tracking branch 'upstream/main'
YulNaumenko May 1, 2024
95d84c4
[Security Solution] Fix assistant settings availability for non-super…
YulNaumenko May 2, 2024
445444f
fixed priviledges
YulNaumenko May 2, 2024
a050ffd
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 2, 2024
c16cc20
made features plugin optional
YulNaumenko May 2, 2024
be414d5
fixed ftr tests
YulNaumenko May 2, 2024
0867041
more tests
YulNaumenko May 2, 2024
1c34370
Merge branch 'main' into security-ai-assistant-setting-privilege-bug
YulNaumenko May 2, 2024
bc56a95
revert test fix
YulNaumenko May 2, 2024
f37afe6
Merge branch 'main' into security-ai-assistant-setting-privilege-bug
YulNaumenko May 2, 2024
9ccd510
Merge branch 'main' into security-ai-assistant-setting-privilege-bug
YulNaumenko May 2, 2024
296620c
Merge branch 'main' into security-ai-assistant-setting-privilege-bug
jbudz May 2, 2024
b8df2e4
Merge branch 'main' into security-ai-assistant-setting-privilege-bug
YulNaumenko May 2, 2024
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
1 change: 1 addition & 0 deletions packages/solution-nav/es/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const navTree: NavigationTreeDefinition = {
{ link: 'management:objects' },
{ link: 'management:tags' },
{ link: 'management:search_sessions' },
{ link: 'management:aiAssistantManagementSelection' },
{ link: 'management:spaces' },
{ link: 'management:settings' },
],
Expand Down
1 change: 1 addition & 0 deletions packages/solution-nav/oblt/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ const navTree: NavigationTreeDefinition = {
{ link: 'management:objects' },
{ link: 'management:tags' },
{ link: 'management:search_sessions' },
{ link: 'management:aiAssistantManagementSelection' },
{ link: 'management:spaces' },
{ link: 'management:settings' },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"server": true,
"browser": true,
"requiredPlugins": ["management"],
"optionalPlugins": ["home", "serverless"],
"optionalPlugins": ["home", "serverless", "features"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: cannot we make features plugin required?

"requiredBundles": ["kibanaReact"],
"configPath": [
"aiAssistantManagementSelection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AIAssistantManagementPlugin
defaultMessage: 'Manage your AI Assistants.',
}),
icon: 'sparkles',
path: '/app/management/kibana/ai-assistant',
path: '/app/management/kibana/aiAssistantManagementSelection',
showOnHomePage: false,
category: 'admin',
});
Expand Down
71 changes: 69 additions & 2 deletions src/plugins/ai_assistant_management/selection/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
import { schema } from '@kbn/config-schema';
import type { AIAssistantManagementSelectionConfig } from './config';
import type {
AIAssistantManagementSelectionPluginServerDependenciesSetup,
AIAssistantManagementSelectionPluginServerDependenciesStart,
AIAssistantManagementSelectionPluginServerSetup,
AIAssistantManagementSelectionPluginServerStart,
} from './types';
Expand All @@ -27,7 +29,9 @@ export class AIAssistantManagementSelectionPlugin
implements
Plugin<
AIAssistantManagementSelectionPluginServerSetup,
AIAssistantManagementSelectionPluginServerStart
AIAssistantManagementSelectionPluginServerStart,
AIAssistantManagementSelectionPluginServerDependenciesSetup,
AIAssistantManagementSelectionPluginServerDependenciesStart
>
{
private readonly config: AIAssistantManagementSelectionConfig;
Expand All @@ -36,7 +40,10 @@ export class AIAssistantManagementSelectionPlugin
this.config = initializerContext.config.get();
}

public setup(core: CoreSetup) {
public setup(
core: CoreSetup,
plugins: AIAssistantManagementSelectionPluginServerDependenciesSetup
) {
core.uiSettings.register({
[PREFERRED_AI_ASSISTANT_TYPE_SETTING_KEY]: {
name: i18n.translate('aiAssistantManagementSelection.preferredAIAssistantTypeSettingName', {
Expand Down Expand Up @@ -79,6 +86,66 @@ export class AIAssistantManagementSelectionPlugin
},
});

core.capabilities.registerProvider(() => {
Copy link
Member

@azasypkin azasypkin May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: forgot to comment on this one yesterday - I don't think we need this here - I believe it's only needed when the feature/plugin can be used with Elastic Stack security disabled which is unlikely to be the case for this plugin.

return {
management: {
kibana: {
aiAssistantManagementSelection: true,
observabilityAiAssistantManagement: true,
securityAiAssistantManagement: true,
},
},
};
});

plugins.features?.registerKibanaFeature({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I'm not sure if this plugin is enabled in Serverless, but if it's - should this feature be available in Serverless role management UI? If so, for which project types (Security, Search, Observability)?

id: 'aiAssistantManagementSelection',
name: i18n.translate('aiAssistantManagementSelection.featureRegistry.featureName', {
defaultMessage: 'AI Assistant',
}),
order: 8600,
app: [],
category: DEFAULT_APP_CATEGORIES.management,
management: {
kibana: [
'aiAssistantManagementSelection',
'securityAiAssistantManagement',
'observabilityAiAssistantManagement',
],
},
minimumLicense: 'enterprise',
privileges: {
all: {
management: {
kibana: [
'aiAssistantManagementSelection',
'securityAiAssistantManagement',
'observabilityAiAssistantManagement',
],
},
savedObject: {
all: [],
read: [],
},
ui: [],
},
read: {
management: {
kibana: [
'aiAssistantManagementSelection',
'securityAiAssistantManagement',
'observabilityAiAssistantManagement',
],
},
savedObject: {
all: [],
read: [],
},
ui: [],
},
},
});

return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AIAssistantManagementSelectionPluginServerDependenciesStart {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AIAssistantManagementSelectionPluginServerDependenciesSetup {}
export interface AIAssistantManagementSelectionPluginServerDependenciesSetup {
features?: FeaturesPluginSetup;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AIAssistantManagementSelectionPluginServerStart {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@kbn/typed-react-router-config",
"@kbn/serverless",
"@kbn/config-schema",
"@kbn/core-plugins-server"
"@kbn/core-plugins-server",
"@kbn/features-plugin"
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const stackManagementLinks: Array<NodeDefinition<AppDeepLinkId, string, string>>
{ link: 'management:objects' },
{ link: 'management:tags' },
{ link: 'management:search_sessions' },
{ link: 'management:aiAssistantManagementSelection' },
{ link: 'management:spaces' },
{ link: 'management:settings' },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default function ({ getService }: FtrProviderContext) {
'filesManagement',
'filesSharedImage',
'advancedSettings',
'aiAssistantManagementSelection',
'indexPatterns',
'graph',
'guidedOnboardingFeature',
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/api_integration/apis/security/privileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default function ({ getService }: FtrProviderContext) {
],
maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'],
guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'],
aiAssistantManagementSelection: ['all', 'read', 'minimal_all', 'minimal_read'],
},
reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function ({ getService }: FtrProviderContext) {
rulesSettings: ['all', 'read', 'minimal_all', 'minimal_read'],
maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'],
guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'],
aiAssistantManagementSelection: ['all', 'read', 'minimal_all', 'minimal_read'],
},
global: ['all', 'read'],
space: ['all', 'read'],
Expand Down Expand Up @@ -217,6 +218,7 @@ export default function ({ getService }: FtrProviderContext) {
],
maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'],
guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'],
aiAssistantManagementSelection: ['all', 'read', 'minimal_all', 'minimal_read'],
},
reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
sectionLinks: [
'dataViews',
'filesManagement',
'aiAssistantManagementSelection',
'objects',
'tags',
'search_sessions',
Expand Down