Skip to content

ci(codeql): exclude emulator TLS test files from cert-validation alert#3158

Merged
bk201- merged 1 commit into
mainfrom
ci/codeql-exclude-emulator-tls-tests
Jun 17, 2026
Merged

ci(codeql): exclude emulator TLS test files from cert-validation alert#3158
bk201- merged 1 commit into
mainfrom
ci/codeql-exclude-emulator-tls-tests

Conversation

@bk201-

@bk201- bk201- commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

CodeQL (js/disabling-certificate-validation) flags the rejectUnauthorized: false scoped https.Agent used to reach the Cosmos DB emulator's self-signed certificate in two test-only files:

  • test/e2e/setup/emulator.ts (e2e emulator readiness probe)
  • scripts/import-seed.mjs (local seed/dev script)

Why exclude rather than fix

There is no SDK option to trust the emulator's self-signed certificate, and the linux/vnext-preview emulator exposes no reliable certificate to import (its /_explorer/emulator.pem endpoint returns HTTP 400 — already documented in emulator.ts). The agent is already correctly scoped (not a global NODE_TLS_REJECT_UNAUTHORIZED=0), so the relaxation doesn't leak to other HTTPS calls.

Since these files never run in production, they are added to sdl.codeql.excludePathPatterns in .azure-pipelines/build.yml rather than weakening the check for shipped code. The production path (src/cosmosdb/getCosmosClient.ts) is intentionally not excluded — it gates rejectUnauthorized on isEmulator.

Changes

  • .azure-pipelines/build.yml: add the two test files to excludePathPatterns with an explanatory comment.

The e2e emulator setup (test/e2e/setup/emulator.ts) and seed script
(scripts/import-seed.mjs) use a scoped https.Agent with
rejectUnauthorized: false to reach the Cosmos DB emulator's self-signed
certificate. CodeQL flags this as js/disabling-certificate-validation,
but the emulator exposes no reliable certificate to trust and these
files never run in production, so exclude them via excludePathPatterns
rather than weakening the check for shipped code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bk201- bk201- requested a review from a team as a code owner June 16, 2026 15:53
@github-actions

Copy link
Copy Markdown
Contributor

🔨 Build (Compile, Lint, Prettier, l10n, Package)

🔗 Source

🧱 Step Results

  • Validate Version: ✅ success
  • Localization: ✅ success
  • Lint: ✅ success
  • Prettier: ✅ success
  • Compile (tsc): ✅ success
  • Package: ✅ success
  • External Skills (info): ✅ success

📦 Package Information

📥 Artifacts (run)

✅ Build Status

Compile, analyzers and packaging passed. See sibling comments for unit/integration and E2E results.

@github-code-quality

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/vitest

The overall coverage remains at 81%, unchanged from the branch.


Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Tests (Unit + Integration)

Commit: 6562c7d
Pull Request: #3158 ci(codeql): exclude emulator TLS test files from cert-validation alert

🧪 Results

  • Unit Tests (vitest): ✅ success
  • Integration Tests (extension host): ✅ success

@bk201- bk201- merged commit ebf3bef into main Jun 17, 2026
7 checks passed
@bk201- bk201- deleted the ci/codeql-exclude-emulator-tls-tests branch June 17, 2026 10:03
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