diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e69e2d9e0..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 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..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,10 +148,14 @@ class WzGroupsActionButtonsFiles extends Component { async showGroupConfiguration() { const { itemDetail } = this.props.state; - const result = await this.groupsHandler.getFileContent( + let 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..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,10 +36,12 @@ export default class GroupsFilesColumns { aria-label="See file content" iconType="eye" onClick={async () => { - const result = await this.groupsHandler.getFileContent( + let 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 = ''; 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/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 28fa251dfb..e028423af0 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,8 @@ export class WazuhReportingCtrl { log('reporting:createReportsGroups', error.message || error, 'debug'); }; - if (Object.keys(configuration.affected_items[0].config).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 +1466,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); }