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

Fix API request to get the manager labels and broken documentation link #5687

Merged
merged 7 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Fixed the rendering of tables that contains IPs and agent overview [#5471](https://github.com/wazuh/wazuh-kibana-app/pull/5471)
- Fixed the agents active coverage stat as NaN in Details panel of Agents section [#5490](https://github.com/wazuh/wazuh-kibana-app/pull/5490)
- Fixed a broken documentation link to agent labels [#5687](https://github.com/wazuh/wazuh-kibana-app/pull/5687)

### Removed

Expand All @@ -21,6 +22,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Changed method to perform redirection on agent table buttons [#5539](https://github.com/wazuh/wazuh-kibana-app/pull/5539)
- Changed windows agent service name in the deploy agent wizard [#5538](https://github.com/wazuh/wazuh-kibana-app/pull/5538)
- Changed the requests to get the agent labels for the managers [#5687](https://github.com/wazuh/wazuh-kibana-app/pull/5687)

## Wazuh v4.5.0 - OpenSearch Dashboards 2.6.0 - Revision 01

Expand All @@ -36,7 +38,6 @@ All notable changes to the Wazuh app project will be documented in this file.

## Wazuh v4.4.4 - OpenSearch Dashboards 2.6.0 - Revision 01


### Added

- Support for Wazuh 4.4.4
Expand Down
15 changes: 15 additions & 0 deletions docker/imposter/agents/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var path = context.request.path;
var pathConfiguration = path.split('/');
pathConfiguration.splice(0, 5);
console.log(pathConfiguration);
switch (pathConfiguration[0]) {
case 'labels':
respond()
.withStatusCode(200)
.withFile('agents/configuration/agent_labels.json');

break;
default:
respond().withStatusCode(200).withFile('agents/configuration/default.json');
break;
}
12 changes: 12 additions & 0 deletions docker/imposter/agents/configuration/agent_labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data": {
"labels": [
{
"value": "customLabel",
"key": "custom",
"hidden": "no"
}
]
},
"error": 0
}
33 changes: 33 additions & 0 deletions docker/imposter/agents/configuration/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"data": {
"client": {
"config-profile": "ubuntu, ubuntu20, ubuntu20.04",
"notify_time": 10,
"time-reconnect": 60,
"force_reconnect_interval": 0,
"ip_update_interval": 0,
"auto_restart": "yes",
"remote_conf": "yes",
"crypto_method": "aes",
"server": [
{
"address": "nginx-lb/172.25.0.4",
"port": 1514,
"max_retries": 5,
"retry_interval": 10,
"protocol": "tcp"
}
],
"enrollment": [
{
"enabled": "yes",
"delay_after_enrollment": 20,
"port": 1515,
"ssl_cipher": "HIGH:!ADH:!EXP:!MD5:!RC4:!3DES:!CAMELLIA:@STRENGTH",
"auto_method": "no"
}
]
}
},
"error": 0
}
20 changes: 20 additions & 0 deletions docker/imposter/cluster/configuration/agent_labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"data": {
"affected_items": [
{
"labels": [
{
"value": "customLabel",
"key": "custom",
"hidden": "no"
}
]
}
],
"total_affected_items": 1,
"total_failed_items": 0,
"failed_items": []
},
"message": "Active configuration was successfully read in specified node.",
"error": 0
}
22 changes: 22 additions & 0 deletions docker/imposter/manager/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var path = context.request.path;
var pathConfiguration = path.split('/');
pathConfiguration.splice(0, 4);
switch (pathConfiguration[0]) {
case 'labels':
respond()
.withStatusCode(200)
.withFile('manager/configuration/agent_labels.json');

break;
case 'reports':
respond()
.withStatusCode(200)
.withFile('manager/configuration/monitor_reports.json');

break;
default:
respond()
.withStatusCode(200)
.withFile('manager/configuration/default.json');
break;
}
20 changes: 20 additions & 0 deletions docker/imposter/manager/configuration/agent_labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"data": {
"affected_items": [
{
"labels": [
{
"value": "customLabel",
"key": "custom",
"hidden": "no"
}
]
}
],
"total_affected_items": 1,
"total_failed_items": 0,
"failed_items": []
},
"message": "Active configuration was successfully read in specified node.",
"error": 0
}
35 changes: 35 additions & 0 deletions docker/imposter/manager/configuration/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"data": {
"affected_items": [
{
"global": {
"email_notification": "no",
"logall": "no",
"logall_json": "no",
"integrity_checking": 8,
"rootkit_detection": 8,
"host_information": 8,
"prelude_output": "no",
"zeromq_output": "no",
"jsonout_output": "yes",
"alerts_log": "yes",
"stats": 4,
"memory_size": 8192,
"white_list": [
"127.0.0.1",
"80.58.61.250",
"80.58.61.254",
"localhost.localdomain"
],
"rotate_interval": 0,
"max_output_size": 0
}
}
],
"total_affected_items": 1,
"total_failed_items": 0,
"failed_items": []
},
"message": "Active configuration was successfully read in specified node",
"error": 0
}
16 changes: 16 additions & 0 deletions docker/imposter/manager/configuration/monitor_reports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data": {
"affected_items": [{
"reports": [{
"category": "syscheck",
"title": "Daily report: File changes",
"email_to": "[email protected]"
}]
}],
"total_affected_items": 1,
"total_failed_items": 0,
"failed_items": []
},
"message": "Could not read active configuration in specified node",
"error": 0
}
6 changes: 6 additions & 0 deletions docker/imposter/wazuh-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ resources:
# Get active configuration
- method: GET
path: /agents/{agent_id}/config/{component}/{configuration}
response:
statusCode: 200
scriptFile: agents/configuration.js

# Remove agent from groups
- method: DELETE
Expand Down Expand Up @@ -501,6 +504,9 @@ resources:
# Get active configuration
- method: GET
path: /manager/configuration/{component}/{configuration}
response:
statusCode: 200
scriptFile: manager/configuration.js

# ===================================================== #
# MITRE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ import { webDocumentationLink } from '../../../../../../../common/services/web_d
const columns = [
{ field: 'key', name: 'Label key' },
{ field: 'value', name: 'Label value' },
{ field: 'hidden', name: 'Hidden' }
{ field: 'hidden', name: 'Hidden' },
];

const helpLinks = [
{
text: 'Agent labels',
href: webDocumentationLink('user-manual/capabilities/labels.html')
href: webDocumentationLink('user-manual/agents/labels.html'),
},
{
text: 'Labels reference',
href: webDocumentationLink('user-manual/reference/ossec-conf/labels.html')
}
href: webDocumentationLink('user-manual/reference/ossec-conf/labels.html'),
},
];

class WzConfigurationAlertsLabels extends Component {
Expand All @@ -49,71 +49,34 @@ class WzConfigurationAlertsLabels extends Component {
const { currentConfig, agent, wazuhNotReadyYet } = this.props;
return (
<Fragment>
{currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
] &&
isString(
currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
]
) && (
{currentConfig['agent-labels'] &&
isString(currentConfig['agent-labels']) && (
<WzNoConfig
error={
currentConfig[
agent && agent.id !== '000'
? 'agent-labels'
: 'analysis-labels'
]
}
error={currentConfig['agent-labels']}
help={helpLinks}
/>
)}
{currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
] &&
!isString(
currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
]
) &&
!hasSize(
currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
].labels
) && <WzNoConfig error="not-present" help={helpLinks} />}
{currentConfig['agent-labels'] &&
!isString(currentConfig['agent-labels']) &&
!hasSize(currentConfig['agent-labels'].labels) && (
<WzNoConfig error='not-present' help={helpLinks} />
)}
{wazuhNotReadyYet &&
(!currentConfig ||
!currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
]) && <WzNoConfig error="Wazuh not ready yet" />}
{currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
] &&
!isString(
currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
]
) &&
hasSize(
currentConfig[
agent && agent.id !== '000' ? 'agent-labels' : 'analysis-labels'
].labels
) ? (
(!currentConfig || !currentConfig['agent-labels']) && (
<WzNoConfig error='Wazuh not ready yet' />
)}
{currentConfig['agent-labels'] &&
!isString(currentConfig['agent-labels']) &&
hasSize(currentConfig['agent-labels'].labels) ? (
<WzConfigurationSettingsTabSelector
title="Defined labels"
title='Defined labels'
currentConfig={currentConfig}
minusHeight={agent.id === '000' ? 320 : 355}
helpLinks={helpLinks}
>
<EuiBasicTable
columns={columns}
items={
currentConfig[
agent && agent.id !== '000'
? 'agent-labels'
: 'analysis-labels'
].labels
}
items={currentConfig['agent-labels'].labels}
/>
</WzConfigurationSettingsTabSelector>
) : null}
Expand All @@ -123,7 +86,7 @@ class WzConfigurationAlertsLabels extends Component {
}

const mapStateToProps = state => ({
wazuhNotReadyYet: state.appStateReducers.wazuhNotReadyYet
wazuhNotReadyYet: state.appStateReducers.wazuhNotReadyYet,
});

export default connect(mapStateToProps)(WzConfigurationAlertsLabels);
Expand All @@ -132,15 +95,15 @@ const sectionsAgent = [{ component: 'agent', configuration: 'labels' }];

export const WzConfigurationAlertsLabelsAgent = compose(
connect(mapStateToProps),
withWzConfig(sectionsAgent)
withWzConfig(sectionsAgent),
)(WzConfigurationAlertsLabels);

WzConfigurationAlertsLabels.propTypes = {
// currentConfig: PropTypes.object.isRequired,
wazuhNotReadyYet: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
wazuhNotReadyYet: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
};

WzConfigurationAlertsLabelsAgent.propTypes = {
// currentConfig: PropTypes.object.isRequired,
wazuhNotReadyYet: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
wazuhNotReadyYet: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
};
Loading