Restricting API request method to GET by default for dev tool feature

This commit is contained in:
Jesús Ángel González 2018-05-11 10:39:37 +02:00
parent 9cbc79d57e
commit b34b397128
2 changed files with 9 additions and 1 deletions

View File

@ -238,7 +238,8 @@ app.controller('devToolsController', function($scope, $rootScope, errorHandler,
}
const path = req.includes('?') ? req.split('?')[0] : req;
const params = req.includes('?') ? parseParams(req.split('?')[1]) : {}
const params = { devTools: true }
if(typeof JSONraw === 'object') JSONraw.devTools = true;
const output = await apiReq.request(method, path, validJSON && !req.includes('?') ? JSONraw : params)
apiOutputBox.setValue(

View File

@ -321,6 +321,13 @@ export default class WazuhApi {
} else if (!req.payload.path) {
return ErrorResponse('Missing param: path', 3016, 400, reply);
} else {
if(req.payload.method !== 'GET' && req.payload.body && req.payload.body.devTools){
const configuration = getConfiguration();
if(!configuration || (configuration && !configuration['devtools.allowall'])){
return ErrorResponse('Allowed method: [GET]', 3023, 400, reply);
}
}
if(req.payload.body.devTools) delete req.payload.body.devTools;
return this.makeRequest(req.payload.method, req.payload.path, req.payload.body, req.payload.id, reply);
}
}