Open alxndrsn opened 3 years ago
@alxndrsn Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
I've opened a PR to fix this at https://github.com/balderdashy/sails-hook-orm/pull/22, but there are other instances of the same/similar technique in:
waterline
: https://github.com/balderdashy/waterline/blob/master/lib/waterline/methods/stream.js#L379, https://github.com/balderdashy/waterline/blob/master/lib/waterline/methods/stream.js#L431skipper
: https://github.com/sailshq/skipper/blob/master/lib/skipper.js#L63sails
core: https://github.com/balderdashy/sails/blob/master/lib/app/private/bootstrap.js#L68, https://github.com/balderdashy/sails/blob/master/lib/hooks/index.js#L211, https://github.com/balderdashy/sails/blob/master/lib/router/bind.js#L233, https://github.com/balderdashy/sails/blob/master/lib/router/bind.js#L369machine
: https://github.com/node-machine/machine/blob/master/lib/private/normalize-machine-def.jsparley
: https://github.com/mikermcneil/parley/blob/master/lib/parley.js#L373, https://github.com/mikermcneil/parley/blob/master/lib/private/Deferred.js#L1325-L1328parasails
: https://github.com/mikermcneil/parasails/blob/master/dist/cloud.js#L1200anchor
: https://github.com/sailshq/anchor/blob/master/lib/rules.js#L303This suggests there might be surprising behaviour in other places than just datastore.transaction()
.
I'd be happy to provide PRs for some of these other packages if https://github.com/balderdashy/sails-hook-orm/pull/22 is accepted.
Hi @alxndrsn, the code in the files you link is to determine whether or not a function is async. Due to the ad hoc way Sails sniffs async functions and function arguments, it doesn't support certain shorthand for passing in functions. Would you mind explaining how these files relate to this issue, and are you running into issues with this when you use documented syntax?
it doesn't support certain shorthand for passing in functions
@eashaw :+1: that's the cause of the reported bug, which is fixed in my PR
Hi @eashaw, just revisiting this.
Given the expectations around transactional guarantees when working with databases, I think it's dangerously misleading that during
may be silently executed outside a database transaction.
It would be great if either a fix can be applied, or the documentation can be updated to warn about this possibility.
I suspect the sails-mysql
adapter is also affected by this, although I haven't had a chance to test this yet.
Node version:
14.15.0
Sails version (sails):1.4.0
ORM hook version (sails-hook-orm):2.1.1
DB adapter & version (e.g. sails-mysql@5.55.5):sails-postgresql@2.0.0
Observed
Calling
datastore.transaction(during)
when using thesails-postgresql
adapter for Waterline doesn't guarantee thatduring
will be run inside a database transaction.If there is no transaction-specific code in the executed SQL, the
during
code will complete without error, so the user may not be aware that their query or queries were not transactional.Steps to recreate
Example project: https://github.com/alxndrsn/sailsjs-postgres-transactions-maybe
Maybe related to https://github.com/balderdashy/sails/pull/7017.