Repository navigation
[report] Harden data access for reports - #13111
Conversation
SchrodingersGat
commented
Oct 27, 2026
- Exclude sensitive data
- Prevent database writes during report generation
- Exclude sensitive data - Prevent database writes during report generation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@matmair LMK what you think here. While the underlying fallback is still "report templates are trusted" - this prevents exfiltration of sensitive data via reports |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #13111 +/- ##
==========================================
+ Coverage 86.86% 86.87% +0.01%
==========================================
Files 1560 1561 +1
Lines 110194 110283 +89
Branches 11987 11987
==========================================
+ Hits 95715 95804 +89
Misses 14413 14413
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The restrictions leave write and sensitive-data access gaps and can break normal rendering when settings are missing.
5 open issues
Report currency formatting fails when precision settings are absent · New Webhook credentials and headers remain exposed by model filtering · New PluginUserSetting remains exposed through denylist gaps · New Allowing WITH-prefixed writes bypasses read-only SQL guard · New Warm caches bypass PluginSetting restriction in setting_object · New
What changed in this PR
This PR hardens InvenTree’s report and label rendering by restricting database writes and access to sensitive models, while retaining the trusted-template model.
Changes:
- Adds database guards around template and filename rendering.
- Blocks selected sensitive models in database queries and
filter_db_model. - Adds restriction tests and documents the intended protections.
| File | Description |
|---|---|
src/backend/InvenTree/report/tests.py |
Tests blocked models, writes, relation traversal, and normal reads. |
src/backend/InvenTree/report/templatetags/report.py |
Rejects blocked models in filter_db_model. |
src/backend/InvenTree/report/security.py |
Defines restricted models and database execution guards. |
src/backend/InvenTree/report/models.py |
Applies guards to template and filename rendering. |
docs/docs/report/helpers.md |
Documents restrictions and trusted-template assumptions. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
matmair
left a comment
There was a problem hiding this comment.
Lgtm; is this also applied to labels?
Yes, reports and labels are the same |

