@@ -52,6 +52,16 @@ export const ELASTIC_CONNECTORS_INDEX_PERMISSIONS = [
5252 'view_index_metadata' ,
5353] ;
5454
55+ export const AGENTLESS_INDEX_PERMISSIONS = [
56+ 'read' ,
57+ 'write' ,
58+ 'monitor' ,
59+ 'create_index' ,
60+ 'auto_configure' ,
61+ 'maintenance' ,
62+ 'view_index_metadata' ,
63+ ] ;
64+
5565export function storedPackagePoliciesToAgentPermissions (
5666 packageInfoCache : Map < string , PackageInfo > ,
5767 agentPolicyNamespace : string ,
@@ -173,13 +183,10 @@ export function storedPackagePoliciesToAgentPermissions(
173183 }
174184 // namespace is either the package policy's or the agent policy one
175185 const namespace = packagePolicy ?. namespace || agentPolicyNamespace ;
176- return [
177- packagePolicy . id ,
178- {
179- indices : dataStreamsForPermissions . map ( ( ds ) => getDataStreamPrivileges ( ds , namespace ) ) ,
180- ...clusterRoleDescriptor ,
181- } ,
182- ] ;
186+ return maybeAddAgentlessPermissions ( packagePolicy , {
187+ indices : dataStreamsForPermissions . map ( ( ds ) => getDataStreamPrivileges ( ds , namespace ) ) ,
188+ ...clusterRoleDescriptor ,
189+ } ) ;
183190 } ) ;
184191
185192 return Object . fromEntries ( permissionEntries ) ;
@@ -244,6 +251,20 @@ function universalProfilingPermissions(packagePolicyId: string): [string, Securi
244251 ] ;
245252}
246253
254+ function maybeAddAgentlessPermissions (
255+ packagePolicy : PackagePolicy ,
256+ existing : SecurityRoleDescriptor
257+ ) : [ string , SecurityRoleDescriptor ] {
258+ if ( ! packagePolicy . supports_agentless ) {
259+ return [ packagePolicy . id , existing ] ;
260+ }
261+ existing . indices ! . push ( {
262+ names : [ 'agentless-*' ] ,
263+ privileges : AGENTLESS_INDEX_PERMISSIONS ,
264+ } ) ;
265+ return [ packagePolicy . id , existing ] ;
266+ }
267+
247268function apmPermissions ( packagePolicyId : string ) : [ string , SecurityRoleDescriptor ] {
248269 return [
249270 packagePolicyId ,
0 commit comments