-
- Downloads
[FIX] test_lint: support fstrings in sql injection checker
Those were not accounted for, leading to fstrings passing through
unflagged.
Also update the SQL checker to be stricter but smarter:
The previous version would "fail open", unknown nodes would be allowed
through hence f-strings not being flagged when they started appearing
in arg0 position, should now fail-closed, anything that's not allowed
is forbidden.
This flags a few more cases, all of which seem acceptable upon review.
However the previous version would also only resolve arg0 (in case it
had a `NAME`, to see if that resolved to an acceptable form of
query-building). The new version performs resolution during
`_check_concatenation` and should thus allow e.g. format strings to be
separate variables (though not e.g. module-level constants, yet
anyway).
In resolution, replace the ad-hoc process by astroid's built-in
`lookup` which seems to provide the same information. Slightly more in
fact, as it yields every assignment in case of e.g. conditionals, but
making use of that would require a lot more changes in the checker so
leaving the behaviour as-is for now.
It's important to *not* use `ilookup` here, because ilookup is not
"iterable" but "inferring", and we don't want values, we want
expression ASTs for analysis.
NOTE: previous improvements as well as fixes to existing code were
only implemented in 14.0, hence this being merged in 14.0 not 13.0
despite 13.0 still being supported.
closes odoo/odoo#81639
Signed-off-by:
Xavier Morel (xmo) <xmo@odoo.com>
Showing
- addons/sale/report/report_all_channels_sales.py 2 additions, 2 deletionsaddons/sale/report/report_all_channels_sales.py
- odoo/addons/base/models/ir_ui_view.py 0 additions, 1 deletionodoo/addons/base/models/ir_ui_view.py
- odoo/addons/base/models/res_users.py 8 additions, 2 deletionsodoo/addons/base/models/res_users.py
- odoo/addons/base/wizard/base_partner_merge.py 1 addition, 1 deletionodoo/addons/base/wizard/base_partner_merge.py
- odoo/addons/test_lint/tests/__init__.py 1 addition, 0 deletionsodoo/addons/test_lint/tests/__init__.py
- odoo/addons/test_lint/tests/_odoo_checker_sql_injection.py 33 additions, 30 deletionsodoo/addons/test_lint/tests/_odoo_checker_sql_injection.py
- odoo/addons/test_lint/tests/test_checkers.py 91 additions, 0 deletionsodoo/addons/test_lint/tests/test_checkers.py
- odoo/modules/db.py 1 addition, 1 deletionodoo/modules/db.py
- odoo/tools/convert.py 1 addition, 1 deletionodoo/tools/convert.py
Loading
Please register or sign in to comment