Skip to content

feat: replace string-substitution HTML templates with Jinja2 (#51) - #167

Open
jeffrey-theog06 wants to merge 2 commits into
OWASP:mainfrom
jeffrey-theog06:feat/jinja2-html-templates
Open

feat: replace string-substitution HTML templates with Jinja2 (#51)#167
jeffrey-theog06 wants to merge 2 commits into
OWASP:mainfrom
jeffrey-theog06:feat/jinja2-html-templates

Conversation

@jeffrey-theog06

Copy link
Copy Markdown

Closes #51

Overview

Migrated HTML report generation from manual string replacement to Jinja2 with auto-escaping.

Changes

  • Added jinja2>=3.1.0 to requirements.txt and setup.py.
  • Created docksec/templates/report.html.j2 with native loops, conditionals, and auto-escaping.
  • Refactored ReportGenerator.generate_html_report to use jinja2.Environment with select_autoescape.
  • Removed Python-side HTML generation methods and raw {{VAR}} replacements.
  • Added comprehensive unit tests in tests/test_report_generator.py covering loops, empty states, and auto-escaping.

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file reports Changes to report generation config Changes to configuration handling tests Changes to the test suite labels Sep 9, 2026
@jeffrey-theog06
jeffrey-theog06 force-pushed the feat/jinja2-html-templates branch from 6b7bda7 to eb1df42 Compare September 9, 2026 05:16
Comment thread docksec/report_generator.py Outdated

from docksec import output
from docksec.config import RESULTS_DIR, get_html_template
from docksec.config import RESULTS_DIR, TEMPLATES_DIR, get_html_template

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hello @jeffrey-theog06 thank you for the PR. can you please fix this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hello @jeffrey-theog06 thank you for the PR. can you please fix this?

Sure sir.. Will work on it!

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.16129% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.96%. Comparing base (a2fe184) to head (eb1df42).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
docksec/config.py 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   78.95%   80.96%   +2.01%     
==========================================
  Files          26       32       +6     
  Lines        4158     5107     +949     
==========================================
+ Hits         3283     4135     +852     
- Misses        875      972      +97     
Flag Coverage Δ
unittests 80.96% <95.16%> (+2.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeffrey-theog06

Copy link
Copy Markdown
Author

@advaitpatel Sir.. please check and let me know if its a valid fix..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Changes to configuration handling dependencies Pull requests that update a dependency file reports Changes to report generation tests Changes to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Replace string-substitution HTML templates with Jinja2

4 participants