Skip to content

Commit

Permalink
Fix x-pack updating API using incoming request
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesús Ángel committed Sep 7, 2018
1 parent 0161d9e commit 9fb9cc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/controllers/wazuh-api-elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default class WazuhApiElastic {

const settings = this.buildSettingsObject(req.payload);

await this.wzWrapper.updateWazuhIndexDocument(req.payload.id, { doc: settings });
await this.wzWrapper.updateWazuhIndexDocument(req, { doc: settings });

return reply({ statusCode: 200, message: 'ok' });

Expand Down
7 changes: 4 additions & 3 deletions server/lib/elastic-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,12 @@ export default class ElasticWrapper {
* @param {*} id
* @param {*} doc
*/
async updateWazuhIndexDocument(id,doc){
async updateWazuhIndexDocument(req,doc){
try {
if(!id || !doc) return Promise.reject(new Error('No valid parameters given'))
const id = typeof req === 'object' && req.payload ? req.payload.id : req;
if(!id || !doc) throw new Error('No valid parameters given')

const data = await this.elasticRequest.callWithInternalUser('update', {
const data = await this.elasticRequest.callWithRequest(req, 'update', {
index: '.wazuh',
type : 'wazuh-configuration',
id : id,
Expand Down

0 comments on commit 9fb9cc3

Please sign in to comment.