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

empty agents.conf error and export error #2978

Merged
merged 6 commits into from
Feb 18, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class FilesInGroupTable extends Component {
<EuiToolTip position="right" content="See file content">
<EuiButtonIcon
aria-label="See file content"
onClick={() =>
onClick={() =>
this.props.openFileContent(
this.state.groupName,
item.filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = '';
Expand Down
2 changes: 2 additions & 0 deletions public/react-services/generic-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion public/react-services/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 4 additions & 2 deletions server/controllers/wazuh-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@ export class WazuhReportingCtrl {
text: `Group ${groupID} configuration`,
style: 'h1'
});

if (components['0']) {
let configuration = {};
try {
Expand All @@ -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' },
Expand Down Expand Up @@ -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);
}
Expand Down