Skip to content

fix(export): exclude raw_html from JSON exports when include_raw_html is false - #116

Merged
HC-ONLINE merged 1 commit into
mainfrom
fix/json-export-raw-html-exclusion
Oct 16, 2026
Merged

HC-ONLINE merged 1 commit into
mainfrom
fix/json-export-raw-html-exclusion

Conversation

@HC-ONLINE

Copy link
Copy Markdown
Owner

Pull Request Template

Description

JSONExporter.export_report() serialized the report, stripped scrape.raw_html, then called calculate_summary() and re-serialized the report — discarding the cleanup and leaking raw HTML into exports even with include_raw_html: false. Additionally, BaseExporter._serialize_item() only removed the top-level raw_html key, never the nested data["scrape"]["raw_html"] found in AnalysisReport exports (e.g. quick).

Changes:

  • export/json.py — export_report() now runs calculate_summary() before the single serialization; the redundant post-serialization cleanup block was removed. Controls (_started, _finalized, ExportWriteError, stream/file writing) are unchanged.
  • export/base.py — _serialize_item() strips raw_html from both the top level and the nested scrape mapping (copying the sub-dict first so caller-owned plain dicts are never mutated). Handles absent/null/non-mapping scrape without raising. include_raw and exclude_none semantics untouched.

Verified end-to-end via CLI against a local loopback server: with CIBERWEBSCAN_EXPORT_INCLUDE_RAW_HTML=false the exported JSON contains no raw_html key; with true it is present. All other scrape fields remain intact.

Related Issue

None — found during internal code audit.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have followed the style guidelines of this project (Ruff & Pyright)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly

Screenshots (if applicable)

N/A — backend/export change.

@HC-ONLINE
HC-ONLINE merged commit 545d249 into main Oct 16, 2026
8 checks passed
@HC-ONLINE
HC-ONLINE deleted the fix/json-export-raw-html-exclusion branch October 16, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant