Skip to content

Demo/pr 127 coderabbit - #2

Open
evancoderabbit wants to merge 4 commits into
base-demo-127from
demo/pr-127-coderabbit
Open

Demo/pr 127 coderabbit#2
evancoderabbit wants to merge 4 commits into
base-demo-127from
demo/pr-127-coderabbit

Conversation

@evancoderabbit

Copy link
Copy Markdown
Owner

Description

  • Closes #[issue-number] (if applicable)

Testing


Checklist

  • Code has been tested locally
  • Unit tests have been added or updated
  • Documentation has been updated if needed

Additional Notes

Valiunia and others added 4 commits July 28, 2026 17:31
Mapbox APIs take the access token as a URL query parameter, and
OpenTelemetry's HTTP/undici auto-instrumentation records the full request
URL on every client span as `url.full` and `url.query`. Nothing scrubbed
those attributes before export, so any operator who followed the tracing
setup in docs/tracing.md and set OTEL_EXPORTER_OTLP_ENDPOINT had the
caller's token copied verbatim into their telemetry backend on every
authenticated tool call.

Wrap the OTLP exporter in a RedactingSpanExporter that rewrites
`access_token=<value>` to `access_token=***` across all string span
attributes (and span event attributes) on the way out, reusing the
existing redactToken() helper.

Redacting at the exporter rather than in an instrumentation requestHook
means the scrub covers every attribute on every span, including attribute
names introduced by future semantic-convention or instrumentation
changes, instead of only the four URL attribute names known today. Spans
needing no redaction are passed through by reference; spans that do are
copied field-by-field from the prototype chain rather than mutated, so
the SDK's own span state is untouched and the copy survives SDK version
differences in span shape.

docs/tracing.md previously claimed sensitive data was protected in
tracing output without qualification. It now describes what the exporter
actually does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Masking every token to `access_token=***` threw away context that is
useful in a trace and not sensitive: which kind of token was used, and
which account the request billed to.

Mapbox tokens are JWTs (`<prefix>.<payload>.<signature>`) whose payload
carries the account name under `u`, so redaction now decodes the payload
and emits `<prefix>.<account>.redacted` — `pk.some-account.redacted`,
`sk.some-account.redacted`, `tk.some-account.redacted`. The signature,
which is the part that actually authenticates, still never leaves the
process.

Anything that does not parse cleanly as such a token — unrecognized
prefix, wrong segment count, payload that is not base64 JSON, payload
with no usable `u` field, or an opaque legacy value — falls back to
`access_token=***`. An unrecognized shape is never partially disclosed on
the assumption it was harmless. The account name is also matched against
`[A-Za-z0-9_-]{1,64}` before being emitted, so a hostile payload cannot
inject arbitrary text into a span attribute.

This changes `redactToken()` itself, so the same enriched placeholder now
applies to the debug logs and MCP client error responses that already
used it, not only to exported spans.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The fixture tokens carried a real token's decoded payload (account name
and 'a' claim). The signature was already fake, so they were never usable
credentials, but there is no reason for a public test file to name a real
account. Switch to 'example-account'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The comment above ACCOUNT_NAME_PATTERN asserted that Mapbox usernames are
lowercase alphanumerics with dashes and underscores. That was not verified
against anything, and it contradicted the regex directly below it, which
accepts uppercase.

Describe what the allowlist is actually for — bounding what a token payload
can write into a span attribute or log line — and point at the existing
username validation in StyleComparisonTool as the precedent for the
character set, rather than claiming a rule about Mapbox account naming.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 45c3a897-dae7-4878-8001-b59cf6ceab4a

📥 Commits

Reviewing files that changed from the base of the PR and between 0306e2b and eccf5a5.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/tracing.md
  • src/tools/MapboxApiBasedTool.ts
  • src/utils/redactingSpanExporter.ts
  • src/utils/tracing.ts
  • test/tools/MapboxApiBasedTool.test.ts
  • test/utils/redactingSpanExporter.test.ts
 __________________________________
< I void warranties and segfaults. >
 ----------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch demo/pr-127-coderabbit

Comment @coderabbitai help to get the list of available commands.

@evancoderabbit

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Action performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@evancoderabbit
evancoderabbit marked this pull request as draft August 10, 2026 15:12
@evancoderabbit
evancoderabbit marked this pull request as ready for review August 10, 2026 15:12
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Action performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Action performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@evancoderabbit

Copy link
Copy Markdown
Owner Author

@coderabbitai review please

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@evancoderabbit I will review the current changes.

Action performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@evancoderabbit I will review the current changes.

Action performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants