vgi-python 0.42.0__py3-none-any.whl → 0.43.0__py3-none-any.whl
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.
- vgi/_redact.py +35 -0
- vgi/_test_fixtures/attach_ticket_vectors.json +450 -0
- vgi/_test_fixtures/catalog.py +2 -1
- vgi/_test_fixtures/http_server.py +30 -5
- vgi/_test_fixtures/ticket_probe.py +167 -0
- vgi/_test_fixtures/worker.py +4 -0
- vgi/attach_ticket.py +733 -0
- vgi/catalog/attach_option.py +12 -1
- vgi/client/__init__.py +3 -0
- vgi/client/client.py +158 -38
- vgi/exceptions.py +24 -1
- vgi/filter_v2.py +29 -1
- vgi/meta_worker.py +21 -3
- vgi/rpc_server.py +38 -4
- vgi/serve.py +23 -0
- vgi/transactor/server.py +12 -9
- vgi/worker.py +40 -25
- {vgi_python-0.42.0.dist-info → vgi_python-0.43.0.dist-info}/METADATA +2 -2
- {vgi_python-0.42.0.dist-info → vgi_python-0.43.0.dist-info}/RECORD +22 -18
- {vgi_python-0.42.0.dist-info → vgi_python-0.43.0.dist-info}/WHEEL +0 -0
- {vgi_python-0.42.0.dist-info → vgi_python-0.43.0.dist-info}/entry_points.txt +0 -0
- {vgi_python-0.42.0.dist-info → vgi_python-0.43.0.dist-info}/licenses/LICENSE +0 -0
vgi/_redact.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
+
|
|
3
|
+
"""The one way an opaque value may appear in a log, trace or error report.
|
|
4
|
+
|
|
5
|
+
``attach_opaque_data`` and ``transaction_opaque_data`` (and anything else a
|
|
6
|
+
client stores and hands back) may carry credentials, so their raw bytes, full
|
|
7
|
+
hex, and raw-hex *prefixes* never reach a sink. What does is the first 12 hex
|
|
8
|
+
characters of SHA-256 over the value's lowercase hex text
|
|
9
|
+
(docs/protocol/vgi-opaque-data-sealing.md, rule 7).
|
|
10
|
+
|
|
11
|
+
Hashing the hex text rather than the bytes matches ``vgi_rpc.sentry.short_hash``,
|
|
12
|
+
so a value redacted here correlates with the tag vgi-rpc's dispatch hook puts on
|
|
13
|
+
the same request. It is defined here instead of imported because
|
|
14
|
+
``vgi_rpc.sentry`` pulls in ``sentry_sdk``, an optional extra, and this module
|
|
15
|
+
has to stay importable from the lightest entry points (the transactor).
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import hashlib
|
|
21
|
+
|
|
22
|
+
SHORT_HASH_LEN = 12
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def short_hash(value: bytes | str | None, *, length: int = SHORT_HASH_LEN) -> str | None:
|
|
26
|
+
"""Return a stable hex prefix of ``sha256(hex(value))``, never the value itself.
|
|
27
|
+
|
|
28
|
+
``bytes`` are normalised to lowercase hex before hashing, so
|
|
29
|
+
``short_hash(b)`` equals ``short_hash(b.hex())``. ``None`` passes through.
|
|
30
|
+
"""
|
|
31
|
+
if value is None:
|
|
32
|
+
return None
|
|
33
|
+
if isinstance(value, bytes | bytearray | memoryview):
|
|
34
|
+
value = bytes(value).hex()
|
|
35
|
+
return hashlib.sha256(value.encode("utf-8")).hexdigest()[:length]
|