-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix purge filter in DELETE/agents #122
Conversation
d2455a9
to
8567fc1
Compare
8567fc1
to
53dbe65
Compare
@@ -942,9 +942,9 @@ router.delete('/groups/:group_id', function(req, res) { | |||
router.delete('/', function(req, res) { | |||
logger.debug(req.connection.remoteAddress + " DELETE /agents"); | |||
|
|||
var data_request = { 'function': 'DELETE/agents/', 'arguments': {} }; | |||
var filter_body = { 'ids': 'array_numbers', 'purge': 'boolean' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the purge
argument be removed from the body
? If it is sent in a JSON, the request will fail. I think it could be much better to accept the argument in the body and in the query.
controllers/agents.js
Outdated
@@ -957,7 +957,7 @@ router.delete('/', function(req, res) { | |||
return; | |||
} | |||
|
|||
data_request['arguments']['purge'] = 'purge' in req.body && (req.body['purge'] == true || req.body['purge'] == 'true'); | |||
data_request['arguments']['purge'] = 'purge' in req.query && (req.query.purge == 'true' || req.query.purge == ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the purge
argument is present in the query:
- It can be
'true'
. - It can be empty.
If it is present in the body:
- It can be
true
. - It can be
'true'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's allow the purge in both places: query and body. The most restrictive wins.
Hi team,
this PR fixes
purge
filter inDELETE/agents
(issue #121).Sample
Regards,
Javi.