kaos-content 0.1.0a1__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.
- kaos_content-0.1.0a1/.gitignore +40 -0
- kaos_content-0.1.0a1/CHANGELOG.md +219 -0
- kaos_content-0.1.0a1/LICENSE +201 -0
- kaos_content-0.1.0a1/NOTICE +8 -0
- kaos_content-0.1.0a1/PKG-INFO +295 -0
- kaos_content-0.1.0a1/README.md +248 -0
- kaos_content-0.1.0a1/SECURITY.md +61 -0
- kaos_content-0.1.0a1/kaos_content/__init__.py +426 -0
- kaos_content-0.1.0a1/kaos_content/_security.py +77 -0
- kaos_content-0.1.0a1/kaos_content/_version.py +1 -0
- kaos_content-0.1.0a1/kaos_content/artifacts.py +552 -0
- kaos_content-0.1.0a1/kaos_content/bridges/__init__.py +1 -0
- kaos_content-0.1.0a1/kaos_content/bridges/content_to_tabular.py +211 -0
- kaos_content-0.1.0a1/kaos_content/bridges/duckdb.py +687 -0
- kaos_content-0.1.0a1/kaos_content/bridges/polars.py +231 -0
- kaos_content-0.1.0a1/kaos_content/builders/__init__.py +5 -0
- kaos_content-0.1.0a1/kaos_content/builders/builder.py +530 -0
- kaos_content-0.1.0a1/kaos_content/chunking/__init__.py +5 -0
- kaos_content-0.1.0a1/kaos_content/chunking/section_chunker.py +509 -0
- kaos_content-0.1.0a1/kaos_content/corpus.py +242 -0
- kaos_content-0.1.0a1/kaos_content/dedup/__init__.py +42 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/__init__.py +24 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/binary_hash.py +82 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/fuzzy_binary.py +140 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/minhash.py +144 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/perceptual.py +184 -0
- kaos_content-0.1.0a1/kaos_content/dedup/levels/text_hash.py +76 -0
- kaos_content-0.1.0a1/kaos_content/dedup/pipeline.py +113 -0
- kaos_content-0.1.0a1/kaos_content/dedup/presets.py +111 -0
- kaos_content-0.1.0a1/kaos_content/dedup/types.py +139 -0
- kaos_content-0.1.0a1/kaos_content/errors.py +54 -0
- kaos_content-0.1.0a1/kaos_content/images/__init__.py +35 -0
- kaos_content-0.1.0a1/kaos_content/images/artifacts.py +126 -0
- kaos_content-0.1.0a1/kaos_content/images/model.py +509 -0
- kaos_content-0.1.0a1/kaos_content/images/ops.py +159 -0
- kaos_content-0.1.0a1/kaos_content/images/profiles.py +109 -0
- kaos_content-0.1.0a1/kaos_content/indexing.py +569 -0
- kaos_content-0.1.0a1/kaos_content/layout/__init__.py +76 -0
- kaos_content-0.1.0a1/kaos_content/layout/clustering.py +354 -0
- kaos_content-0.1.0a1/kaos_content/layout/detection.py +554 -0
- kaos_content-0.1.0a1/kaos_content/layout/profiles.py +184 -0
- kaos_content-0.1.0a1/kaos_content/layout/segmentation.py +132 -0
- kaos_content-0.1.0a1/kaos_content/layout/types.py +176 -0
- kaos_content-0.1.0a1/kaos_content/model/__init__.py +169 -0
- kaos_content-0.1.0a1/kaos_content/model/annotation.py +113 -0
- kaos_content-0.1.0a1/kaos_content/model/annotation_bodies.py +267 -0
- kaos_content-0.1.0a1/kaos_content/model/attr.py +132 -0
- kaos_content-0.1.0a1/kaos_content/model/blocks.py +171 -0
- kaos_content-0.1.0a1/kaos_content/model/document.py +38 -0
- kaos_content-0.1.0a1/kaos_content/model/extraction.py +297 -0
- kaos_content-0.1.0a1/kaos_content/model/inlines.py +166 -0
- kaos_content-0.1.0a1/kaos_content/model/metadata.py +79 -0
- kaos_content-0.1.0a1/kaos_content/model/node.py +36 -0
- kaos_content-0.1.0a1/kaos_content/model/table.py +42 -0
- kaos_content-0.1.0a1/kaos_content/model/tabular.py +485 -0
- kaos_content-0.1.0a1/kaos_content/normalize.py +271 -0
- kaos_content-0.1.0a1/kaos_content/parsers/__init__.py +25 -0
- kaos_content-0.1.0a1/kaos_content/parsers/html.py +1570 -0
- kaos_content-0.1.0a1/kaos_content/parsers/markdown.py +913 -0
- kaos_content-0.1.0a1/kaos_content/parsers/plain.py +72 -0
- kaos_content-0.1.0a1/kaos_content/py.typed +0 -0
- kaos_content-0.1.0a1/kaos_content/revision.py +780 -0
- kaos_content-0.1.0a1/kaos_content/search.py +1035 -0
- kaos_content-0.1.0a1/kaos_content/serializers/__init__.py +25 -0
- kaos_content-0.1.0a1/kaos_content/serializers/_revision.py +95 -0
- kaos_content-0.1.0a1/kaos_content/serializers/html.py +481 -0
- kaos_content-0.1.0a1/kaos_content/serializers/markdown.py +887 -0
- kaos_content-0.1.0a1/kaos_content/serializers/tabular.py +341 -0
- kaos_content-0.1.0a1/kaos_content/serializers/text.py +271 -0
- kaos_content-0.1.0a1/kaos_content/shortcuts.py +222 -0
- kaos_content-0.1.0a1/kaos_content/structure.py +693 -0
- kaos_content-0.1.0a1/kaos_content/tools.py +1274 -0
- kaos_content-0.1.0a1/kaos_content/transforms.py +78 -0
- kaos_content-0.1.0a1/kaos_content/traversal/__init__.py +43 -0
- kaos_content-0.1.0a1/kaos_content/traversal/index.py +249 -0
- kaos_content-0.1.0a1/kaos_content/traversal/queries.py +156 -0
- kaos_content-0.1.0a1/kaos_content/traversal/visitor.py +204 -0
- kaos_content-0.1.0a1/kaos_content/units.py +162 -0
- kaos_content-0.1.0a1/kaos_content/views/__init__.py +20 -0
- kaos_content-0.1.0a1/kaos_content/views/document_view.py +497 -0
- kaos_content-0.1.0a1/kaos_content/views/models.py +113 -0
- kaos_content-0.1.0a1/kaos_content/views/tabular_view.py +245 -0
- kaos_content-0.1.0a1/pyproject.toml +223 -0
- kaos_content-0.1.0a1/tests/__init__.py +0 -0
- kaos_content-0.1.0a1/tests/benchmarks/dedup_scale_test.py +179 -0
- kaos_content-0.1.0a1/tests/fixtures/perceptual/README.md +52 -0
- kaos_content-0.1.0a1/tests/fixtures/perceptual/page_gpo.png +0 -0
- kaos_content-0.1.0a1/tests/fixtures/perceptual/page_plaster.png +0 -0
- kaos_content-0.1.0a1/tests/fixtures/perceptual/page_staten.png +0 -0
- kaos_content-0.1.0a1/tests/fuzz/__init__.py +19 -0
- kaos_content-0.1.0a1/tests/fuzz/conftest.py +27 -0
- kaos_content-0.1.0a1/tests/fuzz/test_fuzz_json_robustness.py +229 -0
- kaos_content-0.1.0a1/tests/fuzz/test_fuzz_markdown_roundtrip.py +241 -0
- kaos_content-0.1.0a1/tests/fuzz/test_fuzz_serializer_xss.py +262 -0
- kaos_content-0.1.0a1/tests/fuzz/test_fuzz_sql_safety.py +184 -0
- kaos_content-0.1.0a1/tests/fuzz/test_fuzz_url_filter.py +115 -0
- kaos_content-0.1.0a1/tests/integration/test_office_duckdb_e2e.py +37 -0
- kaos_content-0.1.0a1/tests/security/__init__.py +0 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec1.py +152 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec2.py +233 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec3.py +235 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec4.py +121 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec5.py +136 -0
- kaos_content-0.1.0a1/tests/security/test_security_sec6.py +109 -0
- kaos_content-0.1.0a1/tests/test_annotation_index.py +162 -0
- kaos_content-0.1.0a1/tests/test_structure.py +409 -0
- kaos_content-0.1.0a1/tests/unit/__init__.py +0 -0
- kaos_content-0.1.0a1/tests/unit/test_annotation.py +129 -0
- kaos_content-0.1.0a1/tests/unit/test_annotation_bodies.py +169 -0
- kaos_content-0.1.0a1/tests/unit/test_artifacts.py +381 -0
- kaos_content-0.1.0a1/tests/unit/test_attr.py +181 -0
- kaos_content-0.1.0a1/tests/unit/test_blocks.py +380 -0
- kaos_content-0.1.0a1/tests/unit/test_builder.py +626 -0
- kaos_content-0.1.0a1/tests/unit/test_content_model_validation.py +85 -0
- kaos_content-0.1.0a1/tests/unit/test_content_to_tabular_bridge.py +173 -0
- kaos_content-0.1.0a1/tests/unit/test_corpus_protocol.py +179 -0
- kaos_content-0.1.0a1/tests/unit/test_dedup.py +523 -0
- kaos_content-0.1.0a1/tests/unit/test_dedup_perceptual.py +313 -0
- kaos_content-0.1.0a1/tests/unit/test_document.py +287 -0
- kaos_content-0.1.0a1/tests/unit/test_extraction.py +557 -0
- kaos_content-0.1.0a1/tests/unit/test_html_pre_content_mode.py +127 -0
- kaos_content-0.1.0a1/tests/unit/test_html_serializer.py +316 -0
- kaos_content-0.1.0a1/tests/unit/test_image_figure.py +69 -0
- kaos_content-0.1.0a1/tests/unit/test_images.py +578 -0
- kaos_content-0.1.0a1/tests/unit/test_index.py +401 -0
- kaos_content-0.1.0a1/tests/unit/test_indexing.py +305 -0
- kaos_content-0.1.0a1/tests/unit/test_inlines.py +250 -0
- kaos_content-0.1.0a1/tests/unit/test_layout.py +1073 -0
- kaos_content-0.1.0a1/tests/unit/test_markdown_parser.py +996 -0
- kaos_content-0.1.0a1/tests/unit/test_markdown_serializer.py +725 -0
- kaos_content-0.1.0a1/tests/unit/test_node_identity.py +243 -0
- kaos_content-0.1.0a1/tests/unit/test_normalize.py +144 -0
- kaos_content-0.1.0a1/tests/unit/test_parse_plain_text.py +91 -0
- kaos_content-0.1.0a1/tests/unit/test_phase0_hardening.py +1792 -0
- kaos_content-0.1.0a1/tests/unit/test_phase1_hardening.py +1406 -0
- kaos_content-0.1.0a1/tests/unit/test_phase2_hardening.py +1132 -0
- kaos_content-0.1.0a1/tests/unit/test_polars_bridge.py +252 -0
- kaos_content-0.1.0a1/tests/unit/test_queries.py +247 -0
- kaos_content-0.1.0a1/tests/unit/test_revision.py +303 -0
- kaos_content-0.1.0a1/tests/unit/test_revision_authoring.py +250 -0
- kaos_content-0.1.0a1/tests/unit/test_revision_transforms.py +420 -0
- kaos_content-0.1.0a1/tests/unit/test_search.py +245 -0
- kaos_content-0.1.0a1/tests/unit/test_section_chunker.py +640 -0
- kaos_content-0.1.0a1/tests/unit/test_section_model.py +81 -0
- kaos_content-0.1.0a1/tests/unit/test_security_duckdb.py +248 -0
- kaos_content-0.1.0a1/tests/unit/test_security_image_bombs.py +140 -0
- kaos_content-0.1.0a1/tests/unit/test_security_model_validation.py +227 -0
- kaos_content-0.1.0a1/tests/unit/test_security_serializer_xss.py +231 -0
- kaos_content-0.1.0a1/tests/unit/test_security_url_filter.py +114 -0
- kaos_content-0.1.0a1/tests/unit/test_serializer_escaping.py +572 -0
- kaos_content-0.1.0a1/tests/unit/test_serializer_structure.py +609 -0
- kaos_content-0.1.0a1/tests/unit/test_serializer_view_modes.py +197 -0
- kaos_content-0.1.0a1/tests/unit/test_shortcuts.py +239 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_artifacts.py +183 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_model.py +398 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_search.py +117 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_serializers.py +313 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_stress.py +1399 -0
- kaos_content-0.1.0a1/tests/unit/test_tabular_view.py +201 -0
- kaos_content-0.1.0a1/tests/unit/test_text_serializer.py +234 -0
- kaos_content-0.1.0a1/tests/unit/test_tools.py +839 -0
- kaos_content-0.1.0a1/tests/unit/test_transforms.py +92 -0
- kaos_content-0.1.0a1/tests/unit/test_traversal_realistic.py +1072 -0
- kaos_content-0.1.0a1/tests/unit/test_units.py +303 -0
- kaos_content-0.1.0a1/tests/unit/test_views.py +451 -0
- kaos_content-0.1.0a1/tests/unit/test_visitor.py +334 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
.venv/
|
|
5
|
+
.coverage
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
|
|
12
|
+
# Local secrets — never commit. Examples (.env.example) are allowed.
|
|
13
|
+
.env
|
|
14
|
+
.env.local
|
|
15
|
+
.env.*.local
|
|
16
|
+
.envrc
|
|
17
|
+
|
|
18
|
+
# Hypothesis property-based testing cache (per-machine, not source).
|
|
19
|
+
.hypothesis/
|
|
20
|
+
|
|
21
|
+
# Local KAOS VFS scratch area (used by tests for temp artifacts).
|
|
22
|
+
.kaos-vfs/
|
|
23
|
+
|
|
24
|
+
# Coverage outputs.
|
|
25
|
+
htmlcov/
|
|
26
|
+
coverage.xml
|
|
27
|
+
|
|
28
|
+
# IDE / editor clutter.
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# Lockfile is gitignored at 0.1.0a1 because the dev-group + several
|
|
35
|
+
# extras pin unpublished siblings (kaos-mcp, kaos-nlp-transformers,
|
|
36
|
+
# kaos-office). uv lock is strict — every declared dep must resolve,
|
|
37
|
+
# so committing the lockfile would freeze a no-longer-resolvable view.
|
|
38
|
+
# Re-track this file at 0.1.0a2 once Wave 3 siblings ship. See
|
|
39
|
+
# F009 #4 in the kaos-modules OSS plan / docs/oss/00-overview/decisions.md.
|
|
40
|
+
uv.lock
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `kaos-content` are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0a1] — 2026-05-07
|
|
11
|
+
|
|
12
|
+
First public alpha release.
|
|
13
|
+
|
|
14
|
+
### Security
|
|
15
|
+
|
|
16
|
+
The first published wheel ships with a hardened security surface
|
|
17
|
+
(seven contract-level fixes, ~35 regression tests under `tests/security/`):
|
|
18
|
+
|
|
19
|
+
- **Sec-1 — `urlparse` `ValueError` leak + parser context isolation.**
|
|
20
|
+
HTML / markdown URL filters now route every parse through
|
|
21
|
+
`kaos_content._security.is_safe_url`, which catches `ValueError` from
|
|
22
|
+
malformed URIs internally and returns a uniform unsafe verdict instead
|
|
23
|
+
of leaking exceptions. The HTML parser's per-document state is now
|
|
24
|
+
carried in a `contextvars.ContextVar` so concurrent `parse_html` calls
|
|
25
|
+
on different documents don't cross-contaminate ID counters or
|
|
26
|
+
`pre_content_mode`. Closes findings #3 and #6.
|
|
27
|
+
- **Sec-2 — markdown XSS via unescaped URL / alt text.**
|
|
28
|
+
`serialize_markdown` now escapes link / image URLs and image alt text
|
|
29
|
+
through the same `is_safe_url` filter as the HTML serializer; raw
|
|
30
|
+
`javascript:` / `data:` / `vbscript:` / `file:` URIs in the AST
|
|
31
|
+
no longer round-trip into renderable HTML. Closes finding #1.
|
|
32
|
+
- **Sec-3 — DuckDB sandbox structural reorganisation.**
|
|
33
|
+
`bridges/duckdb.py` now exposes `create_safe_connection()` which sets
|
|
34
|
+
`lock_configuration` and disables filesystem extension loading at
|
|
35
|
+
open time (structural enforcement) instead of relying on a SQL
|
|
36
|
+
deny-list (regex-defeatable). The legacy deny-list is kept as
|
|
37
|
+
telemetry only. Closes finding #2.
|
|
38
|
+
- **Sec-4 — HTML link-stripping preserves visible text.**
|
|
39
|
+
When `parse_html` strips an unsafe-URL `<a>` element, the inner text
|
|
40
|
+
/ image is now preserved as a plain inline span instead of being
|
|
41
|
+
dropped. Prevents accidental information loss and the "phantom button"
|
|
42
|
+
UX where rendered output omitted visible labels. Closes finding #4.
|
|
43
|
+
- **Sec-5 — bounded artifact reads with `max_bytes` cap.**
|
|
44
|
+
`load_document` and `load_tabular` accept an optional `max_bytes`
|
|
45
|
+
parameter (default: 256 MB) and short-circuit if the manifest body
|
|
46
|
+
exceeds it. Prevents an attacker-controlled artifact from triggering
|
|
47
|
+
unbounded memory consumption during deserialisation. Closes finding #5.
|
|
48
|
+
- **Sec-6 — `KaosImage.resize` copy-before-thumbnail.**
|
|
49
|
+
`resize()` now copies the source PIL image before invoking
|
|
50
|
+
`thumbnail()`, which is in-place. The previous code mutated the
|
|
51
|
+
caller's image when the result happened to fit — a silent
|
|
52
|
+
cross-call side-effect. Closes finding #7.
|
|
53
|
+
- **Sec-7 — kaos-source defensive test + security guide.**
|
|
54
|
+
Added cross-package defensive tests covering the artifact-cap
|
|
55
|
+
contract from kaos-source's perspective; `docs/security.md` documents
|
|
56
|
+
the threat model + entry-point contracts ([HTML / markdown URL safety,
|
|
57
|
+
DuckDB sandbox, artifact size, parser context isolation, image
|
|
58
|
+
decompression-bomb caps]).
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- `ContentDocument` typed Block/Inline AST: 17 Block types and 17 Inline
|
|
63
|
+
types as frozen Pydantic v2 models, with content-model enforcement
|
|
64
|
+
at construction (blocks contain blocks or inlines, never mixed).
|
|
65
|
+
- Provenance on every node: source file, page, bounding box, char span,
|
|
66
|
+
extraction confidence (`Provenance` model in `model/provenance.py`).
|
|
67
|
+
- 15 `AnnotationType` values (3 generic + 7 legal + 3 NLP + 1 extraction
|
|
68
|
+
+ 1 tracked-change) with typed `body` schemas via
|
|
69
|
+
`model/annotation_bodies.py`.
|
|
70
|
+
- `Attr` triple — `(id, classes, key-value)` on every node — for
|
|
71
|
+
domain-specific extension via `Div` / `Span` containers.
|
|
72
|
+
- 17 `ColumnType` values (8 universal + 3 analytical + 2 structured
|
|
73
|
+
+ 4 KAOS extraction-specific) for `TabularDocument`.
|
|
74
|
+
- `DocumentView` and `TabularDocument`: dynamic hierarchical views
|
|
75
|
+
(pages, sections, paragraphs, sentences) and the universal tabular
|
|
76
|
+
AST.
|
|
77
|
+
- Three serializers: `serialize_markdown()`, `serialize_html()`,
|
|
78
|
+
`serialize_text()`, each supporting `view` parameter for tracked-
|
|
79
|
+
changes rendering (`final` / `original` / `markup`).
|
|
80
|
+
- Five tabular serializers: `serialize_csv()`, `serialize_tsv()`,
|
|
81
|
+
`serialize_markdown_table()`, `serialize_json_records()`,
|
|
82
|
+
`serialize_tabular_summary()`.
|
|
83
|
+
- `SectionChunker` — canonical heading-aware chunker that preserves
|
|
84
|
+
AST validity, footnote partitioning, and annotation propagation.
|
|
85
|
+
- 9 optional extras: `[markdown]`, `[html]`, `[images]`, `[layout]`,
|
|
86
|
+
`[nlp]`, `[polars]`, `[duckdb]`, `[mcp]`, `[dedup-perceptual]`.
|
|
87
|
+
- `kaos_content.shortcuts` — terse AST construction helpers
|
|
88
|
+
(`text`, `bold`, `paragraph`, `heading`, `bullet_list`, etc.).
|
|
89
|
+
- `kaos_content.traversal` — depth-first walk + typed queries
|
|
90
|
+
(`find_by_type`, `find_links`, `find_tables`, `find_images`, etc.).
|
|
91
|
+
- `kaos_content.transforms` — `DocumentTransform` Protocol +
|
|
92
|
+
`compose()` + `apply()`.
|
|
93
|
+
- `kaos_content.revision` — tracked-change API: `accept_all`,
|
|
94
|
+
`reject_all`, `at_time` transforms.
|
|
95
|
+
- Polars and DuckDB bridges in `bridges/` for tabular round-trip.
|
|
96
|
+
- `search_document()` BM25 search (optional `[nlp]` extra) with
|
|
97
|
+
term-frequency fallback.
|
|
98
|
+
- `WS-TR` extraction primitives: `ExtractionCell`,
|
|
99
|
+
`ExtractionCitation`, `ExtractionError`, `CellStatus` with
|
|
100
|
+
reviewer-overlay invariants (immutable AI / immutable reviewer).
|
|
101
|
+
- 7 MCP tools registered via `register_content_tools()`.
|
|
102
|
+
- Python 3.13 and 3.14 support.
|
|
103
|
+
|
|
104
|
+
### Security
|
|
105
|
+
|
|
106
|
+
- HTML and Markdown serializers no longer pass through raw HTML
|
|
107
|
+
blocks by default; `allow_raw_html=False` is the default. Raw HTML
|
|
108
|
+
blocks emit `<!-- raw HTML stripped -->` (HTML) or
|
|
109
|
+
`<!-- raw {format} stripped -->` (Markdown) unless the caller
|
|
110
|
+
explicitly opts in. Audit C1+C2.
|
|
111
|
+
- Both serializers neuter unsafe URI schemes (`javascript:`, `data:`,
|
|
112
|
+
`vbscript:`, `file:`) in `<a href>` and `<img src>`. The URL is
|
|
113
|
+
replaced with `#` and the original captured as `data-unsafe-url`
|
|
114
|
+
for forensics. Audit C3.
|
|
115
|
+
- New shared module `kaos_content._security` consolidates
|
|
116
|
+
`is_safe_url()` + `UNSAFE_SCHEMES`. Canonicalises through HTML-
|
|
117
|
+
entity decoding, URL percent-decoding, and whitespace removal
|
|
118
|
+
before scheme matching — closes the `jav\nascript:`,
|
|
119
|
+
`javascript:`, and `javascript%3A` bypasses (audit C4).
|
|
120
|
+
Used by HTML parser, HTML serializer, and Markdown serializer so
|
|
121
|
+
one fix applies everywhere.
|
|
122
|
+
- DuckDB bridge gains layered defence (audit C5+C6+C7):
|
|
123
|
+
- `execute_query(..., untrusted_sql=True)` is the default; it
|
|
124
|
+
rejects SQL containing dangerous functions (`read_csv`,
|
|
125
|
+
`read_csv_auto`, `read_parquet`, `read_json`, `read_json_auto`,
|
|
126
|
+
`read_blob`, `read_text`, `read_xml`, `glob`, `scan_jsonl`) and
|
|
127
|
+
keywords (`attach`, `detach`, `copy`, `install`, `load`,
|
|
128
|
+
`pragma`, `export`, `import`). SQL line and block comments are
|
|
129
|
+
stripped before the deny-list runs so comment-evasion bypasses
|
|
130
|
+
fail.
|
|
131
|
+
- New `create_safe_connection()` returns an in-memory DuckDB
|
|
132
|
+
connection with `enable_external_access=false` and unsigned-
|
|
133
|
+
extension loads disabled — the engine-level half of the
|
|
134
|
+
defence.
|
|
135
|
+
- `_register_table_fallback` quotes column identifiers via
|
|
136
|
+
`_quote_ident`; embedded `"` characters can no longer break
|
|
137
|
+
out of the identifier.
|
|
138
|
+
- `list_tables` uses parameterised queries instead of f-string
|
|
139
|
+
interpolation.
|
|
140
|
+
- Hypothesis-based fuzz suite under `tests/fuzz/` (dev-only, gated
|
|
141
|
+
on the `hypothesis` dev dependency): 42 property tests covering
|
|
142
|
+
the URL filter, serializer XSS contracts, DuckDB deny-list
|
|
143
|
+
evasion, JSON deserialization robustness, and Markdown
|
|
144
|
+
serializer/parser no-crash properties. Surfaced and fixed an
|
|
145
|
+
adjacent-emphasis serializer escape-rule bug (see Fixed).
|
|
146
|
+
|
|
147
|
+
### Fixed
|
|
148
|
+
|
|
149
|
+
- Model field constraints reject structurally-invalid values at
|
|
150
|
+
construction time (audit M1):
|
|
151
|
+
- `BoundingBox` rejects right<left and (top_left) bottom<top.
|
|
152
|
+
- `Provenance.page` is `>=1`; `0` and negative values rejected.
|
|
153
|
+
- `Provenance.confidence` is bounded to `[0.0, 1.0]`.
|
|
154
|
+
- `Provenance.char_span` is non-negative and `end >= start`.
|
|
155
|
+
- `Cell.row_span` and `Cell.col_span` are `>= 1`.
|
|
156
|
+
- `Image.width` and `Image.height` are `> 0` when set.
|
|
157
|
+
- Image loading is bounded against decompression-bomb attacks
|
|
158
|
+
(audit M2): `kaos_content.images.model.MAX_IMAGE_PIXELS =
|
|
159
|
+
100_000_000` is enforced, and PIL's process-wide
|
|
160
|
+
`Image.MAX_IMAGE_PIXELS` is set to the same cap on import.
|
|
161
|
+
Decompression-bomb warnings are promoted to a typed
|
|
162
|
+
`ImageDecompressionBombError`. `images/artifacts.load_image()`
|
|
163
|
+
defaults `max_bytes=50_000_000` (was unbounded).
|
|
164
|
+
- Markdown serializer alternates `*` / `_` (and `**` / `__`)
|
|
165
|
+
delimiters when an adjacent inline sibling already used the same
|
|
166
|
+
delimiter. Without this, `Emphasis(0), Emphasis(0), Emphasis(0)`
|
|
167
|
+
rendered as `*0**0**0*` and re-tokenised under CommonMark
|
|
168
|
+
flanker rules into `Emphasis[Text(0), Strong(Text(0)), Text(0)]`
|
|
169
|
+
on round-trip. Surfaced by the new fuzz tier.
|
|
170
|
+
- MCP tool annotations split between `_QUERY_ANNOTATIONS`
|
|
171
|
+
(read-only/idempotent — search tools) and
|
|
172
|
+
`_ARTIFACT_WRITER_ANNOTATIONS` (parse / chunk / extract /
|
|
173
|
+
serialize-to-large — they materialise new VFS artifacts).
|
|
174
|
+
Previously every tool advertised `readOnlyHint=True` even when
|
|
175
|
+
it wrote artifacts, which auto-approving agents
|
|
176
|
+
(Claude Code) would skip confirmation for. Audit M3.
|
|
177
|
+
- `kaos_content.parsers.parse_markdown` is now lazily re-exported
|
|
178
|
+
from the package so importing `kaos_content` no longer pulls in
|
|
179
|
+
`markdown_it` for users who don't have the `[markdown]` extra
|
|
180
|
+
installed.
|
|
181
|
+
- Tool `_VERSION` synced to `0.1.0a1` (was stale at `0.1.0`).
|
|
182
|
+
|
|
183
|
+
### Removed
|
|
184
|
+
|
|
185
|
+
- `kaos-content-serve` script entry point and `kaos_content.serve`
|
|
186
|
+
module — exposing tools over the Model Context Protocol is the
|
|
187
|
+
responsibility of the companion package
|
|
188
|
+
[`kaos-mcp`](https://github.com/273v/kaos-mcp), which ships
|
|
189
|
+
separately. Bundling a stub server in `kaos-content` whose only
|
|
190
|
+
resolution path went through `kaos-mcp` was a misleading
|
|
191
|
+
dependency contract.
|
|
192
|
+
|
|
193
|
+
### Packaging
|
|
194
|
+
|
|
195
|
+
- `kaos-core` dependency spec is now `>=0.1.0a1,<0.2` (was
|
|
196
|
+
`>=0.1,<0.2`). PEP 440 excludes pre-releases from a bare `>=0.1`
|
|
197
|
+
spec, so plain `pip install kaos-content` could not satisfy the
|
|
198
|
+
dependency. Same fix applied to the `[nlp]` and `[mcp]` extras'
|
|
199
|
+
sibling-package pins.
|
|
200
|
+
- `SECURITY.md` is now included in the PyPI sdist (was missing).
|
|
201
|
+
- `[tool.check-manifest]` declares the intentional sdist exclusions
|
|
202
|
+
(`CLAUDE.md`, internal `docs/*.md`, `uv.lock`) so the parity
|
|
203
|
+
check passes cleanly.
|
|
204
|
+
|
|
205
|
+
### Dependencies
|
|
206
|
+
|
|
207
|
+
- `cryptography>=46.0.7` (was `>=44.0.2`) — closes
|
|
208
|
+
CVE-2026-34073 and CVE-2026-39892.
|
|
209
|
+
- `lxml>=6.1.0` (was `>=5.0.0`, `[html]` extra) — closes
|
|
210
|
+
CVE-2026-41066.
|
|
211
|
+
- `Pillow>=12.2.0` (`[images]` extra) — closes CVE-2026-40192.
|
|
212
|
+
|
|
213
|
+
### License
|
|
214
|
+
|
|
215
|
+
This release is the first to ship under the Apache License 2.0.
|
|
216
|
+
Earlier internal versions were proprietary.
|
|
217
|
+
|
|
218
|
+
[Unreleased]: https://github.com/273v/kaos-content/compare/v0.1.0a1...HEAD
|
|
219
|
+
[0.1.0a1]: https://github.com/273v/kaos-content/releases/tag/v0.1.0a1
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 273 Ventures LLC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
kaos-content
|
|
2
|
+
Copyright 2026 273 Ventures LLC.
|
|
3
|
+
|
|
4
|
+
This product includes software developed at 273 Ventures LLC
|
|
5
|
+
(https://273ventures.com).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0. See the LICENSE file
|
|
8
|
+
distributed with this software for the full text of the license.
|