From 09173d573d11b173b1ad2c3feacc5ea9512fc6f3 Mon Sep 17 00:00:00 2001 From: sortiz Date: Fri, 12 Feb 2021 18:08:30 +0100 Subject: [PATCH 1/5] empty agent.resolv solved --- .../management/components/files-group-table.js | 2 +- .../management/groups/actions-buttons-files.js | 6 +++++- .../management/groups/utils/columns-files.js | 14 ++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/public/controllers/management/components/files-group-table.js b/public/controllers/management/components/files-group-table.js index 96279e6bba..a2ea6347f3 100644 --- a/public/controllers/management/components/files-group-table.js +++ b/public/controllers/management/components/files-group-table.js @@ -108,7 +108,7 @@ export class FilesInGroupTable extends Component { + onClick={() => this.props.openFileContent( this.state.groupName, item.filename diff --git a/public/controllers/management/components/management/groups/actions-buttons-files.js b/public/controllers/management/components/management/groups/actions-buttons-files.js index 8ab56b2e0b..2a35374dc8 100644 --- a/public/controllers/management/components/management/groups/actions-buttons-files.js +++ b/public/controllers/management/components/management/groups/actions-buttons-files.js @@ -148,10 +148,14 @@ class WzGroupsActionButtonsFiles extends Component { async showGroupConfiguration() { const { itemDetail } = this.props.state; - const result = await this.groupsHandler.getFileContent( + var result = await this.groupsHandler.getFileContent( `/groups/${itemDetail.name}/files/agent.conf/xml` ); + if(Object.keys(result).length == 0){ + result = ''; + } + const data = this.autoFormat(result); const file = { diff --git a/public/controllers/management/components/management/groups/utils/columns-files.js b/public/controllers/management/components/management/groups/utils/columns-files.js index 0ffc5b2e1f..a32b08cf03 100644 --- a/public/controllers/management/components/management/groups/utils/columns-files.js +++ b/public/controllers/management/components/management/groups/utils/columns-files.js @@ -36,10 +36,12 @@ export default class GroupsFilesColumns { aria-label="See file content" iconType="eye" onClick={async () => { - const result = await this.groupsHandler.getFileContent( + var result = await this.groupsHandler.getFileContent( `/groups/${itemDetail.name}/files/${item.filename}/xml` ); - + if (Object.keys(result).length == 0) { + result = ''; + } const isEditable = item.filename === 'agent.conf'; const data = !isEditable ? typeof result === 'object' @@ -109,10 +111,10 @@ export default class GroupsFilesColumns { var type = single ? 'single' : closing - ? 'closing' - : opening - ? 'opening' - : 'other'; + ? 'closing' + : opening + ? 'opening' + : 'other'; var fromTo = lastType + '->' + type; lastType = type; var padding = ''; From 56b82c66ec44e45835e6a857f5f8e62e879c5e3f Mon Sep 17 00:00:00 2001 From: sortiz Date: Mon, 15 Feb 2021 19:58:30 +0100 Subject: [PATCH 2/5] Check server response --- public/react-services/generic-request.js | 2 ++ public/react-services/reporting.js | 3 ++- server/controllers/wazuh-reporting.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/react-services/generic-request.js b/public/react-services/generic-request.js index 239e44810b..960c57282e 100644 --- a/public/react-services/generic-request.js +++ b/public/react-services/generic-request.js @@ -77,12 +77,14 @@ export class GenericRequest { timeout: timeout || 20000 }; } + Object.assign(data, await axios(options)); if (!data) { throw new Error( `Error doing a request to ${tmpUrl}, method: ${method}.` ); } + return data; } catch (err) { OdfeUtils.checkOdfeSessionExpired(err); diff --git a/public/react-services/reporting.js b/public/react-services/reporting.js index e0539b9060..8be2aa423b 100644 --- a/public/react-services/reporting.js +++ b/public/react-services/reporting.js @@ -156,6 +156,7 @@ export class ReportingService { components }; const apiEndpoint = type === 'agentConfig' ? `/reports/agents/${obj.id}` : `/reports/groups/${obj.name}`; + await GenericRequest.request('POST', apiEndpoint, data); this.$rootScope.reportBusy = false; @@ -171,7 +172,7 @@ export class ReportingService { } catch (error) { this.$rootScope.reportBusy = false; this.$rootScope.reportStatus = false; - this.showToast('danger', 'Error', error.message || error, 4000); + this.showToast('danger', 'Error configuring report', error.message || error, 4000); this.$rootScope.$applyAsync(); } } diff --git a/server/controllers/wazuh-reporting.ts b/server/controllers/wazuh-reporting.ts index 28fa251dfb..c889f2220c 100644 --- a/server/controllers/wazuh-reporting.ts +++ b/server/controllers/wazuh-reporting.ts @@ -1233,6 +1233,7 @@ export class WazuhReportingCtrl { text: `Group ${groupID} configuration`, style: 'h1' }); + if (components['0']) { let configuration = {}; try { @@ -1247,7 +1248,11 @@ export class WazuhReportingCtrl { log('reporting:createReportsGroups', error.message || error, 'debug'); }; - if (Object.keys(configuration.affected_items[0].config).length) { + + console.log("configuration.affected_items.length"); + console.log(configuration.affected_items.length); + + if (configuration.affected_items.length>0 && Object.keys(configuration.affected_items[0].config).length) { printer.addContent({ text: 'Configurations', style: { fontSize: 14, color: '#000' }, @@ -1464,7 +1469,7 @@ export class WazuhReportingCtrl { message: `Report ${name} was created` } }) - }catch(error){ + }catch(error){ log('reporting:createReportsGroups', error.message || error); return ErrorResponse(error.message || error, 5029, 500, response); } From 216dbc4793432893dd44240b577e8bc519d08f96 Mon Sep 17 00:00:00 2001 From: sortiz Date: Wed, 17 Feb 2021 12:48:38 +0100 Subject: [PATCH 3/5] Resolve PRs --- CHANGELOG.md | 1 + server/controllers/index.ts | 2 +- server/controllers/wazuh-reporting.ts | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9857e98a1..c16686a852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Fixed +- Can't edit through the app empty rules and decoders files that already exist in the host [#2893](https://github.com/wazuh/wazuh-kibana-app/issues/2893) - Fix server error Invalid token specified: Cannot read property 'replace' of undefined [#2899](https://github.com/wazuh/wazuh-kibana-app/issues/2899) - Fix show empty files rules and decoders: [#2923](https://github.com/wazuh/wazuh-kibana-app/issues/2923) - Fixed wrong hover texts in CDB lists actions [#2929](https://github.com/wazuh/wazuh-kibana-app/pull/2929) diff --git a/server/controllers/index.ts b/server/controllers/index.ts index 591a8f3fe4..6e2a19c79a 100644 --- a/server/controllers/index.ts +++ b/server/controllers/index.ts @@ -13,4 +13,4 @@ export { WazuhElasticCtrl } from './wazuh-elastic'; export { WazuhApiCtrl } from './wazuh-api'; export { WazuhUtilsCtrl } from './wazuh-utils'; export { WazuhReportingCtrl } from './wazuh-reporting'; -export { WazuhHostsCtrl } from './wazuh-hosts' +export { WazuhHostsCtrl } from './wazuh-hosts' \ No newline at end of file diff --git a/server/controllers/wazuh-reporting.ts b/server/controllers/wazuh-reporting.ts index c889f2220c..e028423af0 100644 --- a/server/controllers/wazuh-reporting.ts +++ b/server/controllers/wazuh-reporting.ts @@ -1249,9 +1249,6 @@ export class WazuhReportingCtrl { }; - console.log("configuration.affected_items.length"); - console.log(configuration.affected_items.length); - if (configuration.affected_items.length>0 && Object.keys(configuration.affected_items[0].config).length) { printer.addContent({ text: 'Configurations', From 0f1976e2e8f6f69fa585cf1244d769e95e808aae Mon Sep 17 00:00:00 2001 From: Desvelao Date: Thu, 18 Feb 2021 18:05:48 +0100 Subject: [PATCH 4/5] fix(frontend): Replaced var by let variables in some files --- .../components/management/groups/actions-buttons-files.js | 2 +- .../components/management/groups/utils/columns-files.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/controllers/management/components/management/groups/actions-buttons-files.js b/public/controllers/management/components/management/groups/actions-buttons-files.js index 2a35374dc8..62a311e2ea 100644 --- a/public/controllers/management/components/management/groups/actions-buttons-files.js +++ b/public/controllers/management/components/management/groups/actions-buttons-files.js @@ -148,7 +148,7 @@ class WzGroupsActionButtonsFiles extends Component { async showGroupConfiguration() { const { itemDetail } = this.props.state; - var result = await this.groupsHandler.getFileContent( + let result = await this.groupsHandler.getFileContent( `/groups/${itemDetail.name}/files/agent.conf/xml` ); diff --git a/public/controllers/management/components/management/groups/utils/columns-files.js b/public/controllers/management/components/management/groups/utils/columns-files.js index a32b08cf03..f8e05aa625 100644 --- a/public/controllers/management/components/management/groups/utils/columns-files.js +++ b/public/controllers/management/components/management/groups/utils/columns-files.js @@ -36,7 +36,7 @@ export default class GroupsFilesColumns { aria-label="See file content" iconType="eye" onClick={async () => { - var result = await this.groupsHandler.getFileContent( + let result = await this.groupsHandler.getFileContent( `/groups/${itemDetail.name}/files/${item.filename}/xml` ); if (Object.keys(result).length == 0) { From 59a76b9be46b2af321645ea0ddc290616f785115 Mon Sep 17 00:00:00 2001 From: Desvelao Date: Thu, 18 Feb 2021 18:11:00 +0100 Subject: [PATCH 5/5] fix(changelog): Add PR to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6f8bdfa8..1cd450c26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fix the statusCode error message [#2971](https://github.com/wazuh/wazuh-kibana-app/pull/2971) - Fix the SCA policy stats didn't refresh [#2973](https://github.com/wazuh/wazuh-kibana-app/pull/2973) - Fix some date fields format in FIM and SCA modules [#2975](https://github.com/wazuh/wazuh-kibana-app/pull/2975) +- Can't edit empty rules and decoders files that already exist in the manager [#2978](https://github.com/wazuh/wazuh-kibana-app/pull/2978) ## Wazuh v4.1.0 - Kibana 7.10.0 , 7.10.2 - Revision 4101 @@ -32,7 +33,6 @@ All notable changes to the Wazuh app project will be documented in this file. ### Fixed -- Can't edit through the app empty rules and decoders files that already exist in the host [#2893](https://github.com/wazuh/wazuh-kibana-app/issues/2893) - Fix server error Invalid token specified: Cannot read property 'replace' of undefined [#2899](https://github.com/wazuh/wazuh-kibana-app/issues/2899) - Fix show empty files rules and decoders: [#2923](https://github.com/wazuh/wazuh-kibana-app/issues/2923) - Fixed wrong hover texts in CDB lists actions [#2929](https://github.com/wazuh/wazuh-kibana-app/pull/2929)