Skip to content

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

Merged
advaitpatel merged 2 commits into
OWASP:mainfrom
jeffrey-theog06:feat/jinja2-html-templates
Sep 11, 2026
Merged

advaitpatel merged 2 commits into
OWASP:mainfrom
jeffrey-theog06:feat/jinja2-html-templates

Conversation

@jeffrey-theog06

Copy link
Copy Markdown
Contributor

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
Contributor 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

codecov-commenter commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.06%. Comparing base (a2fe184) to head (741a9e6).
⚠️ Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   78.95%   81.06%   +2.11%     
==========================================
  Files          26       32       +6     
  Lines        4158     5118     +960     
==========================================
+ Hits         3283     4149     +866     
- Misses        875      969      +94     
Flag Coverage Δ
unittests 81.06% <100.00%> (+2.11%) ⬆️

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
Contributor Author

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

@advaitpatel advaitpatel left a comment

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.

lgtm

@advaitpatel
advaitpatel merged commit 1a09a2f into OWASP:main Sep 11, 2026
11 checks passed
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