import { schema } from '@kbn/config-schema' ; import { PLUGIN_ID , OSQUERY_INTEGRATION_NAME } from '../../../common' ; import { IRouter } from '../../../../../../src/core/server' ; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../fleet/common' ; import { OsqueryAppContext } from '../../lib/osquery_app_context_services' ; export const getPackagePoliciesRoute = ( router , osqueryContext ) => { router . get ( { path : '/internal/osquery/fleet_wrapper/package_policies' , validate : { query : schema . object ( { } , { unknowns : 'allow' } ) , } , options : { tags : [ `access:${ PLUGIN_ID }-read` ] } , } , async ( context , request , response ) => { const kuery = `${ PACKAGE_POLICY_SAVED_OBJECT_TYPE }.attributes.package.name: ${ OSQUERY_INTEGRATION_NAME }` ; const packagePolicyService = osqueryContext . service . getPackagePolicyService ( ) ; const policies = await packagePolicyService ?. list ( context . core . savedObjects . client , { kuery , } ) ; return response . ok ( { body : policies , } ) ; } ) ; } ;