Skip to content

JS: Add OpenTelemetry logging sink models - #23320

Open
adityareddy-dev wants to merge 3 commits into
github:mainfrom
adityareddy-dev:js-opentelemetry-logging-models
Open

adityareddy-dev wants to merge 3 commits into
github:mainfrom
adityareddy-dev:js-opentelemetry-logging-models

Conversation

@adityareddy-dev

@adityareddy-dev adityareddy-dev commented Dec 1, 2026 •

Copy link
Copy Markdown

Adds OpenTelemetry logging sink models for JS/TS in javascript/ql/lib/ext/opentelemetry.model.json and wires log-injection models into js/clear-text-logging.

Right now js/clear-text-logging only checks LoggerCall and ignores log-injection sinks from models-as-data. Adding SinkFromModel in CleartextLoggingCustomizations.qll matches LogInjectionQuery.qll and the Java, Go, and Rust clear-text logging queries.

The model covers Logger.emit (body and exception for log-injection, plus structured attributes modeled separately for js/clear-text-logging via OpenTelemetryLogAttributesSink) across @opentelemetry/api-logs, @opentelemetry/api 1.10+, and @opentelemetry/sdk-logs. It also models DiagLogger methods on diag, diag.createComponentLogger(...), and new DiagConsoleLogger().

I left tracing span APIs like span.setAttribute and structured log attributes out of log-injection on purpose. Passing request metadata into structured attributes is standard OpenTelemetry instrumentation and would create false positives in js/log-injection.

@adityareddy-dev
adityareddy-dev requested a review from a team as a code owner December 1, 2026 23:19
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 23:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The log-injection sink incorrectly flags structured request attributes, requiring separate attribute modeling and a negative regression test.

1 open issue
What changed in this PR

Adds OpenTelemetry logging coverage to JavaScript/TypeScript security analysis.

Changes:

  • Models Logger.emit and diagnostic logging methods.
  • Enables clear-text logging analysis to consume log-injection sink models.
  • Adds regression fixtures and expected results for both queries.
File Description
javascript/​ql/​test/​query-tests/​Security/​CWE-312/​opentelemetry.ts Adds sensitive-data logging tests.
javascript/​ql/​test/​query-tests/​Security/​CWE-312/​CleartextLogging.expected Records expected clear-text logging results.
javascript/​ql/​test/​query-tests/​Security/​CWE-117/​opentelemetry.ts Adds log-injection tests and safe cases.
javascript/​ql/​test/​query-tests/​Security/​CWE-117/​LogInjection.expected Records expected log-injection results.
javascript/​ql/​lib/​semmle/​javascript/​security/​dataflow/​CleartextLoggingCustomizations.qll Incorporates model-defined logging sinks.
javascript/​ql/​lib/​ext/​opentelemetry.model.json Defines OpenTelemetry types and logging sinks.
javascript/​ql/​lib/​change-notes/​2026-12-01-opentelemetry-logging.md Documents expanded analysis coverage.

Review effort: Balanced (adaptive)

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants