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

Neo4j error while opening the panel events in GitHub #7050

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
700a967
Fix the error opening Events panel in Github
guidomodarelli Oct 2, 2024
70e9886
Refactor data grid props and functions- Improve data grid functionali…
guidomodarelli Oct 2, 2024
3d78d86
Update default pagination options and type definitions
guidomodarelli Oct 2, 2024
af6a3ad
Update default pagination options in DrillDownDataGrid component
guidomodarelli Oct 2, 2024
e5aa451
Add test for WazuhDataGrid component
guidomodarelli Oct 2, 2024
da7d980
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 2, 2024
462ba08
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
asteriscos Oct 2, 2024
b718b2f
Refactor EuiButtonIcon rendering in InventoryVulsComponent
guidomodarelli Oct 2, 2024
fd17eed
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
asteriscos Oct 2, 2024
21eb5af
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 10, 2024
65172a4
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 14, 2024
78ac92b
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 14, 2024
301fcb7
Fix CHANGELOG
guidomodarelli Oct 14, 2024
cd29792
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 17, 2024
2107eed
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 17, 2024
0d198e8
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 18, 2024
c8786bb
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 22, 2024
9ca8422
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
guidomodarelli Oct 24, 2024
ca4c88b
Merge branch '4.10.0' into bug/3408-neo4j-error-while-opening-the-pan…
asteriscos Oct 24, 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed vulnerabilities inventory table scroll [#7118](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7118)
- Fixed the filter are displayed cropped on screens of 575px to 767px in vulnerability detection module [#7047](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7047)
- Fixed ability to filter from files inventory details flyout of File Integrity Monitoring [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
- Fixed the error while opening the panel Events in Github [#3408](https://github.com/wazuh/external-devel-requests/issues/3408)

### Removed

Expand Down
23 changes: 15 additions & 8 deletions plugins/main/public/components/common/data-grid/use-data-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export interface PaginationOptions
type SortingColumns = EuiDataGridSorting['columns'];

const MAX_ENTRIES_PER_QUERY = 10000;
const DEFAULT_PAGE_INDEX = 0;
const DEFAULT_PAGE_SIZE = 15;
const DEFAULT_PAGE_SIZE_OPTIONS = [DEFAULT_PAGE_SIZE, 25, 50, 100];
const DEFAULT_PAGINATION_OPTIONS: PaginationOptions = {
export const DEFAULT_PAGE_INDEX = 0;
export const DEFAULT_PAGE_SIZE = 15;
export const DEFAULT_PAGE_SIZE_OPTIONS = [DEFAULT_PAGE_SIZE, 25, 50, 100];
export const DEFAULT_PAGINATION_OPTIONS: PaginationOptions = {
pageIndex: DEFAULT_PAGE_INDEX,
pageSize: DEFAULT_PAGE_SIZE,
pageSizeOptions: DEFAULT_PAGE_SIZE_OPTIONS,
Expand All @@ -41,9 +41,13 @@ export interface RenderColumn {
render: (value: any, rowItem: object) => string | React.ReactNode;
}

export type tDataGridColumn = Partial<RenderColumn> & EuiDataGridColumn;
export type tDataGridColumn = Partial<RenderColumn> &
EuiDataGridColumn &
Partial<{ name: string }>;

export type tDataGridRenderColumn = RenderColumn & EuiDataGridColumn;
export type tDataGridRenderColumn = RenderColumn &
EuiDataGridColumn &
Partial<{ name: string }>;

export type tDataGridProps = {
indexPattern: IndexPattern;
Expand All @@ -60,7 +64,10 @@ export type tDataGridProps = {
setFilters?: (filters: Filter[]) => void;
};

export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => {
type DataGridProps = EuiDataGridProps &
Required<Pick<EuiDataGridProps, 'sorting' | 'pagination'>>;

export const useDataGrid = (props: tDataGridProps): DataGridProps => {
const {
indexPattern,
DocViewInspectButton,
Expand Down Expand Up @@ -262,5 +269,5 @@ export const useDataGrid = (props: tDataGridProps): EuiDataGridProps => {
onChangePage: onChangePage,
},
setPagination,
} as EuiDataGridProps;
} as DataGridProps;
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface WzSearchBarProps extends SearchBarProps {
userFilters?: Filter[];
preQueryBar?: React.ReactElement;
postFilters?: React.ReactElement;
postFixedFilters?: () => React.ReactElement<any>[];
postFixedFilters?: (() => React.JSX.Element)[];
hideFixedFilters?: boolean;
showSaveQueryButton?: boolean;
showSaveQuery?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import React from 'react';
import { SearchResponse } from '@opensearch-project/opensearch/api/types';
import { render } from '@testing-library/react';
import {
IndexPattern,
TimeRange,
} from '../../../../../../src/plugins/data/common';
import WazuhDataGrid from './wz-data-grid';
import { PaginationOptions, tDataGridColumn } from '../data-grid';
import { tFilter } from '../data-source';

jest.mock('../../../kibana-services', () => ({
getWazuhCorePlugin: jest.fn().mockImplementation(() => {
return {
hooks: {
useDockedSideNav: jest.fn().mockImplementation(() => true),
},
};
}),
}));

describe('WazuhDataGrid', () => {
let mockOnChangePagination: jest.Mock;
let mockOnChangeSorting: jest.Mock;
let mockResults: SearchResponse;
let mockIndexPatternMock: IndexPattern;
let mockDefaultColumnsMock: tDataGridColumn[];
let mockDefaultPaginationMock: PaginationOptions;
let mockTimeRangeMock: TimeRange;
let mockExportFilters: tFilter[];

beforeEach(() => {
mockOnChangePagination = jest.fn();
mockOnChangeSorting = jest.fn();
mockResults = {
took: 6,
timed_out: false,
_shards: {
total: 9,
successful: 9,
skipped: 0,
failed: 0,
},
hits: {
total: 1,
max_score: 0,
hits: [
{
_index: 'wazuh-alerts-4.x-sample-security',
_id: 'EexXSZIBE_oA_ZslejwA',
_score: 0,
_source: {
predecoder: {},
cluster: {
node: 'wazuh',
name: 'wazuh',
},
agent: {
ip: '207.45.34.78',
name: 'Windows',
id: '006',
},
manager: {
name: 'wazuh-manager-master-0',
},
data: {
github: {
actor: 'User7',
'@timestamp': '2024-10-01T18:24:43.468+0000',
visibility: 'private',
org: 'Organization1',
repo: 'Organization1/Repo4',
created_at: '2024-10-01T18:24:43.468+0000',
action: 'repo.create',
actor_location: {
country_code: 'CA',
},
_document_id: 'AcrdSmMW0PpEEmuGWiTcoQ',
},
},
'@sampledata': true,
rule: {
firedtimes: 1,
mail: false,
level: 5,
description: 'GitHub Repo create.',
groups: ['github', 'git', 'git_repo'],
id: '91318',
},
location: 'github',
id: '1580123327.49031',
decoder: {
name: 'json',
},
timestamp: '2024-10-01T18:24:43.468+0000',
},
fields: {
timestamp: ['2024-10-01T18:24:43.468Z'],
},
},
],
},
};
mockIndexPatternMock = {
id: '48e5b251-5238-49bc-a4b5-446168ea167c',
// @ts-expect-error
fields: [],
};
mockDefaultColumnsMock = [
{
id: 'timestamp',
isSortable: true,
defaultSortDirection: 'desc',
},
{
id: 'rule.description',
},
{
id: 'data.github.org',
displayAsText: 'Organization',
},
{
id: 'data.github.actor',
displayAsText: 'Actor',
},
{
id: 'data.github.action',
displayAsText: 'Action',
},
{
id: 'rule.level',
},
{
id: 'rule.id',
},
];
mockDefaultPaginationMock = {
pageIndex: 0,
pageSize: 15,
pageSizeOptions: [15, 25, 50, 100],
};
mockTimeRangeMock = {
from: '2024-10-01T15:36:13.085Z',
to: '2024-10-02T15:36:13.085Z',
};
mockExportFilters = [
{
meta: {
removable: false,
index: 'wazuh-alerts-*',
negate: false,
disabled: false,
alias: null,
type: 'phrase',
key: 'cluster.name',
value: 'wazuh',
params: {
query: 'wazuh',
type: 'phrase',
},
controlledBy: 'cluster-manager',
},
query: {
match: {
'cluster.name': {
query: 'wazuh',
type: 'phrase',
},
},
},
$state: {
store: 'appState',
},
},
{
meta: {
index: 'wazuh-alerts-*',
negate: false,
disabled: false,
alias: null,
type: 'phrase',
key: 'rule.groups',
value: 'github',
params: {
query: 'github',
type: 'phrase',
},
controlledBy: 'github-rule-group',
},
query: {
match: {
'rule.groups': {
query: 'github',
type: 'phrase',
},
},
},
$state: {
store: 'appState',
},
},
{
meta: {
alias: null,
disabled: false,
key: 'data.github.repo',
value: 'Organization1/Repo4',
params: ['Organization1/Repo4'],
negate: false,
type: 'phrases',
index: 'wazuh-alerts-*',
controlledBy: 'github-panel-row-filter',
},
query: {
bool: {
minimum_should_match: 1,
should: [
{
match_phrase: {
'data.github.repo': {
query: 'Organization1/Repo4',
},
},
},
],
},
},
$state: {
store: 'appState',
},
},
];
});

it('should render correctly', () => {
const { container } = render(
<WazuhDataGrid
results={mockResults}
defaultColumns={mockDefaultColumnsMock}
defaultPagination={mockDefaultPaginationMock}
indexPattern={mockIndexPatternMock}
exportFilters={mockExportFilters}
isLoading={false}
onChangePagination={mockOnChangePagination}
onChangeSorting={mockOnChangeSorting}
dateRange={mockTimeRangeMock}
/>,
);

expect(container).toBeTruthy();
});
});
Loading
Loading