doxtr-secops 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. doxtr_secops-0.1.0/LICENSE +21 -0
  2. doxtr_secops-0.1.0/PKG-INFO +84 -0
  3. doxtr_secops-0.1.0/README.md +48 -0
  4. doxtr_secops-0.1.0/doxtr_secops/__init__.py +182 -0
  5. doxtr_secops-0.1.0/doxtr_secops/builders/__init__.py +37 -0
  6. doxtr_secops-0.1.0/doxtr_secops/builders/confluence.py +60 -0
  7. doxtr_secops-0.1.0/doxtr_secops/builders/epub.py +67 -0
  8. doxtr_secops-0.1.0/doxtr_secops/builders/html.py +105 -0
  9. doxtr_secops-0.1.0/doxtr_secops/builders/latex.py +140 -0
  10. doxtr_secops-0.1.0/doxtr_secops/directives.py +554 -0
  11. doxtr_secops-0.1.0/doxtr_secops/engine.py +960 -0
  12. doxtr_secops-0.1.0/doxtr_secops/links.py +103 -0
  13. doxtr_secops-0.1.0/doxtr_secops/loader.py +719 -0
  14. doxtr_secops-0.1.0/doxtr_secops/model.py +262 -0
  15. doxtr_secops-0.1.0/doxtr_secops/nodes.py +13 -0
  16. doxtr_secops-0.1.0/doxtr_secops/periods.py +189 -0
  17. doxtr_secops-0.1.0/doxtr_secops/renderers/__init__.py +26 -0
  18. doxtr_secops-0.1.0/doxtr_secops/renderers/summary.py +457 -0
  19. doxtr_secops-0.1.0/doxtr_secops/renderers/table.py +488 -0
  20. doxtr_secops-0.1.0/doxtr_secops/renderers/timeline.py +616 -0
  21. doxtr_secops-0.1.0/doxtr_secops/static/secops.css +284 -0
  22. doxtr_secops-0.1.0/doxtr_secops/static/secops.js +237 -0
  23. doxtr_secops-0.1.0/doxtr_secops/theme_adapter.py +168 -0
  24. doxtr_secops-0.1.0/doxtr_secops/versions.py +265 -0
  25. doxtr_secops-0.1.0/doxtr_secops.egg-info/PKG-INFO +84 -0
  26. doxtr_secops-0.1.0/doxtr_secops.egg-info/SOURCES.txt +35 -0
  27. doxtr_secops-0.1.0/doxtr_secops.egg-info/dependency_links.txt +1 -0
  28. doxtr_secops-0.1.0/doxtr_secops.egg-info/requires.txt +22 -0
  29. doxtr_secops-0.1.0/doxtr_secops.egg-info/top_level.txt +1 -0
  30. doxtr_secops-0.1.0/pyproject.toml +72 -0
  31. doxtr_secops-0.1.0/setup.cfg +4 -0
  32. doxtr_secops-0.1.0/tests/test_engine.py +166 -0
  33. doxtr_secops-0.1.0/tests/test_loader.py +129 -0
  34. doxtr_secops-0.1.0/tests/test_periods.py +53 -0
  35. doxtr_secops-0.1.0/tests/test_renderers.py +118 -0
  36. doxtr_secops-0.1.0/tests/test_sphinx_builders.py +295 -0
  37. doxtr_secops-0.1.0/tests/test_versions.py +62 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jens Frey / Doxtr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: doxtr-secops
3
+ Version: 0.1.0
4
+ Summary: Multi-team security advisory, CVE, bug bounty, risk, and incident remediation tracker extension for Sphinx with CSV/XLSX/ODS inputs and doxtr-roadmap PI/sprint integration.
5
+ Author: Jens Frey
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/doxtr/doxtr-secops
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Framework :: Sphinx :: Extension
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: sphinx>=5.0
16
+ Requires-Dist: docutils>=0.18
17
+ Requires-Dist: doxtr-data-core>=0.1.0
18
+ Requires-Dist: packaging>=23.0
19
+ Requires-Dist: openpyxl>=3.1
20
+ Requires-Dist: odfpy>=1.4
21
+ Provides-Extra: roadmap
22
+ Requires-Dist: doxtr-roadmap>=0.3.0; extra == "roadmap"
23
+ Requires-Dist: sphinxcontrib-plantuml>=0.9; extra == "roadmap"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
27
+ Requires-Dist: doxtr-xlink>=2.1.0; extra == "dev"
28
+ Requires-Dist: doxtr-roadmap>=0.3.0; extra == "dev"
29
+ Requires-Dist: sphinxcontrib-plantuml>=0.9; extra == "dev"
30
+ Requires-Dist: doxtr-theme-core>=0.5.0; extra == "dev"
31
+ Requires-Dist: doxtr-pdf-theme-core>=2.2.0; extra == "dev"
32
+ Requires-Dist: doxtr-html-theme-core>=0.5.0; extra == "dev"
33
+ Requires-Dist: doxtr-epub-theme-core>=0.4.0; extra == "dev"
34
+ Requires-Dist: sphinxcontrib-confluencebuilder>=2.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # doxtr-secops
38
+
39
+ Multi-team security advisory, CVE, bug bounty, risk, and incident remediation tracker extension for Sphinx, integrated with `doxtr-data-core`, `doxtr-roadmap`, `doxtr-theme-core`, and `doxtr-xlink`.
40
+
41
+ ## Features
42
+
43
+ - **Unified Finding Types**: Tracks `cve`, `advisory`, `bug_bounty`, `risk`, and `incident` findings against targets and rebranded internal products.
44
+ - **CVE & Offline Metadata Support**: First-class `cve` item type, optional `cve_ids`, `cvss_score`, `cvss_vector`, `cwe`, `kev`, and `epss` metadata, and offline CVE linking via `doxtr-xlink` or configurable URL templates (defaulting to NVD).
45
+ - **Spreadsheet Backends**: Loads `targets`, `items`, and `remediations` from a directory of CSV/TSV files, a single `.xlsx` / `.xlsm` / `.ods` / `.fods` workbook, or explicit mixed file overrides.
46
+ - **Automated Exposure Synthesis**: Evaluates `affected_components` and `affected_versions` (PEP-440/SemVer comparator ranges and natural-version fallbacks) against `targets.components` and synthesizes implied open (`unpatched`) rows when no remediation entry exists.
47
+ - **doxtr-roadmap PI/Sprint Integration**: Resolves `planned_pi`, `planned_sprint`, and `planned_date` against shared `doxtr_period_calendars` / `doxtr_roadmap_period_calendars` / `doxtr_secops_period_calendars` and renders PlantUML Gantt timelines (`doxtr-roadmap`) or native inline SVG timelines.
48
+ - **Secops Directives & Inline Role**:
49
+ - `.. secops-view::` (unified view with `:view: table | matrix | summary | timeline`)
50
+ - `.. secops-table::`, `.. secops-matrix::`, `.. secops-summary::`, `.. secops-timeline::`
51
+ - `:secops:` inline role for live metrics or item/target references
52
+ - **Build-Time Guardrails**: Detects broken foreign keys, duplicate remediation keys, invalid statuses/dates, inconsistent lifecycle dates, overdue open items, and unplanned open items past grace period (with `:strict:` / `doxtr_secops_strict` CI mode).
53
+ - **Full Doxtr Builder Matrix**: HTML (interactive sort/filter + light/dark `doxtr-theme-core`), LaTeX/PDF (`doxtr-pdf-theme-core`), EPUB (strict XHTML5 + `doxtr-epub-theme-core`), and Confluence (`sphinxcontrib-confluencebuilder`).
54
+
55
+ ## Quickstart
56
+
57
+ Add `doxtr_secops` to `extensions` in `conf.py`:
58
+
59
+ ```python
60
+ extensions = [
61
+ "doxtr_secops",
62
+ "doxtr_roadmap", # optional for PlantUML timeline rendering
63
+ ]
64
+
65
+ doxtr_secops_source = "data/secops" # directory of CSVs or path to .xlsx/.ods workbook
66
+ doxtr_period_calendars = {
67
+ "current-pi": {"file": "data/pi_sprints.csv", "section": "PI"},
68
+ }
69
+ ```
70
+
71
+ Then embed live security views in any `.rst` page:
72
+
73
+ ```rst
74
+ .. secops-summary:: Organization Security Posture
75
+ :group-by: team
76
+
77
+ .. secops-view:: Open Critical & High Exposures
78
+ :state: open
79
+ :severity: critical,high
80
+ :view: table
81
+
82
+ .. secops-timeline:: Remediation Roadmap
83
+ :group-by: pi
84
+ ```
@@ -0,0 +1,48 @@
1
+ # doxtr-secops
2
+
3
+ Multi-team security advisory, CVE, bug bounty, risk, and incident remediation tracker extension for Sphinx, integrated with `doxtr-data-core`, `doxtr-roadmap`, `doxtr-theme-core`, and `doxtr-xlink`.
4
+
5
+ ## Features
6
+
7
+ - **Unified Finding Types**: Tracks `cve`, `advisory`, `bug_bounty`, `risk`, and `incident` findings against targets and rebranded internal products.
8
+ - **CVE & Offline Metadata Support**: First-class `cve` item type, optional `cve_ids`, `cvss_score`, `cvss_vector`, `cwe`, `kev`, and `epss` metadata, and offline CVE linking via `doxtr-xlink` or configurable URL templates (defaulting to NVD).
9
+ - **Spreadsheet Backends**: Loads `targets`, `items`, and `remediations` from a directory of CSV/TSV files, a single `.xlsx` / `.xlsm` / `.ods` / `.fods` workbook, or explicit mixed file overrides.
10
+ - **Automated Exposure Synthesis**: Evaluates `affected_components` and `affected_versions` (PEP-440/SemVer comparator ranges and natural-version fallbacks) against `targets.components` and synthesizes implied open (`unpatched`) rows when no remediation entry exists.
11
+ - **doxtr-roadmap PI/Sprint Integration**: Resolves `planned_pi`, `planned_sprint`, and `planned_date` against shared `doxtr_period_calendars` / `doxtr_roadmap_period_calendars` / `doxtr_secops_period_calendars` and renders PlantUML Gantt timelines (`doxtr-roadmap`) or native inline SVG timelines.
12
+ - **Secops Directives & Inline Role**:
13
+ - `.. secops-view::` (unified view with `:view: table | matrix | summary | timeline`)
14
+ - `.. secops-table::`, `.. secops-matrix::`, `.. secops-summary::`, `.. secops-timeline::`
15
+ - `:secops:` inline role for live metrics or item/target references
16
+ - **Build-Time Guardrails**: Detects broken foreign keys, duplicate remediation keys, invalid statuses/dates, inconsistent lifecycle dates, overdue open items, and unplanned open items past grace period (with `:strict:` / `doxtr_secops_strict` CI mode).
17
+ - **Full Doxtr Builder Matrix**: HTML (interactive sort/filter + light/dark `doxtr-theme-core`), LaTeX/PDF (`doxtr-pdf-theme-core`), EPUB (strict XHTML5 + `doxtr-epub-theme-core`), and Confluence (`sphinxcontrib-confluencebuilder`).
18
+
19
+ ## Quickstart
20
+
21
+ Add `doxtr_secops` to `extensions` in `conf.py`:
22
+
23
+ ```python
24
+ extensions = [
25
+ "doxtr_secops",
26
+ "doxtr_roadmap", # optional for PlantUML timeline rendering
27
+ ]
28
+
29
+ doxtr_secops_source = "data/secops" # directory of CSVs or path to .xlsx/.ods workbook
30
+ doxtr_period_calendars = {
31
+ "current-pi": {"file": "data/pi_sprints.csv", "section": "PI"},
32
+ }
33
+ ```
34
+
35
+ Then embed live security views in any `.rst` page:
36
+
37
+ ```rst
38
+ .. secops-summary:: Organization Security Posture
39
+ :group-by: team
40
+
41
+ .. secops-view:: Open Critical & High Exposures
42
+ :state: open
43
+ :severity: critical,high
44
+ :view: table
45
+
46
+ .. secops-timeline:: Remediation Roadmap
47
+ :group-by: pi
48
+ ```
@@ -0,0 +1,182 @@
1
+ """Sphinx extension entry point for ``doxtr-secops``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.util
6
+ from pathlib import Path
7
+ from typing import Any, Dict
8
+
9
+ from docutils import nodes
10
+ from sphinx.util import logging
11
+
12
+ from doxtr_data_core import add_config_value_if_missing
13
+
14
+ from .builders import (
15
+ SecopsConfluencePostTransform,
16
+ SecopsEpubPostTransform,
17
+ SecopsHtmlPostTransform,
18
+ SecopsLatexPostTransform,
19
+ depart_secops_noop,
20
+ register_latex_preamble,
21
+ visit_secops_summary_epub,
22
+ visit_secops_summary_html,
23
+ visit_secops_summary_latex,
24
+ visit_secops_timeline_svg_epub,
25
+ visit_secops_timeline_svg_html,
26
+ visit_secops_timeline_svg_latex,
27
+ )
28
+ from .directives import (
29
+ SecopsMatrixDirective,
30
+ SecopsSummaryDirective,
31
+ SecopsTableDirective,
32
+ SecopsTimelineDirective,
33
+ SecopsViewDirective,
34
+ secops_role,
35
+ )
36
+ from .links import DEFAULT_CVE_URL_TEMPLATE
37
+ from .nodes import secops_summary_node, secops_timeline_svg_node
38
+ from .renderers.summary import build_summary_docutils_nodes
39
+ from .renderers.timeline import build_timeline_docutils_nodes
40
+
41
+ __version__ = "0.1.0"
42
+
43
+ logger = logging.getLogger(__name__)
44
+
45
+
46
+ def _autoload_theme_core(app: Any) -> None:
47
+ if not getattr(app.config, "doxtr_secops_autoload_theme_core", True):
48
+ return
49
+ if importlib.util.find_spec("doxtr_theme_core") is None:
50
+ return
51
+ try:
52
+ app.setup_extension("doxtr_theme_core")
53
+ except Exception as exc: # pragma: no cover
54
+ logger.debug("[doxtr-secops] could not auto-load doxtr_theme_core: %s", exc)
55
+
56
+
57
+ def _register_static_assets(app: Any) -> None:
58
+ builder = getattr(app, "builder", None)
59
+ bname = getattr(builder, "name", "") if builder else ""
60
+ bfmt = getattr(builder, "format", "") if builder else ""
61
+
62
+ static_dir = str((Path(__file__).resolve().parent / "static"))
63
+ if hasattr(app.config, "html_static_path"):
64
+ if static_dir not in app.config.html_static_path:
65
+ app.config.html_static_path.append(static_dir)
66
+
67
+ if bfmt == "html" or bname in ("html", "dirhtml", "singlehtml", "readthedocs", "epub", "epub3"):
68
+ app.add_css_file("secops.css")
69
+
70
+ if bname in ("html", "dirhtml", "singlehtml", "readthedocs"):
71
+ app.add_js_file("secops.js")
72
+
73
+
74
+ def _reset_build_state(app: Any) -> None:
75
+ env = getattr(app, "env", None)
76
+ if env is not None:
77
+ env._doxtr_secops_cache = {}
78
+ env._doxtr_secops_warned = set()
79
+
80
+
81
+ def _visit_summary_text(visitor: Any, node: nodes.Node) -> None:
82
+ lines = [f"[{node.get('title', 'Secops Summary')}]"]
83
+ metrics = node["metrics"]
84
+ ov = metrics.overall
85
+ lines.append(
86
+ f"Total: {ov.total}, Open: {ov.open_count}, Closed: {ov.closed_count}, "
87
+ f"Overdue: {ov.overdue_count}, Mean TTF: {ov.ttf_avg_days}"
88
+ )
89
+ visitor.add_text("\n".join(lines) + "\n")
90
+ raise nodes.SkipNode
91
+
92
+
93
+ def _visit_timeline_text(visitor: Any, node: nodes.Node) -> None:
94
+ _ = build_timeline_docutils_nodes(
95
+ node["exposures"],
96
+ group_by=node.get("group_by", "team"),
97
+ title=node.get("title", "Security Remediation Timeline"),
98
+ )
99
+ visitor.add_text(f"[{node.get('title', 'Security Remediation Timeline')}: {len(node['exposures'])} items]\n")
100
+ raise nodes.SkipNode
101
+
102
+
103
+ def _visit_noop_other(visitor: Any, node: nodes.Node) -> None:
104
+ _ = build_summary_docutils_nodes # keeps symbol imported cleanly
105
+ raise nodes.SkipNode
106
+
107
+
108
+ def setup(app: Any) -> Dict[str, Any]:
109
+ """Sphinx extension entry point for ``doxtr_secops``."""
110
+ try:
111
+ app.setup_extension("doxtr_data_core")
112
+ except Exception as exc: # pragma: no cover
113
+ logger.debug("[doxtr-secops] could not setup doxtr_data_core: %s", exc)
114
+
115
+ add_config_value_if_missing(app, "doxtr_secops_source", None, "env")
116
+ add_config_value_if_missing(app, "doxtr_secops_targets", None, "env")
117
+ add_config_value_if_missing(app, "doxtr_secops_items", None, "env")
118
+ add_config_value_if_missing(app, "doxtr_secops_remediations", None, "env")
119
+ add_config_value_if_missing(app, "doxtr_secops_strict", False, "env", types=(bool,))
120
+ add_config_value_if_missing(app, "doxtr_secops_fail_on", [], "env", types=(list, tuple))
121
+ add_config_value_if_missing(app, "doxtr_secops_grace_days", 14, "env", types=(int,))
122
+ add_config_value_if_missing(app, "doxtr_secops_today", None, "env")
123
+ add_config_value_if_missing(
124
+ app,
125
+ "doxtr_secops_cve_url_template",
126
+ DEFAULT_CVE_URL_TEMPLATE,
127
+ "env",
128
+ types=(str,),
129
+ )
130
+ add_config_value_if_missing(app, "doxtr_secops_ticket_url_template", "", "env", types=(str,))
131
+ add_config_value_if_missing(app, "doxtr_secops_interactive", True, "env", types=(bool,))
132
+ add_config_value_if_missing(app, "doxtr_secops_timeline_renderer", "auto", "env", types=(str,))
133
+ add_config_value_if_missing(app, "doxtr_secops_period_calendars", {}, "env", types=(dict,))
134
+ add_config_value_if_missing(app, "doxtr_secops_period_calendars_options", {}, "env", types=(dict,))
135
+ add_config_value_if_missing(app, "doxtr_secops_period_resolver_hooks", [], "env", types=(list, tuple))
136
+ add_config_value_if_missing(app, "doxtr_secops_business_days", None, "env")
137
+ add_config_value_if_missing(app, "doxtr_secops_query_functions", {}, "env", types=(dict,))
138
+ add_config_value_if_missing(app, "doxtr_secops_autoload_theme_core", True, "env", types=(bool,))
139
+ add_config_value_if_missing(app, "doxtr_secops_use_theme_core", "auto", "env")
140
+
141
+ _autoload_theme_core(app)
142
+
143
+ app.add_node(
144
+ secops_summary_node,
145
+ html=(visit_secops_summary_html, depart_secops_noop),
146
+ latex=(visit_secops_summary_latex, depart_secops_noop),
147
+ epub=(visit_secops_summary_epub, depart_secops_noop),
148
+ text=(_visit_summary_text, depart_secops_noop),
149
+ man=(_visit_noop_other, depart_secops_noop),
150
+ texinfo=(_visit_noop_other, depart_secops_noop),
151
+ )
152
+ app.add_node(
153
+ secops_timeline_svg_node,
154
+ html=(visit_secops_timeline_svg_html, depart_secops_noop),
155
+ latex=(visit_secops_timeline_svg_latex, depart_secops_noop),
156
+ epub=(visit_secops_timeline_svg_epub, depart_secops_noop),
157
+ text=(_visit_timeline_text, depart_secops_noop),
158
+ man=(_visit_noop_other, depart_secops_noop),
159
+ texinfo=(_visit_noop_other, depart_secops_noop),
160
+ )
161
+
162
+ app.add_directive("secops-view", SecopsViewDirective)
163
+ app.add_directive("secops-table", SecopsTableDirective)
164
+ app.add_directive("secops-matrix", SecopsMatrixDirective)
165
+ app.add_directive("secops-summary", SecopsSummaryDirective)
166
+ app.add_directive("secops-timeline", SecopsTimelineDirective)
167
+ app.add_role("secops", secops_role)
168
+
169
+ app.add_post_transform(SecopsHtmlPostTransform)
170
+ app.add_post_transform(SecopsLatexPostTransform)
171
+ app.add_post_transform(SecopsEpubPostTransform)
172
+ app.add_post_transform(SecopsConfluencePostTransform)
173
+
174
+ app.connect("config-inited", register_latex_preamble, priority=920)
175
+ app.connect("builder-inited", _reset_build_state)
176
+ app.connect("builder-inited", _register_static_assets)
177
+
178
+ return {
179
+ "version": __version__,
180
+ "parallel_read_safe": True,
181
+ "parallel_write_safe": True,
182
+ }
@@ -0,0 +1,37 @@
1
+ """Builder-specific Sphinx post-transforms and node visitors for ``doxtr-secops``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .confluence import SecopsConfluencePostTransform
6
+ from .epub import (
7
+ SecopsEpubPostTransform,
8
+ visit_secops_summary_epub,
9
+ visit_secops_timeline_svg_epub,
10
+ )
11
+ from .html import (
12
+ SecopsHtmlPostTransform,
13
+ depart_secops_noop,
14
+ visit_secops_summary_html,
15
+ visit_secops_timeline_svg_html,
16
+ )
17
+ from .latex import (
18
+ SecopsLatexPostTransform,
19
+ register_latex_preamble,
20
+ visit_secops_summary_latex,
21
+ visit_secops_timeline_svg_latex,
22
+ )
23
+
24
+ __all__ = [
25
+ "SecopsConfluencePostTransform",
26
+ "SecopsEpubPostTransform",
27
+ "SecopsHtmlPostTransform",
28
+ "SecopsLatexPostTransform",
29
+ "depart_secops_noop",
30
+ "register_latex_preamble",
31
+ "visit_secops_summary_epub",
32
+ "visit_secops_summary_html",
33
+ "visit_secops_summary_latex",
34
+ "visit_secops_timeline_svg_epub",
35
+ "visit_secops_timeline_svg_html",
36
+ "visit_secops_timeline_svg_latex",
37
+ ]
@@ -0,0 +1,60 @@
1
+ """Confluence PostTransform keeping Storage XHTML clean for ``doxtr-secops``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from docutils import nodes
8
+ from sphinx.transforms.post_transforms import SphinxPostTransform
9
+
10
+ from ..nodes import secops_summary_node, secops_timeline_svg_node
11
+ from ..renderers.summary import build_summary_docutils_nodes
12
+ from ..renderers.timeline import build_timeline_docutils_nodes
13
+
14
+
15
+ def _downgrade_xlink_nodes(root: nodes.Node) -> None:
16
+ """Replace ``xlink_reference`` nodes with plain ``nodes.reference`` for Confluence."""
17
+ for inline in list(root.findall(nodes.inline)):
18
+ if "xlink-icon" in inline.get("classes", []):
19
+ inline.parent.remove(inline)
20
+
21
+ try:
22
+ from doxtr_xlink import xlink_reference
23
+ except ImportError:
24
+ return
25
+
26
+ for xnode in list(root.findall(xlink_reference)):
27
+ ref = nodes.reference(**xnode.attributes)
28
+ ref.extend(xnode.children)
29
+ xnode.replace_self(ref)
30
+
31
+
32
+ class SecopsConfluencePostTransform(SphinxPostTransform):
33
+ """Convert secops tables and custom nodes to clean Confluence docutils nodes."""
34
+
35
+ default_priority = 450
36
+ builders = ("confluence", "singleconfluence")
37
+
38
+ def run(self, **kwargs: Any) -> None:
39
+ for table_node in list(self.document.findall(nodes.table)):
40
+ if "doxtr-secops-table" not in table_node.get("classes", []):
41
+ continue
42
+ if table_node.get("_doxtr_secops_conf_done"):
43
+ continue
44
+ table_node["_doxtr_secops_conf_done"] = True
45
+ _downgrade_xlink_nodes(table_node)
46
+
47
+ for sum_node in list(self.document.findall(secops_summary_node)):
48
+ replacement = build_summary_docutils_nodes(
49
+ sum_node["metrics"],
50
+ title=sum_node.get("title", ""),
51
+ )
52
+ sum_node.replace_self(replacement)
53
+
54
+ for tl_node in list(self.document.findall(secops_timeline_svg_node)):
55
+ replacement = build_timeline_docutils_nodes(
56
+ tl_node["exposures"],
57
+ group_by=tl_node.get("group_by", "team"),
58
+ title=tl_node.get("title", "Security Remediation Timeline"),
59
+ )
60
+ tl_node.replace_self(replacement)
@@ -0,0 +1,67 @@
1
+ """EPUB PostTransform and strict XHTML5 node visitors for ``doxtr-secops``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from docutils import nodes
8
+ from sphinx.transforms.post_transforms import SphinxPostTransform
9
+
10
+ from ..renderers.summary import render_summary_html
11
+ from ..renderers.timeline import render_timeline_svg
12
+ from ..theme_adapter import is_theme_core_active, resolve_palette_context
13
+
14
+
15
+ def _should_use_css_vars(config: Any) -> bool:
16
+ if not is_theme_core_active(config):
17
+ return False
18
+ scheme = str(getattr(config, "doxtr_color_scheme", "auto") or "auto").strip().lower()
19
+ dark_forced = scheme == "dark" or bool(getattr(config, "doxtr_dark_mode", False))
20
+ return scheme == "auto" and not dark_forced
21
+
22
+
23
+ def visit_secops_summary_epub(visitor: Any, node: nodes.Node) -> None:
24
+ """Render ``secops_summary_node`` as static, XML-valid XHTML5 for EPUB."""
25
+ config = getattr(getattr(visitor, "builder", None), "config", None)
26
+ palette_ctx = resolve_palette_context(config)
27
+ markup = render_summary_html(
28
+ node["metrics"],
29
+ palette_ctx,
30
+ title=node.get("title", ""),
31
+ epub=True,
32
+ use_css_vars=_should_use_css_vars(config),
33
+ )
34
+ visitor.body.append(markup)
35
+ raise nodes.SkipNode
36
+
37
+
38
+ def visit_secops_timeline_svg_epub(visitor: Any, node: nodes.Node) -> None:
39
+ """Render ``secops_timeline_svg_node`` as static, XML-valid XHTML5 SVG for EPUB."""
40
+ config = getattr(getattr(visitor, "builder", None), "config", None)
41
+ palette_ctx = resolve_palette_context(config)
42
+ markup = render_timeline_svg(
43
+ node["exposures"],
44
+ group_by=node.get("group_by", "team"),
45
+ title=node.get("title", "Security Remediation Timeline"),
46
+ period_entries=node.get("period_entries", ()),
47
+ show_calendar_bands=node.get("show_calendar_bands", True),
48
+ palette_ctx=palette_ctx,
49
+ today=node.get("today"),
50
+ epub=True,
51
+ use_css_vars=_should_use_css_vars(config),
52
+ )
53
+ visitor.body.append(markup)
54
+ raise nodes.SkipNode
55
+
56
+
57
+ class SecopsEpubPostTransform(SphinxPostTransform):
58
+ """Ensure ``doxtr-secops-table`` renders cleanly in static EPUB builds without JS."""
59
+
60
+ default_priority = 450
61
+ builders = ("epub", "epub3")
62
+
63
+ def run(self, **kwargs: Any) -> None:
64
+ for table_node in list(self.document.findall(nodes.table)):
65
+ if "doxtr-secops-table" not in table_node.get("classes", []):
66
+ continue
67
+ table_node["_doxtr_secops_epub_done"] = True
@@ -0,0 +1,105 @@
1
+ """HTML PostTransform and custom node visitors for ``doxtr-secops``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict
6
+
7
+ from docutils import nodes
8
+ from sphinx.transforms.post_transforms import SphinxPostTransform
9
+
10
+ from ..renderers.summary import render_summary_html
11
+ from ..renderers.timeline import render_timeline_svg
12
+ from ..theme_adapter import resolve_palette_context
13
+
14
+
15
+ def visit_secops_summary_html(visitor: Any, node: nodes.Node) -> None:
16
+ """Render ``secops_summary_node`` as interactive/themed HTML + inline SVG."""
17
+ config = getattr(getattr(visitor, "builder", None), "config", None)
18
+ palette_ctx = resolve_palette_context(config)
19
+ markup = render_summary_html(
20
+ node["metrics"],
21
+ palette_ctx,
22
+ title=node.get("title", ""),
23
+ epub=False,
24
+ )
25
+ visitor.body.append(markup)
26
+ raise nodes.SkipNode
27
+
28
+
29
+ def visit_secops_timeline_svg_html(visitor: Any, node: nodes.Node) -> None:
30
+ """Render ``secops_timeline_svg_node`` as inline themed SVG."""
31
+ config = getattr(getattr(visitor, "builder", None), "config", None)
32
+ palette_ctx = resolve_palette_context(config)
33
+ markup = render_timeline_svg(
34
+ node["exposures"],
35
+ group_by=node.get("group_by", "team"),
36
+ title=node.get("title", "Security Remediation Timeline"),
37
+ period_entries=node.get("period_entries", ()),
38
+ show_calendar_bands=node.get("show_calendar_bands", True),
39
+ palette_ctx=palette_ctx,
40
+ today=node.get("today"),
41
+ epub=False,
42
+ )
43
+ visitor.body.append(markup)
44
+ raise nodes.SkipNode
45
+
46
+
47
+ def depart_secops_noop(visitor: Any, node: nodes.Node) -> None:
48
+ """No-op depart handler paired with ``nodes.SkipNode`` visitors."""
49
+ return None
50
+
51
+
52
+ class SecopsHtmlPostTransform(SphinxPostTransform):
53
+ """Wrap ``doxtr-secops-table`` nodes in interactive filter/sort containers."""
54
+
55
+ default_priority = 450
56
+ builders = ("html", "dirhtml", "singlehtml", "readthedocs")
57
+
58
+ def run(self, **kwargs: Any) -> None:
59
+ for table_node in list(self.document.findall(nodes.table)):
60
+ if "doxtr-secops-table" not in table_node.get("classes", []):
61
+ continue
62
+ if table_node.get("_doxtr_secops_html_done"):
63
+ continue
64
+ table_node["_doxtr_secops_html_done"] = True
65
+
66
+ meta: Dict[str, Any] = table_node.get("doxtr_secops_meta") or {}
67
+ interactive = meta.get("interactive", True)
68
+ table_id = str(meta.get("table_id", "secops-table"))
69
+ body_count = int(meta.get("body_count", 0))
70
+
71
+ if not interactive:
72
+ scroll = nodes.container(classes=["doxtr-secops-scroll", "doxtr-scroll-region"])
73
+ parent = table_node.parent
74
+ if parent is not None:
75
+ idx = parent.index(table_node)
76
+ parent[idx] = scroll
77
+ scroll += table_node
78
+ continue
79
+
80
+ container = nodes.container(
81
+ classes=["doxtr-secops-container", "doxtr-secops-sortable", "doxtr-secops-filterable"],
82
+ ids=[f"secops-{table_id}"],
83
+ )
84
+ toolbar = (
85
+ '<div class="doxtr-secops-toolbar">'
86
+ '<div class="doxtr-secops-filter-wrap">'
87
+ '<label class="doxtr-secops-filter-label">'
88
+ '<span class="doxtr-secops-sr-only">Filter findings</span>'
89
+ '<input type="search" class="doxtr-secops-filter-input" '
90
+ 'placeholder="Filter findings (use !term to exclude)..." '
91
+ 'aria-label="Filter findings" />'
92
+ "</label>"
93
+ f'<span class="doxtr-secops-count" aria-live="polite">{body_count} rows</span>'
94
+ "</div>"
95
+ "</div>"
96
+ )
97
+ container += nodes.raw("", toolbar, format="html")
98
+
99
+ scroll = nodes.container(classes=["doxtr-secops-scroll", "doxtr-scroll-region"])
100
+ parent = table_node.parent
101
+ if parent is not None:
102
+ idx = parent.index(table_node)
103
+ parent[idx] = container
104
+ scroll += table_node
105
+ container += scroll