Repository navigation
fix(data_flow,propagation): validate endpoints and size/token bounds, reject control chars and conflicting headers in Python and TypeScript (#104) - #108
Conversation
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
50a97ec to
4504aef
Compare
dinakarjs
left a comment
There was a problem hiding this comment.
Reviewed source at 4504aef. Python unittest discovery passed with inherited OTEL_* variables removed; the initial three OTel failures were environment configuration. TypeScript build and all 44 existing tests passed using node --import tsx --test test/*.test.ts; the npm check launcher itself encountered an IPC-listen EPERM here, so I do not claim that wrapper passed. Local results only, not hosted CI. Python: 159 tests pass.
The new combined test stops on its first failing size assertion, so it does not independently demonstrate the control-character and conflicting-header guards. Please split the regression into independent tests and add valid twins, including identical case-insensitive duplicate headers and boundary size values. Also correct the description's closing reference: data-flow/propagation is #104, not #103.
Source review and local validation are complete within this scope; regression coverage remains for author follow-up before approval.
Prepared with OpenAI Codex.
|
Thanks @dinakarjs! Split the regression into three independent test methods in |
dinakarjs
left a comment
There was a problem hiding this comment.
Re-reviewed exact head a353e79. The independent data-flow, control-character, and conflicting-header tests address my failure-isolation request, retain valid boundaries and identical-header controls, and the issue reference is corrected to #104. Local Python suite: 161 passed; TypeScript build and all 44 tests pass using node --import tsx --test test/*.test.ts. Independently removing the control-character guard or the conflicting-header guard makes the corresponding committed assertions fail. No source edits retained. This is bounded source/test approval; hosted checks remain separate. Broad optional Ruff reports findings, so this does not claim repository-wide lint cleanliness. Reviewed with OpenAI Codex.
a353e79 to
cec2a3f
Compare
imran-siddique
left a comment
There was a problem hiding this comment.
Approving at cec2a3f: ran conformance, the Python suite and the TS check on this head; each new test fails against main's source; all 11 PRs in this series merge onto main together without conflicts and pass combined.
There was a problem hiding this comment.
A few things:
- Issue #104 asks for the control-character and conflicting case-insensitive header checks in both Python and TypeScript. Python does this now, but
packages/typescript/src/propagation.tsstill accepts control chars (\x00–\x1f,\x7f) and silently picks one value when there are conflicting case-insensitive duplicates on the run/workflow/agent headers, kindly add the same guard and test there - the new Python tests only hit
_safe_value/_header. Worth also coveringinject_context/extract_contextso the public API is locked in. classified_data_flowstill calls the classifier before checking thatsource/destinationareDataEndpoints, so a bad endpoint still runs the user classifier. Moving those checks first would be a small improvement (same pattern exists in TS).
… data_flow and reject control chars and conflicting headers in propagation (agentrust-io#104) - Validate DataEndpoint types and non-negative safe-integer size_bytes and token_count in Python classified_data_flow, matching TypeScript classifiedDataFlow. - Reject ASCII control characters and conflicting case-insensitive duplicate headers in Python propagation. Closes agentrust-io#104 Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
… twins Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
… Python and check endpoints before classifying (agentrust-io#104) - TypeScript injectContext/extractContext reject ASCII control characters (U+0000-U+001F, U+007F) in the AgenTrust header values, and extractContext rejects case-insensitive duplicates of the run, workflow and agent headers that carry different values. Identical duplicates are still accepted, as in Python. It used to take the first header it found. - classified_data_flow and classifiedDataFlow check that source and destination are DataEndpoints before calling the caller's classifier, so a malformed endpoint no longer runs it. TypeScript had no such check and failed later with a missing asEventValue. - Cover inject_context and extract_context directly in Python, and the control-character, duplicate-header, length and endpoint-ordering cases in both languages, each with a valid twin. Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
c24d169 to
6718497
Compare
|
@rajnisht7 thanks, all three are in at 6718497, rebased onto current
I also added a CHANGELOG entry and a line in |
rajnisht7
left a comment
There was a problem hiding this comment.
Thank you for the update, the previous findings are addressed.
one thing (can be followed up): Python and TypeScript disagree on the meaning of the 512-character limit for supplementary Unicode characters
Summary
classified_data_flow(src/agentrust_telemetry/data_flow.py) validatesisinstance(source, DataEndpoint),isinstance(destination, DataEndpoint), and non-negative safe-integersize_bytesandtoken_count(rejectingbool) to match TypeScriptclassifiedDataFlow.propagation.pyrejects ASCII control characters (\x00..\x1f,\x7f) and conflicting case-insensitive duplicate correlation headers.propagation.tsgets the same two guards forinjectContext/extractContext. Identical case-insensitive duplicates are still accepted, as in Python. Before this, TS accepted control characters and silently used the first of two conflicting headers.classified_data_flowandclassifiedDataFlowchecksourceanddestinationbefore they call the caller's classifier, so a malformed endpoint no longer runs it. TS had no explicit check and failed later on a missingasEventValue.inject_context/extract_contextdirectly in Python (previously only_safe_value/_header). TS tests cover control characters, conflicting vs identical duplicates, the 512-character limit and anundefinedheader value. Both languages assert that a bad endpoint raises before the classifier is called, each with a valid twin.CHANGELOG.mdanddocs/architecture.mddescribe the header rules.Closes #104
Contract impact
Evidence
Python 3.11, Node 26, Windows.
python tools/sync_schemas.py: no output, no diff.python tools/check_schemas.py: PASS, 8 bundled schemas match normative bytes.python conformance/runner/validate.py: PASS.python -m unittest discover -s tests -v: 203 tests OK (2 skipped).python -m build: sdist and wheel built.Also run:
tools/check_workflow_oidc.py,check_versions.py,check_otel_compatibility.pyandcheck_typescript_schemas.py(all PASS);npm run checkinpackages/typescript(build, 87 tests,npm pack --dry-run) passed;git diff origin/main...HEAD --checkis clean.ruff checkon the four changed Python files reports the same 9 findings as before this change, none on changed lines.mypy srcreports the same 6 existing errors, none indata_flow.pyorpropagation.py.Patch coverage (
coverage run --branchfor Python, Node's test coverage for TS): every changed line indata_flow.py,propagation.py,data-flow.tsandpropagation.tsis executed, with no uncovered branch on a changed line. Removing the TS control-character guard, the TS duplicate check, theundefinedfilter, or the endpoint check-before-classify (TS or Python) fails the new tests.Privacy and security
Limits
This adds input validation only; the wire contract is unchanged. It does not stop a caller from setting a header on the carrier directly, and it does not address duplicate
traceparentheaders.