Repository navigation
Harden the trace exporter's file and endpoint handling - #656
Open
sabasiddique1 wants to merge 2 commits into
Open
sabasiddique1 wants to merge 2 commits into
sabasiddique1 wants to merge 2 commits into
Conversation
sabasiddique1
requested review from
GangGreenTemperTatum,
afogel,
artmaro,
bar-capsule,
fewdisc,
mamicidal,
rocklambros and
sclintonowasp
as code owners
November 20, 2026 21:13
This was referenced Nov 20, 2026
Open
bar-capsule
pushed a commit
that referenced
this pull request
Nov 24, 2026
## What changed Item 6 of #284 asks for tests that were missing, so a wrong attribute or a wrong path fails a test. This adds them, and gives the slow converter test a 30 s timeout. No file under `src` changes. ### Scope Against item 6 of #284: - **The "empty array is absent" rule.** Done. - **The off-by-default test, able to fail.** Done. It catches a default in the factory, and a relative default path in `startGuardian`. It misses a default endpoint or an absolute path there, because neither writes into the listed directory. - **End-to-end join test.** Done. Both files record the same step, a late decision. The Guardian's bridge is the real deployment bridge, held back until the host has timed out. - **Converter posture and parsing paths.** Done, in five tests. - **Slow converter test.** Done, with `30_000` as the third argument. It can't fail first here, because that test takes about half a second on my machine. - **`acs.exit_status`.** No work. `test/sample-trace.test.ts` already catches a wrong field, as rocklambros said on the issue. Items 1 to 5 and 7 of #284 are not here. rocklambros split the issue on 2026-10-31: item 6 here, the rest in PR #349. The fix to the test `emits the decision extras whether the mapping lists them or not` is in PR #349 too. ### Credit PR #349 is drk-ram's. The list of what each test should check is rocklambros's, from Ask 6 of his review of it. ### Questions for the reviewer @bar-capsule, no questions, one thing to know. This has merge conflicts with PR #349 in `test/audit-to-otlp.test.ts`: the imports, the `OtlpSpan` type, and the end of the file. Taking the union resolves it. I'll rebase if #349 merges first. It also conflicts with my PR #656 for #283 in `otel-trace-exporter.test.ts`, and I'll rebase mine there too. ## Which issue does this implement Part of #284 Refs #274 - [ ] This is an editorial correction (typo, grammar, link, formatting) with no change in meaning, so it needs no issue ## Base branch - [x] `integration`, because this touches the specification, schemas, a reference implementation, an adapter, tests, or CI - [ ] `main`, because every changed path is on the documentation lane allowlist in CONTRIBUTING.md ## Type of change - [ ] Specification change (schema, hooks, events, AgBOM) - [x] Reference implementation or adapter - [ ] Documentation - [ ] Tooling or CI - [ ] Governance (licensing, security policy, contributor docs) ## I tested this - [x] I synced my branch with the base branch before opening this - [x] `uv run pytest -v` passes on my machine - [x] `uv run mkdocs build --strict` passes on my machine ### How I tested From `reference-implementations/agt`, on Bun 1.3.11 and again on Bun 1.3.14: ```bash bun run typecheck bun test ``` - Typecheck is clean. - Bun 1.3.11: 1302 pass, 4 skip, 0 fail. - Bun 1.3.14: 1305 pass, 1 skip, 0 fail. - The two changed test files passed three runs in a row on each version. From the repo root, `uv run pytest -v` gives 1251 passed and 1 skipped, and `uv run mkdocs build --strict` passes. Each new or rewritten test goes red when the source it covers is broken. All of them also pass on top of PR #349 merged with `integration`. I ran this on macOS only. ## Checklist - [x] Commits are signed off with `git commit -s` (required by the DCO) - [x] Prose follows [STYLE.md](../STYLE.md) - [x] No secrets, tokens, or internal URLs in the diff ## Security - [x] This change has no security impact Signed-off-by: Saba Siddique <sabasiddiqdev@gmail.com>
sabasiddique1
force-pushed
the
refimpl/otel-file-endpoint-283
branch
from
November 25, 2026 18:16
9644474 to
f9ac0a0
Compare
Part of GenAI-Security-Project#283 Refs GenAI-Security-Project#274 Signed-off-by: Saba Siddique <sabasiddiqdev@gmail.com>
Signed-off-by: Saba Siddique <sabasiddiqdev@gmail.com>
10 of 18 tasks
sabasiddique1
force-pushed
the
refimpl/otel-file-endpoint-283
branch
from
November 25, 2026 18:36
f9ac0a0 to
60c5722
Compare
Collaborator
|
In review, I see there's conflicts: I don't see that this branch merges cleanly into integration (ts-cases.json under agt-go/agtbridge/testdata). It also conflicts with #655 in the guardian trace exporter source, its test, and the README. Please rebase onto integration first, then resolve the overlap with #655. Suggest #655 lands first, and this branch rebases on it. Happy to re-review once pushed. |
Collaborator
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The trace file was opened by path with no checks, so a symlink or another user's file could receive trace content, and plain
http://could carry spans to another host unencrypted. The file output now opens withO_WRONLY|O_APPEND|O_CREAT|O_NOFOLLOW|O_NONBLOCKon every append, checks the descriptor and the parent directory, and sets the mode to 0600. Plainhttp://to a host that is not loopback builds no endpoint output unlessACS_OTEL_ALLOW_PLAINTEXT_ENDPOINT=1is set. A step still open at shutdown past its timeout now gets classtimeout, andelapsed_msrounds up, so a late decision never shows the timeout value. An error code past the safe integer range is clamped to the bound, and one too large for a number is no longer dropped.Scope
Item by item against #283:
platformoption.http://. Done. No endpoint output without the opt-in, a warning with it, and a refusal with it whenOTEL_EXPORTER_OTLP_HEADERSorOTEL_EXPORTER_OTLP_TRACES_HEADERSis set. Loopback is read from the parsed address: 127.0.0.0/8,::1, and the IPv4-mapped form. The exporter reads those two headers variables fromprocess.envitself, because that is where the SDK reads them. It read no environment before. The Guardian README documents TLS and headers.timeout. Otherwise it staysother.elapsed_ms. Done. It is rounded up, so it never equalstimeout_mson a late decision.asClampedErrorCodeis added here, as rocklambros wrote it in his review of that PR. It clamps a code to the safe integer bounds, turns NaN into no code, and keeps a fraction, so -32005.5 stays on the step and is not read as a rejection. The exporter uses it. Tests cover -1e21, 1e21 and a 400-digit code, which clamp to the bound, -32005.5, which stays the same, and an exporter span with -1e21, which carries the bound.main.ts. Not here. It waits for PR Batch Guardian log writes and drain them on shutdown #112.Three things go past the letter of the issue:
http://127.0.0.2included.audit-to-otlp.ts.This PR and my PR #655 for #282 change the same shutdown lines, the Guardian README, the test file and the Go recording. I'll rebase whichever lands second.
Credit
Thanks to rocklambros for the clamp and its tests, from his review of PR #349, and to drk-ram for the first version of it in that PR. Thanks also to bar-capsule for the ruling on item 6, and to rocklambros for PR #309.
Questions for the reviewer
@rocklambros, two questions:
localhostis the one name that counts as loopback. Should it, or should it need the opt-in?Which issue does this implement
Part of #283
Refs #274
meaning, so it needs no issue
Base branch
integration, because this touches the specification, schemas, a referenceimplementation, an adapter, tests, or CI
main, because every changed path is on the documentation lane allowlist inCONTRIBUTING.md
Type of change
I tested this
uv run pytest -vpasses on my machineuv run mkdocs build --strictpasses on my machineHow I tested
From
reference-implementations/agt, on Bun 1.3.11 and again on Bun 1.3.14:bun run typecheck bun testFrom the repo root,
uv run pytest -vgives 1258 passed and 1 skipped, anduv run mkdocs build --strictpasses. Each new test goes red when the code it covers is broken.The second commit re-records the Go Guardian's TypeScript cases, because the Guardian source changed. From
reference-implementations/agt-goI ran./scripts/record-ts-cases.shwith Go 1.27.4. Only thepackages/guardian/srctree id changed. The 49 recorded answers are the same.go test ./...passes.I ran this on macOS only. CI is its first Linux run, and the Windows branch ran only through the
platformoption.Checklist
git commit -s(required by the DCO)Security
This is a hardening change. It refuses paths and endpoints that worked before:
/tmp, or in a directory that is a symlink;An existing trace file with a wider mode is changed to 0600.