import { OSQUERY_INTEGRATION_NAME , PLUGIN_ID } from '../../../common' ; import { IRouter } from '../../../../../../src/core/server' ; import { OsqueryAppContext } from '../../lib/osquery_app_context_services' ; export const privilegesCheckRoute = ( router , osqueryContext ) => { router . get ( { path : '/internal/osquery/privileges_check' , validate : { } , options : { tags : [ `access:${ PLUGIN_ID }-readLiveQueries` ] , } , } , async ( context , request , response ) => { if ( osqueryContext . security . authz . mode . useRbacForRequest ( request ) ) { const checkPrivileges = osqueryContext . security . authz . checkPrivilegesDynamicallyWithRequest ( request ) ; const { hasAllRequested } = await checkPrivileges ( { elasticsearch : { cluster : [ ] , index : { [ `logs-${ OSQUERY_INTEGRATION_NAME }.result*` ] : [ 'read' ] , } , } , } ) ; return response . ok ( { body : `${ hasAllRequested }` , } ) ; } return response . ok ( { body : 'true' , } ) ; } ) ; } ;