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

Replace empty registry value name in FIM inventory #3279

Merged
merged 9 commits into from
May 27, 2021

Conversation

mpRegalado
Copy link
Member

@mpRegalado mpRegalado commented May 20, 2021

Closes #3220
Presented empty fields with a notice
Added a function that returns a render method compatible with EuiColumn objects that, if the object is either an empty string or undefined, shows a label stating as such (for now only in Value Name on Registry details).
Also replicated the same functionality for the syscheck.value_name in the FIM Discovery dashboard to address the situation in the issue #3220

Testing
Create a enviroment with at least 1 windows agent with syscheck enabled

  • Any empty fields on the FIM inventory should display the label, one can be easily found in the files inventory for a windows agent.
  • Replacing line 129 in public/kibana-integrations/discover/application/components/table/table.tsx with value={""} will empty all the information displayed in all the extended rows of FIM discovery, checking the syscheck.value_name field should show the label.

Screenshots
image

image

@mpRegalado mpRegalado added the type/enhancement Enhancement issue label May 20, 2021
@mpRegalado mpRegalado requested a review from a team May 20, 2021 17:49
@mpRegalado mpRegalado self-assigned this May 20, 2021
@mpRegalado mpRegalado linked an issue May 20, 2021 that may be closed by this pull request
All the tables in the Integrity monitoring section that show an empty field now display a label with an icon noting them as empty, to help distinguish them from whitespace strings and to improve the look.
@mpRegalado mpRegalado force-pushed the enhancement/replace-empty-registry-value_3220 branch from 9616105 to 3803ee9 Compare May 21, 2021 07:16
@mpRegalado mpRegalado changed the base branch from 4.2-7.10 to 4.3-7.10 May 21, 2021 07:17
@mpRegalado mpRegalado marked this pull request as ready for review May 21, 2021 07:19
@mpRegalado mpRegalado added the 4.3 label May 21, 2021
Copy link
Contributor

@gabiwassan gabiwassan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some conventions to apply. Great Job!

Comment on lines 1 to 33
/*
* Wazuh app - Integrity monitoring components
* Copyright (C) 2015-2021 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 { EuiCode, EuiIcon } from '@elastic/eui'
import React from 'react'

/* This function can be used to render possibly empty fields.
It takes a render function suitable for an EuiTable and returns another. */
export const emptyFieldHandler = (renderFn = (value,record) => value) => {
return (value, record) => {
if (value === "" || value === undefined) {
return (
<>
<EuiIcon type="iInCircle"/>
<EuiCode>
Empty field
</EuiCode>
</>
)
} else {
return renderFn(value,record);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The name of this file should be with kebab-case: empty-field-handler.js (if possible we have legacy files with camel case)
  • We use 2 spaces on code style. Maybe you are not using prettier on your IDE.

@@ -15,6 +15,7 @@ import { WzRequest } from '../../../../../react-services';
import React, { useEffect, useState } from 'react';
import valuesMock from './values.json';
import { DIRECTIONS } from '@elastic/eui/src/components/flex/flex_group';
import { emptyFieldHandler } from '../lib'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon ;

}),
'syscheck.value_name': (content, rowData, element, options) => {
if (content) return;
const container = document.createElement("tr");
Copy link
Member

@Desvelao Desvelao May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the container an tr HTML element?

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant to be a td element to match the rest of the cells in the table. Fixed in 97821ec

Copy link
Member

@Desvelao Desvelao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: ❌ Review the suggested changes
Test: ✅
With a window size lower, the cell looks a little strange.
image

I couldn't get the agent report changes about the registry, so I did the suggested trick in the PR comment to get the event detail field:
image

@mpRegalado mpRegalado requested review from gabiwassan and Desvelao May 24, 2021 09:42
}),
'syscheck.value_name': (content, rowData, element, options) => {
if (content) return;
const container = document.createElement("td");
Copy link
Member

@Desvelao Desvelao May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a div or span instead of an HTML related to a table. The td/tr elements are set by the table itself.

I need to redo the test to verify it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked and you were right, replaced the element with a span

@mpRegalado mpRegalado requested a review from Desvelao May 25, 2021 12:45
Copy link
Contributor

@pablomarga pablomarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: ✔️
Testing: ✔️ it works fine but as @Desvelao commented when you reduce the window the cell looks a little strange.
Screenshot_20210526_101735

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: small improvements

},
{
field: 'value',
name: 'Value name',
sortable: true,
render: (item) => item.name,
render: emptyFieldHandler((item) => item.name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove please emptyFieldHandler from all but this.
we'll only notify this field when is empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 3b07cd1

@mpRegalado mpRegalado requested a review from frankeros May 27, 2021 10:16
Copy link
Contributor

@frankeros frankeros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test: ✔️
CR: ✔️
LGTM! Great job 🎉

@frankeros frankeros merged commit 028dc0e into 4.3-7.10 May 27, 2021
@frankeros frankeros deleted the enhancement/replace-empty-registry-value_3220 branch May 27, 2021 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace empty registry value name in FIM inventory
6 participants