diff --git a/CHANGELOG.md b/CHANGELOG.md index 90a450bb82..cb56195b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ All notable changes to the Wazuh app project will be documented in this file. - Changed the registration id of the Settings application for compatibility with Opensearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938) +### Removed + +- Removed agent RBAC filters from dashboard queries [#6945](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6945) + ## Wazuh v4.9.1 - OpenSearch Dashboards 2.13.0 - Revision 00 ### Added diff --git a/plugins/main/public/components/common/data-source/hooks/use-data-source.test.ts b/plugins/main/public/components/common/data-source/hooks/use-data-source.test.ts index e1d27f5616..700060835a 100644 --- a/plugins/main/public/components/common/data-source/hooks/use-data-source.test.ts +++ b/plugins/main/public/components/common/data-source/hooks/use-data-source.test.ts @@ -1,129 +1,130 @@ import { useDataSource } from './use-data-source'; import { renderHook } from '@testing-library/react-hooks'; -import { - tDataSourceRepository, - tFilter, - PatternDataSource, - tParsedIndexPattern +import { + tDataSourceRepository, + tFilter, + PatternDataSource, + tParsedIndexPattern, } from '../index'; -import { IndexPatternsService, IndexPattern } from '../../../../../../../src/plugins/data/common'; +import { + IndexPatternsService, + IndexPattern, +} from '../../../../../../../src/plugins/data/common'; jest.mock('../../../../kibana-services', () => ({ - ...(jest.requireActual('../../../../kibana-services') as object), - getDataPlugin: () => ({ - // mock indexPatterns getter - indexPatterns: { - get: jest.fn().mockResolvedValue({ - fields: { - replaceAll: jest.fn(), - map: jest.fn().mockReturnValue([]), - }, - getScriptedFields: jest.fn().mockReturnValue([]), - }), - getFieldsForIndexPattern: jest.fn().mockResolvedValue([]), - updateSavedObject: jest.fn().mockResolvedValue({}), + ...(jest.requireActual('../../../../kibana-services') as object), + getDataPlugin: () => ({ + // mock indexPatterns getter + indexPatterns: { + get: jest.fn().mockResolvedValue({ + fields: { + replaceAll: jest.fn(), + map: jest.fn().mockReturnValue([]), }, - query: { - filterManager: { - getFilters: jest.fn().mockReturnValue([]), - setFilters: jest.fn(), - getUpdates$: jest.fn().mockReturnValue({ - subscribe: jest.fn() - }) - } - } - }), + getScriptedFields: jest.fn().mockReturnValue([]), + }), + getFieldsForIndexPattern: jest.fn().mockResolvedValue([]), + updateSavedObject: jest.fn().mockResolvedValue({}), + }, + query: { + filterManager: { + getFilters: jest.fn().mockReturnValue([]), + setFilters: jest.fn(), + getUpdates$: jest.fn().mockReturnValue({ + subscribe: jest.fn(), + }), + }, + }, + }), })); const mockedGetFilters = jest.fn().mockReturnValue([]); class DataSourceMocked implements PatternDataSource { - constructor(public id: string, public title: string) { - this.id = id; - this.title = title; - } - fields: any[]; - patternService: IndexPatternsService; - indexPattern: IndexPattern; - defaultFixedFilters: tFilter[]; - filters: tFilter[]; - init = jest.fn(); - select = jest.fn(); - fetch = jest.fn(); - getFilters = mockedGetFilters; - setFilters = jest.fn(); - getFields = mockedGetFilters - getFixedFilters = mockedGetFilters - getFetchFilters = mockedGetFilters - toJSON(): tParsedIndexPattern { - return { - id: this.id, - title: this.title, - } as tParsedIndexPattern; - } - getClusterManagerFilters = mockedGetFilters - getPinnedAgentFilter = mockedGetFilters - getExcludeManagerFilter = mockedGetFilters - getAllowAgentsFilter = mockedGetFilters + constructor(public id: string, public title: string) { + this.id = id; + this.title = title; + } + fields: any[]; + patternService: IndexPatternsService; + indexPattern: IndexPattern; + defaultFixedFilters: tFilter[]; + filters: tFilter[]; + init = jest.fn(); + select = jest.fn(); + fetch = jest.fn(); + getFilters = mockedGetFilters; + setFilters = jest.fn(); + getFields = mockedGetFilters; + getFixedFilters = mockedGetFilters; + getFetchFilters = mockedGetFilters; + toJSON(): tParsedIndexPattern { + return { + id: this.id, + title: this.title, + } as tParsedIndexPattern; + } + getClusterManagerFilters = mockedGetFilters; + getPinnedAgentFilter = mockedGetFilters; + getExcludeManagerFilter = mockedGetFilters; } class ExampleRepository implements tDataSourceRepository { - getDefault = jest.fn(); - setDefault = jest.fn(); - get = jest.fn(); - getAll = jest.fn(); + getDefault = jest.fn(); + setDefault = jest.fn(); + get = jest.fn(); + getAll = jest.fn(); } describe('useDataSource hook', () => { + it('shoudl throw ERROR when the repository is not defined', () => { + try { + renderHook(() => + useDataSource({ + DataSource: DataSourceMocked, + repository: undefined as any, + }), + ); + } catch (error) { + expect(error).toBeDefined(); + expect(error.message).toBe('DataSource and repository are required'); + } + }); - it('shoudl throw ERROR when the repository is not defined', () => { - - try { - renderHook(() => useDataSource({ - DataSource: DataSourceMocked, - repository: undefined as any - })); - } catch(error){ - expect(error).toBeDefined(); - expect(error.message).toBe('DataSource and repository are required'); - } - - }) - - it('should throw ERROR when the DataSource is not defined', () => { - - try { - renderHook(() => useDataSource({ - DataSource: undefined as any, - repository: new ExampleRepository() - })); - } catch(error){ - expect(error).toBeDefined(); - expect(error.message).toBe('DataSource and repository are required'); - } - - }) - - // FIXME: - it.skip('should initialize the hook with only receiving the dataSource and repository', async () => { - const repository = new ExampleRepository(); - const indexMocked = { - id: 'test', - title: 'Test' - } - jest.spyOn(repository, 'getAll').mockResolvedValueOnce([indexMocked]); - jest.spyOn(repository, 'getDefault').mockResolvedValueOnce(indexMocked); - const { result, waitForNextUpdate } = renderHook(() => useDataSource({ - DataSource: DataSourceMocked, - repository - })); - // wait for the promise to resolve - await waitForNextUpdate(); - expect(result.current.isLoading).toBeFalsy(); - expect(result.current.dataSource).toBeDefined(); - expect(result.current.dataSource?.id).toBe('test'); - expect(result.current.dataSource?.title).toBe('Test'); - }) - + it('should throw ERROR when the DataSource is not defined', () => { + try { + renderHook(() => + useDataSource({ + DataSource: undefined as any, + repository: new ExampleRepository(), + }), + ); + } catch (error) { + expect(error).toBeDefined(); + expect(error.message).toBe('DataSource and repository are required'); + } + }); -}) + // FIXME: + it.skip('should initialize the hook with only receiving the dataSource and repository', async () => { + const repository = new ExampleRepository(); + const indexMocked = { + id: 'test', + title: 'Test', + }; + jest.spyOn(repository, 'getAll').mockResolvedValueOnce([indexMocked]); + jest.spyOn(repository, 'getDefault').mockResolvedValueOnce(indexMocked); + const { result, waitForNextUpdate } = renderHook(() => + useDataSource({ + DataSource: DataSourceMocked, + repository, + }), + ); + // wait for the promise to resolve + await waitForNextUpdate(); + expect(result.current.isLoading).toBeFalsy(); + expect(result.current.dataSource).toBeDefined(); + expect(result.current.dataSource?.id).toBe('test'); + expect(result.current.dataSource?.title).toBe('Test'); + }); +}); diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.test.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.test.ts index c1fe0a2e26..37e4374817 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.test.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.test.ts @@ -80,7 +80,6 @@ class DataSourceMocked implements PatternDataSource { getClusterManagerFilters = mockedGetFilters; getPinnedAgentFilter = mockedGetFilters; getExcludeManagerFilter = mockedGetFilters; - getAllowAgentsFilter = mockedGetFilters; } const createFilter = (id: string, value: string, index: string): tFilter => { @@ -374,27 +373,6 @@ describe('PatternDataSourceFilterManager', () => { expect(filter.length).toBe(0); }); - it('should return the filters to fetch the data merging the filters stored and the allowed agents filter', () => { - (store.getState as jest.Mock).mockReturnValue({ - appStateReducers: { - allowedAgents: ['001'], - }, - }); - const filter = - PatternDataSourceFilterManager.getAllowAgentsFilter('index-title'); - expect(filter.length).toBe(1); - expect(filter[0].meta.controlledBy).toBe(AUTHORIZED_AGENTS); - }); - - it('should return the filters to fetch the data merging the filters stored without the allowed agents filter when is not defined', () => { - (store.getState as jest.Mock).mockReturnValue({ - appStateReducers: {}, - }); - const filter = - PatternDataSourceFilterManager.getAllowAgentsFilter('index-title'); - expect(filter.length).toBe(0); - }); - // FIXME: it.skip('should return the fixed filters merged with the pinned agent filter when correspond', () => { // mock store.getState diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts index 90e13ac255..dc7c55130f 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts @@ -40,47 +40,6 @@ export function getFilterExcludeManager(indexPatternId: string) { }; } -/** - * Get the filter that restrict the search to the allowed agents - * @param agentsIds - * @param indexPatternId - * @returns - */ -export function getFilterAllowedAgents( - agentsIds: string[], - indexPatternId: string, -) { - const field = AGENT_ID_KEY; - return { - meta: { - index: indexPatternId, - type: 'phrases', - key: field, - value: agentsIds.toString(), - params: agentsIds, - alias: null, - negate: false, - disabled: false, - controlledBy: AUTHORIZED_AGENTS, - }, - query: { - bool: { - should: agentsIds.map(id => { - return { - match_phrase: { - [field]: id, - }, - }; - }), - minimum_should_match: 1, - }, - }, - $state: { - store: 'appState', - }, - }; -} - export enum FILTER_OPERATOR { IS = 'is', IS_NOT = 'is not', @@ -359,23 +318,6 @@ export class PatternDataSourceFilterManager return []; } - /** - * Return the allowed agents related to the user permissions to read data from agents in the - API server - */ - static getAllowAgentsFilter(indexPatternId: string): tFilter[] { - const allowedAgents = - store.getState().appStateReducers?.allowedAgents || []; - if (allowedAgents.length > 0) { - const allowAgentsFilter = getFilterAllowedAgents( - allowedAgents, - indexPatternId, - ) as tFilter; - return [allowAgentsFilter]; - } - return []; - } - /******************************************************************/ /********************** FILTERS FACTORY ***************************/ /******************************************************************/ diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-selector.test.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-selector.test.ts index 6e5f5599c6..8721b8e8eb 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-selector.test.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-selector.test.ts @@ -1,188 +1,201 @@ -import { IndexPatternsService, IndexPattern } from '../../../../../../../src/plugins/data/public'; import { - tDataSourceSelector, - tDataSourceRepository, - tParsedIndexPattern, - PatternDataSourceSelector, - PatternDataSource, - tFilter + IndexPatternsService, + IndexPattern, +} from '../../../../../../../src/plugins/data/public'; +import { + tDataSourceSelector, + tDataSourceRepository, + tParsedIndexPattern, + PatternDataSourceSelector, + PatternDataSource, + tFilter, } from '../index'; - const mockedGetFilters = jest.fn().mockReturnValue([]); class DataSourceMocked implements PatternDataSource { - constructor(public id: string, public title: string) { - this.id = id; - this.title = title; - } - fields: any[]; - patternService: IndexPatternsService; - indexPattern: IndexPattern; - defaultFixedFilters: tFilter[]; - filters: tFilter[]; - init = jest.fn(); - select = jest.fn(); - fetch = jest.fn(); - getFilters = mockedGetFilters; - setFilters = jest.fn(); - getFields = mockedGetFilters - getFixedFilters = mockedGetFilters - getFetchFilters = mockedGetFilters - toJSON(): tParsedIndexPattern { - return { - id: this.id, - title: this.title, - } as tParsedIndexPattern; - } - getClusterManagerFilters = mockedGetFilters - getPinnedAgentFilter = mockedGetFilters - getExcludeManagerFilter = mockedGetFilters - getAllowAgentsFilter = mockedGetFilters + constructor(public id: string, public title: string) { + this.id = id; + this.title = title; + } + fields: any[]; + patternService: IndexPatternsService; + indexPattern: IndexPattern; + defaultFixedFilters: tFilter[]; + filters: tFilter[]; + init = jest.fn(); + select = jest.fn(); + fetch = jest.fn(); + getFilters = mockedGetFilters; + setFilters = jest.fn(); + getFields = mockedGetFilters; + getFixedFilters = mockedGetFilters; + getFetchFilters = mockedGetFilters; + toJSON(): tParsedIndexPattern { + return { + id: this.id, + title: this.title, + } as tParsedIndexPattern; + } + getClusterManagerFilters = mockedGetFilters; + getPinnedAgentFilter = mockedGetFilters; + getExcludeManagerFilter = mockedGetFilters; } class ExampleRepository implements tDataSourceRepository { - getDefault = jest.fn(); - setDefault = jest.fn(); - get = jest.fn(); - getAll = jest.fn(); + getDefault = jest.fn(); + setDefault = jest.fn(); + get = jest.fn(); + getAll = jest.fn(); } const createListPatternsMocked = (qty: number) => { - const list: DataSourceMocked[] = []; - for (let i = 0; i < qty; i++) { - list.push(new DataSourceMocked(`id ${i.toString()}`, `title ${i}`)); - } - return list; -} + const list: DataSourceMocked[] = []; + for (let i = 0; i < qty; i++) { + list.push(new DataSourceMocked(`id ${i.toString()}`, `title ${i}`)); + } + return list; +}; let repository = new ExampleRepository(); let mockedList = createListPatternsMocked(3); describe('PatternDataSourceSelector', () => { - - afterEach(() => { - jest.clearAllMocks(); - }) - - describe('constructor', () => { - it('should return ERROR when the selector not receive a repository', () => { - try { - new PatternDataSourceSelector(mockedList, null as any); - } catch (error) { - expect(error.message).toBe('Data source repository is required'); - } - }) - - it('should return ERROR when the selector not receive a valid repository', () => { - try { - new PatternDataSourceSelector([], new ExampleRepository()); - } catch (error) { - expect(error.message).toBe('Data sources list is required'); - } - }) - - }) - - describe('existsDataSource', () => { - it('should return TRUE when the data source exists', async () => { - jest.spyOn(repository, 'get').mockResolvedValue({ id: '1', name: 'DataSource 1' }); - const selector = new PatternDataSourceSelector(mockedList, repository); - const result = await selector.existsDataSource('1'); - expect(result).toBe(true); - expect(repository.get).toHaveBeenCalledTimes(1); - }); - - it('should return FALSE when the data source does not exist', async () => { - jest.spyOn(repository, 'get').mockResolvedValue(null); - const selector = new PatternDataSourceSelector(mockedList, repository); - const result = await selector.existsDataSource('fake-id'); - expect(result).toBe(false); - expect(repository.get).toHaveBeenCalledTimes(1); - }); - - it('should throw ERROR when not receive an id', async () => { - jest.spyOn(repository, 'get').mockResolvedValue(null); - try { - let selector = new PatternDataSourceSelector(mockedList, repository); - await selector.existsDataSource(null as any); - }catch(error){ - expect(error.message).toBe('Error checking data source. ID is required'); - } - }); - }) - - describe('getFirstValidDataSource', () => { - it('should return the first valid data source from the repository', async () => { - jest.spyOn(repository, 'get').mockResolvedValueOnce(null).mockResolvedValueOnce(true); - let selector = new PatternDataSourceSelector(mockedList,repository); - const result = await selector.getFirstValidDataSource(); - expect(result).toEqual(mockedList[1]); - expect(repository.get).toHaveBeenCalledTimes(2); - }); - - it('should throw an error when no valid data source is found', async () => { - jest.spyOn(repository, 'get').mockResolvedValueOnce(null).mockResolvedValueOnce(null).mockResolvedValueOnce(null); - let selector = new PatternDataSourceSelector(mockedList,repository); - try { - await selector.getFirstValidDataSource(); - } catch (error) { - expect(error.message).toBe('No valid data sources found'); - } - }); - }) - - describe('getAllDataSources', () => { - it('should return all data sources from the repository when the map is empty', async () => { - let selector = new PatternDataSourceSelector(mockedList,repository); - const result = await selector.getAllDataSources(); - expect(result).toEqual(mockedList); - }); - }) - - describe('getDataSource', () => { - - it('should return the selected data source from the repository', async () => { - jest.spyOn(repository, 'getDefault').mockResolvedValue(mockedList[0]); - let selector = new PatternDataSourceSelector(mockedList,repository); - const result = await selector.getSelectedDataSource(); - expect(result.id).toEqual(mockedList[0].id); - expect(repository.getDefault).toHaveBeenCalledTimes(1); - }); - - it('should return the first data source when the repository does not have a selected data source', async () => { - jest.spyOn(repository, 'getDefault').mockResolvedValue(null); - let selector = new PatternDataSourceSelector(mockedList,repository); - // mock spyon existsDataSource method to return 2 times differents values - jest.spyOn(selector, 'existsDataSource').mockResolvedValueOnce(false).mockResolvedValueOnce(true); - jest.spyOn(selector, 'selectDataSource').mockResolvedValue(); - const result = await selector.getSelectedDataSource(); - expect(result.id).toEqual(mockedList[1].id); - expect(repository.getDefault).toHaveBeenCalledTimes(1); - expect(selector.existsDataSource).toHaveBeenCalledTimes(2); - expect(selector.selectDataSource).toHaveBeenCalledTimes(1); - }) - - }) - - describe('selectDataSource', () => { - - it('should select a data source by ID when exists', async () => { - jest.spyOn(repository, 'setDefault').mockResolvedValue(true); - let selector = new PatternDataSourceSelector(mockedList,repository); - await selector.selectDataSource('id 1'); - expect(repository.setDefault).toHaveBeenCalledTimes(1); - expect(repository.setDefault).toHaveBeenCalledWith({ id: 'id 1', title: 'title 1' }); - }); - - it('should throw an error when selecting a non-existing data source', async () => { - jest.spyOn(repository, 'getAll').mockResolvedValue([]); - try { - let selector = new PatternDataSourceSelector(mockedList,repository); - await selector.selectDataSource('fake id'); - } catch (error) { - expect(error.message).toBe('Data source not found'); - } - }); - }) -}) \ No newline at end of file + afterEach(() => { + jest.clearAllMocks(); + }); + + describe('constructor', () => { + it('should return ERROR when the selector not receive a repository', () => { + try { + new PatternDataSourceSelector(mockedList, null as any); + } catch (error) { + expect(error.message).toBe('Data source repository is required'); + } + }); + + it('should return ERROR when the selector not receive a valid repository', () => { + try { + new PatternDataSourceSelector([], new ExampleRepository()); + } catch (error) { + expect(error.message).toBe('Data sources list is required'); + } + }); + }); + + describe('existsDataSource', () => { + it('should return TRUE when the data source exists', async () => { + jest + .spyOn(repository, 'get') + .mockResolvedValue({ id: '1', name: 'DataSource 1' }); + const selector = new PatternDataSourceSelector(mockedList, repository); + const result = await selector.existsDataSource('1'); + expect(result).toBe(true); + expect(repository.get).toHaveBeenCalledTimes(1); + }); + + it('should return FALSE when the data source does not exist', async () => { + jest.spyOn(repository, 'get').mockResolvedValue(null); + const selector = new PatternDataSourceSelector(mockedList, repository); + const result = await selector.existsDataSource('fake-id'); + expect(result).toBe(false); + expect(repository.get).toHaveBeenCalledTimes(1); + }); + + it('should throw ERROR when not receive an id', async () => { + jest.spyOn(repository, 'get').mockResolvedValue(null); + try { + let selector = new PatternDataSourceSelector(mockedList, repository); + await selector.existsDataSource(null as any); + } catch (error) { + expect(error.message).toBe( + 'Error checking data source. ID is required', + ); + } + }); + }); + + describe('getFirstValidDataSource', () => { + it('should return the first valid data source from the repository', async () => { + jest + .spyOn(repository, 'get') + .mockResolvedValueOnce(null) + .mockResolvedValueOnce(true); + let selector = new PatternDataSourceSelector(mockedList, repository); + const result = await selector.getFirstValidDataSource(); + expect(result).toEqual(mockedList[1]); + expect(repository.get).toHaveBeenCalledTimes(2); + }); + + it('should throw an error when no valid data source is found', async () => { + jest + .spyOn(repository, 'get') + .mockResolvedValueOnce(null) + .mockResolvedValueOnce(null) + .mockResolvedValueOnce(null); + let selector = new PatternDataSourceSelector(mockedList, repository); + try { + await selector.getFirstValidDataSource(); + } catch (error) { + expect(error.message).toBe('No valid data sources found'); + } + }); + }); + + describe('getAllDataSources', () => { + it('should return all data sources from the repository when the map is empty', async () => { + let selector = new PatternDataSourceSelector(mockedList, repository); + const result = await selector.getAllDataSources(); + expect(result).toEqual(mockedList); + }); + }); + + describe('getDataSource', () => { + it('should return the selected data source from the repository', async () => { + jest.spyOn(repository, 'getDefault').mockResolvedValue(mockedList[0]); + let selector = new PatternDataSourceSelector(mockedList, repository); + const result = await selector.getSelectedDataSource(); + expect(result.id).toEqual(mockedList[0].id); + expect(repository.getDefault).toHaveBeenCalledTimes(1); + }); + + it('should return the first data source when the repository does not have a selected data source', async () => { + jest.spyOn(repository, 'getDefault').mockResolvedValue(null); + let selector = new PatternDataSourceSelector(mockedList, repository); + // mock spyon existsDataSource method to return 2 times differents values + jest + .spyOn(selector, 'existsDataSource') + .mockResolvedValueOnce(false) + .mockResolvedValueOnce(true); + jest.spyOn(selector, 'selectDataSource').mockResolvedValue(); + const result = await selector.getSelectedDataSource(); + expect(result.id).toEqual(mockedList[1].id); + expect(repository.getDefault).toHaveBeenCalledTimes(1); + expect(selector.existsDataSource).toHaveBeenCalledTimes(2); + expect(selector.selectDataSource).toHaveBeenCalledTimes(1); + }); + }); + + describe('selectDataSource', () => { + it('should select a data source by ID when exists', async () => { + jest.spyOn(repository, 'setDefault').mockResolvedValue(true); + let selector = new PatternDataSourceSelector(mockedList, repository); + await selector.selectDataSource('id 1'); + expect(repository.setDefault).toHaveBeenCalledTimes(1); + expect(repository.setDefault).toHaveBeenCalledWith({ + id: 'id 1', + title: 'title 1', + }); + }); + + it('should throw an error when selecting a non-existing data source', async () => { + jest.spyOn(repository, 'getAll').mockResolvedValue([]); + try { + let selector = new PatternDataSourceSelector(mockedList, repository); + await selector.selectDataSource('fake id'); + } catch (error) { + expect(error.message).toBe('Data source not found'); + } + }); + }); +}); diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts index 0301a3aee2..ef2bfb4fd7 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts @@ -40,7 +40,7 @@ export class PatternDataSource implements tDataSource { } getFetchFilters(): tFilter[] { - return [...this.getAllowAgentsFilter(), ...this.getExcludeManagerFilter()]; + return [...this.getExcludeManagerFilter()]; } async select() { @@ -122,10 +122,6 @@ export class PatternDataSource implements tDataSource { return PatternDataSourceFilterManager.getPinnedAgentFilter(this.id); } - getAllowAgentsFilter(): tFilter[] { - return PatternDataSourceFilterManager.getAllowAgentsFilter(this.id); - } - getExcludeManagerFilter(): tFilter[] { return PatternDataSourceFilterManager.getExcludeManagerFilter(this.id); } diff --git a/plugins/main/public/components/common/hooks/index.ts b/plugins/main/public/components/common/hooks/index.ts index 97e9aca234..35f7245307 100644 --- a/plugins/main/public/components/common/hooks/index.ts +++ b/plugins/main/public/components/common/hooks/index.ts @@ -18,7 +18,6 @@ export * from './use-time-filter'; export * from './useWindowSize'; export * from './useUserPermissions'; export * from './use-user-is-admin'; -export * from './useAllowedAgents'; export * from './useApiRequest'; export * from './use-app-config'; export * from './use_async_action'; diff --git a/plugins/main/public/components/common/hooks/useAllowedAgents.ts b/plugins/main/public/components/common/hooks/useAllowedAgents.ts deleted file mode 100644 index a4f4e878db..0000000000 --- a/plugins/main/public/components/common/hooks/useAllowedAgents.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Wazuh app - React hooks to manage allowed users - * Copyright (C) 2015-2022 Wazuh, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Find more information about this on the LICENSE file. - */ - -import { useSelector } from 'react-redux'; -import { getFilterWithAuthorizedAgents } from '../../../react-services/filter-authorization-agents'; - -// It returns user allowed agents -export const useAllowedAgents = () => { - const allowedAgents = useSelector( - state => state.appStateReducers.allowedAgents, - ); - const filterAllowedAgents = getFilterWithAuthorizedAgents(allowedAgents); - return { allowedAgents, filterAllowedAgents }; -}; diff --git a/plugins/main/public/react-services/wz-agents.ts b/plugins/main/public/react-services/wz-agents.ts index 5c0a5a4c83..d2a6b8a37d 100644 --- a/plugins/main/public/react-services/wz-agents.ts +++ b/plugins/main/public/react-services/wz-agents.ts @@ -34,30 +34,3 @@ export function hasAgentSupportModule(agent, component) { const agentOSType = getAgentOSType(agent); return !UnsupportedComponents[agentOSType].includes(component); } - -export async function getAuthorizedAgents() { - try { - const params = { limit: 500 }; - const output: IApiResponse<{ id: string }> = await WzRequest.apiReq('GET', `/agents`, {}); - const totalItems = (((output || {}).data || {}).data || {}).total_affected_items; - let itemsArray = []; - if (totalItems && output.data && output.data.data && totalItems > 500) { - params.offset = 0; - itemsArray.push(...output.data.data.affected_items); - while (itemsArray.length < totalItems && params.offset < totalItems) { - params.offset += params.limit; - const tmpData: IApiResponse<{ id: string }> = await WzRequest.apiReq('GET', `/agents`, { - params: params, - }); - itemsArray.push(...tmpData.data.data.affected_items); - } - const allowedAgents = itemsArray ? itemsArray.map((agent) => agent.id) : []; - return allowedAgents; - } else { - const allowedAgents = output ? output.data.data.affected_items.map((agent) => agent.id) : []; - return allowedAgents; - } - } catch (error) { - throw error; - } -} diff --git a/plugins/main/public/react-services/wz-authentication.ts b/plugins/main/public/react-services/wz-authentication.ts index 83138bdf7b..fb167e7143 100644 --- a/plugins/main/public/react-services/wz-authentication.ts +++ b/plugins/main/public/react-services/wz-authentication.ts @@ -17,12 +17,10 @@ import store from '../redux/store'; import { updateUserPermissions, updateWithUserLogged, - updateAllowedAgents, updateUserAccount, } from '../redux/actions/appStateActions'; import { UI_LOGGER_LEVELS } from '../../common/constants'; import { getWazuhCorePlugin } from '../kibana-services'; -import { getAuthorizedAgents } from '../react-services/wz-agents'; import { UI_ERROR_SEVERITIES, UIErrorLog, @@ -83,15 +81,6 @@ export class WzAuthentication { // Get user Policies const userPolicies = await WzAuthentication.getUserPolicies(); - //Get allowed agents for the current user - let allowedAgents: any = []; - if (WzAuthentication.userHasAgentsPermissions(userPolicies)) { - allowedAgents = await getAuthorizedAgents(); - // users without read:agent police should not view info about any agent - allowedAgents = allowedAgents.length ? allowedAgents : ['-1']; - } - store.dispatch(updateAllowedAgents(allowedAgents)); - // Dispatch actions to set permissions and administrator consideration store.dispatch(updateUserPermissions(userPolicies)); diff --git a/plugins/main/public/redux/actions/appStateActions.js b/plugins/main/public/redux/actions/appStateActions.js index 899da9772a..5597068474 100644 --- a/plugins/main/public/redux/actions/appStateActions.js +++ b/plugins/main/public/redux/actions/appStateActions.js @@ -153,17 +153,6 @@ export const updateWithUserLogged = withUserLogged => { }; }; -/** - * Updates allowedAgents in the appState store - * @param allowedAgents - */ -export const updateAllowedAgents = allowedAgents => { - return { - type: 'GET_ALLOWED_AGENTS', - allowedAgents, - }; -}; - /** * Updates logtestToken in the appState store * @param logtestToken diff --git a/plugins/main/public/redux/reducers/appStateReducers.js b/plugins/main/public/redux/reducers/appStateReducers.js index fe583948ff..1c567af90a 100644 --- a/plugins/main/public/redux/reducers/appStateReducers.js +++ b/plugins/main/public/redux/reducers/appStateReducers.js @@ -23,7 +23,6 @@ const initialState = { userPermissions: false, toastNotification: false, withUserLogged: false, - allowedAgents: [], logtestToken: '', userAccount: { administrator: false, @@ -113,13 +112,6 @@ const appStateReducers = (state = initialState, action) => { }; } - if (action.type === 'GET_ALLOWED_AGENTS') { - return { - ...state, - allowedAgents: action.allowedAgents, - }; - } - if (action.type === 'UPDATE_LOGTEST_TOKEN') { return { ...state, diff --git a/plugins/main/server/controllers/wazuh-reporting.ts b/plugins/main/server/controllers/wazuh-reporting.ts index e6362fbec2..80b573b582 100644 --- a/plugins/main/server/controllers/wazuh-reporting.ts +++ b/plugins/main/server/controllers/wazuh-reporting.ts @@ -369,7 +369,6 @@ export class WazuhReportingCtrl { new Date(from).getTime(), new Date(to).getTime(), serverSideQuery, - agentsFilter, indexPatternTitle || context.wazuh_core.configuration.getSettingValue('pattern'), agents, @@ -382,11 +381,6 @@ export class WazuhReportingCtrl { printer.addTables([...tables, ...(additionalTables || [])]); } - //add authorized agents - if (agentsFilter?.agentsText) { - printer.addAgentsFilters(agentsFilter.agentsText); - } - await printer.print(context.wazuhEndpointParams.pathFilename); return response.ok({ @@ -1301,7 +1295,6 @@ export class WazuhReportingCtrl { from, to, serverSideQuery, - agentsFilter, indexPatternTitle || context.wazuh_core.configuration.getSettingValue('pattern'), agentID, diff --git a/plugins/main/server/lib/reporting/audit-request.ts b/plugins/main/server/lib/reporting/audit-request.ts index ecd3d38432..2f58155e78 100644 --- a/plugins/main/server/lib/reporting/audit-request.ts +++ b/plugins/main/server/lib/reporting/audit-request.ts @@ -25,13 +25,12 @@ export const getTop3AgentsSudoNonSuccessful = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '3': { @@ -93,13 +92,12 @@ export const getTop3AgentsFailedSyscalls = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '3': { @@ -175,13 +173,12 @@ export const getTopFailedSyscalls = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/base-query.ts b/plugins/main/server/lib/reporting/base-query.ts index 7e67e541d8..13fa7e8b9a 100644 --- a/plugins/main/server/lib/reporting/base-query.ts +++ b/plugins/main/server/lib/reporting/base-query.ts @@ -12,16 +12,16 @@ import { cloneDeep } from 'lodash'; -export function Base(pattern: string, filters: any, gte: number, lte: number, allowedAgentsFilter: any = null) { +export function Base(pattern: string, filters: any, gte: number, lte: number) { const clonedFilter = cloneDeep(filters); clonedFilter?.bool?.must?.push?.({ range: { timestamp: { gte: gte, lte: lte, - format: 'epoch_millis' - } - } + format: 'epoch_millis', + }, + }, }); const base = { from: 0, @@ -29,7 +29,7 @@ export function Base(pattern: string, filters: any, gte: number, lte: number, al aggs: {}, sort: [], script_fields: {}, - query: clonedFilter + query: clonedFilter, }; return base; diff --git a/plugins/main/server/lib/reporting/extended-information.ts b/plugins/main/server/lib/reporting/extended-information.ts index cc7938e234..cc0b57f556 100644 --- a/plugins/main/server/lib/reporting/extended-information.ts +++ b/plugins/main/server/lib/reporting/extended-information.ts @@ -144,7 +144,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, agent = null, ) { @@ -184,7 +183,6 @@ export async function extendedInformation( to, vulnerabilitiesLevel, filters, - allowedAgentsFilter, pattern, ); return count @@ -209,7 +207,6 @@ export async function extendedInformation( to, 'Low', filters, - allowedAgentsFilter, pattern, ); const mediumRank = await VulnerabilityRequest.topAgentCount( @@ -218,7 +215,6 @@ export async function extendedInformation( to, 'Medium', filters, - allowedAgentsFilter, pattern, ); const highRank = await VulnerabilityRequest.topAgentCount( @@ -227,7 +223,6 @@ export async function extendedInformation( to, 'High', filters, - allowedAgentsFilter, pattern, ); const criticalRank = await VulnerabilityRequest.topAgentCount( @@ -236,7 +231,6 @@ export async function extendedInformation( to, 'Critical', filters, - allowedAgentsFilter, pattern, ); printer.logger.debug( @@ -286,7 +280,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); printer.logger.debug('Adding overview vulnerability detector top 3 CVEs'); @@ -314,7 +307,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); @@ -336,7 +328,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); printer.logger.debug('Adding most common rootkits'); @@ -366,7 +357,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); hiddenPids && @@ -385,7 +375,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); hiddenPorts && @@ -409,7 +398,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); printer.addContentWithNewLine({ @@ -422,7 +410,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, item, pattern, ); @@ -460,7 +447,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); printer.addContentWithNewLine({ @@ -473,7 +459,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, item, pattern, ); @@ -511,7 +496,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); printer.addContentWithNewLine({ @@ -524,7 +508,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, item, pattern, ); @@ -566,7 +549,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); if (auditAgentsNonSuccess && auditAgentsNonSuccess.length) { @@ -582,7 +564,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); if (auditAgentsFailedSyscall && auditAgentsFailedSyscall.length) { @@ -613,7 +594,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); @@ -639,7 +619,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); @@ -664,7 +643,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); auditFailedSyscall && @@ -715,7 +693,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); @@ -736,7 +713,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, pattern, ); @@ -840,7 +816,6 @@ export async function extendedInformation( to, vulnerabilitiesLevel, filters, - allowedAgentsFilter, pattern, ); } catch (error) { @@ -878,7 +853,6 @@ export async function extendedInformation( to, 'Critical', filters, - allowedAgentsFilter, pattern, ); if (topCriticalPackages && topCriticalPackages.length) { @@ -910,7 +884,6 @@ export async function extendedInformation( to, 'High', filters, - allowedAgentsFilter, pattern, ); if (topHighPackages && topHighPackages.length) { @@ -945,7 +918,6 @@ export async function extendedInformation( from, to, filters, - allowedAgentsFilter, summaryTable, pattern, ); diff --git a/plugins/main/server/lib/reporting/gdpr-request.ts b/plugins/main/server/lib/reporting/gdpr-request.ts index 95a2810346..1513cf4664 100644 --- a/plugins/main/server/lib/reporting/gdpr-request.ts +++ b/plugins/main/server/lib/reporting/gdpr-request.ts @@ -24,13 +24,12 @@ export const topGDPRRequirements = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -70,14 +69,13 @@ export const getRulesByRequirement = async ( gte, lte, filters, - allowedAgentsFilter, requirement, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/overview-request.ts b/plugins/main/server/lib/reporting/overview-request.ts index e18b85a8bf..6de20768ad 100644 --- a/plugins/main/server/lib/reporting/overview-request.ts +++ b/plugins/main/server/lib/reporting/overview-request.ts @@ -19,18 +19,11 @@ import { Base } from './base-query'; * @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability * @returns {Array} E.g:['000','130','300'] */ -export const topLevel15 = async ( - context, - gte, - lte, - filters, - allowedAgentsFilter, - pattern, -) => { +export const topLevel15 = async (context, gte, lte, filters, pattern) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/pci-request.ts b/plugins/main/server/lib/reporting/pci-request.ts index 51d470683c..99a818763c 100644 --- a/plugins/main/server/lib/reporting/pci-request.ts +++ b/plugins/main/server/lib/reporting/pci-request.ts @@ -24,13 +24,12 @@ export const topPCIRequirements = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -85,14 +84,13 @@ export const getRulesByRequirement = async ( gte, lte, filters, - allowedAgentsFilter, requirement, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/rootcheck-request.ts b/plugins/main/server/lib/reporting/rootcheck-request.ts index f5d3577765..357251a678 100644 --- a/plugins/main/server/lib/reporting/rootcheck-request.ts +++ b/plugins/main/server/lib/reporting/rootcheck-request.ts @@ -24,14 +24,13 @@ export const top5RootkitsDetected = async ( gte, lte, filters, - allowedAgentsFilter, pattern, size = 5, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -82,13 +81,12 @@ export const agentsWithHiddenPids = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '1': { @@ -134,13 +132,12 @@ export const agentsWithHiddenPorts = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '1': { diff --git a/plugins/main/server/lib/reporting/summary-table.test.ts b/plugins/main/server/lib/reporting/summary-table.test.ts index 1629d5b234..720eedaca3 100644 --- a/plugins/main/server/lib/reporting/summary-table.test.ts +++ b/plugins/main/server/lib/reporting/summary-table.test.ts @@ -11,7 +11,6 @@ describe('Summary table', () => { 'now/1h', 'now', [], - [], summarySetup, 'pattern', ); @@ -106,7 +105,6 @@ describe('Summary table', () => { 'now/1h', 'now', [], - [], summarySetup, 'pattern', ); diff --git a/plugins/main/server/lib/reporting/summary-table.ts b/plugins/main/server/lib/reporting/summary-table.ts index 051f7491fe..561fa46540 100644 --- a/plugins/main/server/lib/reporting/summary-table.ts +++ b/plugins/main/server/lib/reporting/summary-table.ts @@ -17,15 +17,7 @@ interface SummarySetup { } export default class SummaryTable { - constructor( - context, - gte, - lte, - filters, - allowedAgentsFilter, - summarySetup: SummarySetup, - pattern, - ) { + constructor(context, gte, lte, filters, summarySetup: SummarySetup, pattern) { this._context = context; this._pattern = pattern; this._summarySetup = summarySetup; @@ -34,10 +26,7 @@ export default class SummaryTable { this._rows = []; this._title = summarySetup.title; - Object.assign( - this._base, - Base(pattern, filters, gte, lte, allowedAgentsFilter), - ); + Object.assign(this._base, Base(pattern, filters, gte, lte)); this._parseSummarySetup(summarySetup); } diff --git a/plugins/main/server/lib/reporting/syscheck-request.ts b/plugins/main/server/lib/reporting/syscheck-request.ts index d702a83aa8..07ae4c9536 100644 --- a/plugins/main/server/lib/reporting/syscheck-request.ts +++ b/plugins/main/server/lib/reporting/syscheck-request.ts @@ -19,18 +19,11 @@ import { Base } from './base-query'; * @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability * @returns {Array} */ -export const top3agents = async ( - context, - gte, - lte, - filters, - allowedAgentsFilter, - pattern, -) => { +export const top3agents = async (context, gte, lte, filters, pattern) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -72,18 +65,11 @@ export const top3agents = async ( * @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability * @returns {Array} */ -export const top3Rules = async ( - context, - gte, - lte, - filters, - allowedAgentsFilter, - pattern, -) => { +export const top3Rules = async (context, gte, lte, filters, pattern) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -140,13 +126,12 @@ export const lastTenDeletedFiles = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -194,13 +179,12 @@ export const lastTenModifiedFiles = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/tsc-request.ts b/plugins/main/server/lib/reporting/tsc-request.ts index 44669489d4..502d3ba924 100644 --- a/plugins/main/server/lib/reporting/tsc-request.ts +++ b/plugins/main/server/lib/reporting/tsc-request.ts @@ -24,13 +24,12 @@ export const topTSCRequirements = async ( gte, lte, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -85,14 +84,13 @@ export const getRulesByRequirement = async ( gte, lte, filters, - allowedAgentsFilter, requirement, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { diff --git a/plugins/main/server/lib/reporting/vulnerability-request.ts b/plugins/main/server/lib/reporting/vulnerability-request.ts index 5402de6fcd..de254ec09b 100644 --- a/plugins/main/server/lib/reporting/vulnerability-request.ts +++ b/plugins/main/server/lib/reporting/vulnerability-request.ts @@ -26,13 +26,12 @@ export const topAgentCount = async ( lte, severity, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -74,18 +73,11 @@ export const topAgentCount = async ( * @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability * @returns {Array} */ -export const topCVECount = async ( - context, - gte, - lte, - filters, - allowedAgentsFilter, - pattern, -) => { +export const topCVECount = async (context, gte, lte, filters, pattern) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -126,13 +118,12 @@ export const uniqueSeverityCount = async ( lte, severity, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '1': { @@ -172,13 +163,12 @@ export const topPackages = async ( lte, severity, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': { @@ -222,13 +212,12 @@ export const topPackagesWithCVE = async ( lte, severity, filters, - allowedAgentsFilter, pattern, ) => { try { const base = {}; - Object.assign(base, Base(pattern, filters, gte, lte, allowedAgentsFilter)); + Object.assign(base, Base(pattern, filters, gte, lte)); Object.assign(base.aggs, { '2': {