Implement safer ArangoDB queries#8351
Merged
auvipy merged 13 commits intocelery:mainfrom Jul 29, 2023
Merged
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #8351 +/- ##
==========================================
+ Coverage 87.07% 87.32% +0.24%
==========================================
Files 148 148
Lines 18492 18458 -34
Branches 3152 3148 -4
==========================================
+ Hits 16102 16118 +16
+ Misses 2110 2061 -49
+ Partials 280 279 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
fd8a3dd to
29d7990
Compare
auvipy
reviewed
Jul 25, 2023
Member
auvipy
left a comment
There was a problem hiding this comment.
having improved test coverage for all the methods would be great
The AQL queries used in the ArangoDbBackend's implementation are potentially
vulnerable to injections because no sanity checks are performed on the
arguments used to build the query strings.
This is particularly evident when using a database collection with a dash in
its name, e.g. "celery-task-results". The query string generated by the set
method is 'INSERT {task: v}, _key: "k"} INTO celery-task-results' instead of
'INSERT {task: v}, _key: "k"} INTO `celery-task-results`' (backticks
surrounding collection name). The former is evaluated as a substraction
(celery - task - results) and is therefore an illegal collection name,
while the latter is evaluated as a string.
This commit re-implements the setter and getters using bind parameters[1],
which performs the necessary safety checks. Furthermore, the new query used
in the set method accounts for updates to existing keys, resolving celery#7039.
[1] https://www.arangodb.com/docs/stable/aql/fundamentals-bind-parameters.html
for more information, see https://pre-commit.ci
6afa0c4 to
9ae1e38
Compare
c2f7224 to
ad0dedc
Compare
Member
|
are the new changes backward compatible? |
auvipy
approved these changes
Jul 29, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AQL queries used in the ArangoDbBackend's implementation are potentially
vulnerable to injections because no sanity checks are performed on the
arguments used to build the query strings.
This is particularly evident when using a database collection with a dash in
its name, e.g. "celery-task-results". The query string generated by the set
method is 'INSERT {task: v}, _key: "k"} INTO celery-task-results' instead of
'INSERT {task: v}, _key: "k"} INTO
celery-task-results' (backtickssurrounding collection name). The former is evaluated as a substraction
(celery - task - results) and is therefore an illegal collection name,
while the latter is evaluated as a string.
This commit re-implements the setter and getters using bind parameters,
which performs the necessary safety checks. Furthermore, the new query used
in the set method accounts for updates to existing keys, resolving #7039.