Skip to content

[report] Harden data access for reports - #13111

Merged
SchrodingersGat merged 8 commits into
inventree:masterfrom
SchrodingersGat:report-security
Oct 27, 2026
Merged

SchrodingersGat merged 8 commits into
inventree:masterfrom
SchrodingersGat:report-security

Conversation

@SchrodingersGat

Copy link
Copy Markdown
Member
  • Exclude sensitive data
  • Prevent database writes during report generation

- Exclude sensitive data
- Prevent database writes during report generation
@SchrodingersGat SchrodingersGat added this to the 1.7.0 milestone Oct 27, 2026
@SchrodingersGat SchrodingersGat added report Report/Label generation security Relates to a security issue labels Oct 27, 2026
@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 3e0944b
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6ae07d87527727fc7f38aedd
😎 Deploy Preview https://deploy-preview-13111--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 92 (🔴 down 2 from production)
Accessibility: 82 (🟢 up 1 from production)
Best Practices: 92 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat

Copy link
Copy Markdown
Member Author

@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

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.93878% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.87%. Comparing base (4f80cda) to head (3e0944b).

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              
Flag Coverage Δ
backend 91.18% <96.93%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.72% <96.93%> (+<0.01%) ⬆️
Backend General 94.78% <ø> (ø)
Frontend 79.50% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The restrictions leave write and sensitive-data access gaps and can break normal rendering when settings are missing.

5 open issues
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

Comment thread src/backend/InvenTree/report/models.py Resolved

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm; is this also applied to labels?

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Lgtm; is this also applied to labels?

Yes, reports and labels are the same

@SchrodingersGat
SchrodingersGat merged commit 3e55d41 into inventree:master Oct 27, 2026
48 checks passed
@SchrodingersGat
SchrodingersGat deleted the report-security branch October 27, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

report Report/Label generation security Relates to a security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants