Repository navigation
[release/17.0] Pin the dev certificate in extension E2E HTTPS probes instead of disabling validation - #22043
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Conversation
…bling validation (#21898) ## Description CodeQL reports `js/disabling-certificate-validation` ([CodeQL.SM03616], Critical) against `extension/src/test-e2e/helpers/assertions.ts`: `getUrlText` passed `rejectUnauthorized: false` to `https.get`. The live VS Code extension E2E tests use it (through `waitForHttpText`) to probe the Dashboard and HTTPS resource endpoints of a running AppHost, which are served with the ASP.NET Core development certificate. Clean machines and hosted runners do not trust that certificate, so verification was switched off for the probe. This PR keeps verification on and trusts exactly the certificate the AppHost serves: - `extension/scripts/run-e2e.js` exports the public half of the development certificate with `dotnet dev-certs https --export-path <run-root>/aspnetcore-dev-cert.pem --format Pem` and passes the file to the test process as `ASPIRE_EXTENSION_E2E_DEV_CERT_PATH`. The export creates the certificate if the machine has none (as the CLI does on first run) but never trusts it, and writes no private key (`dotnet dev-certs` only writes one with `--password`/`--no-password`). A failed export is a warning, not a failure, so shards that never probe HTTPS are unaffected. - `extension/src/test-e2e/helpers/assertions.ts` replaces `rejectUnauthorized: false` with `ca: <exported PEM>`. Chain and host name validation still run, any other certificate is rejected, and without the env var the default trust store applies. No `checkServerIdentity` override, `NODE_TLS_REJECT_UNAUTHORIZED`, or other bypass is introduced, and the extension's own runtime behavior is unchanged (this is test-helper and test-runner code only). - `extension/src/test-e2e/helpers/paths.ts` gets `getDevCertPath()`. How this removes the flagged pattern: CodeQL's query matches TLS options that set `rejectUnauthorized: false` (or an equivalent bypass). The helper now supplies a CA certificate to the TLS client instead, which keeps validation enabled, so no suppression comment is needed. ### Validation All commands were run from `extension/` on Windows (Node 22, repo-local .NET SDK). | Command | Result | | --- | --- | | `corepack yarn install --frozen-lockfile` | Passed (no lockfile changes) | | `corepack yarn run compile-tests` (`tsc -p . --outDir out`) | Passed | | `corepack yarn run compile-e2e` (`tsc -p tsconfig.e2e.json`) | Passed | | `corepack yarn run compile` (webpack) | Passed | | `corepack yarn run lint` (`eslint src`) | Passed, no warnings | | `corepack yarn run unit-test` (full suite) | 4151 passing, 9 pending, 2 failing. The 2 failures are `E2E download cache` tests (`fails before publishing when a concurrent unusable generation fills the recovery bound` and `observes a symlinked cache entry group without mutating it before miss-path repair`): Windows filesystem `ctime`/symlink assertions in untouched code that fail identically on an unmodified tree. | Manual check against the real thing: I ran the repo's `Aspire.Dashboard` over `https://localhost:18943` (Kestrel's default development certificate), exported the certificate with the exact command the runner uses, and called `waitForHttpText`. Without the pin it was rejected with `self-signed certificate` (the CI condition); with `ASPIRE_EXTENSION_E2E_DEV_CERT_PATH` set it returned the page. Not run: the live VS Code E2E shards (`zeroToRunning`, `debugDashboard`, `azureFunctions`) were not run locally because they need a repo-built CLI, a packaged VSIX, ExTester-downloaded VS Code/ChromeDriver and NuGet packages for the fixture AppHost; they run in `extension-e2e-tests.yml`. Note that E2E shards with `advisoryIssue` can pass the job despite completed test failures, so check the Mocha results of the HTTPS-probing shards and not just the job conclusion. ### Security considerations This change removes a disabled-certificate-validation pattern from test code. The runner reads the dev-certs public certificate (no private key) from the user's certificate store and writes it under the per-run temp root, which is deleted at the end of the run; if no development certificate exists on the machine, `dotnet dev-certs` creates one without trusting it, which matches what the CLI already does on first run. Reviewers should confirm the trust is limited to the exported certificate (`ca` replaces the default roots for these requests only) and that no E2E helper regains a verification bypass. Fixes # (issue) --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 7dc0df2)
14 tasks
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
marked this pull request as ready for review
November 10, 2026 05:13
Mitch Denny (mitchdenny)
requested review from
Adam Ratzman (adamint) and
Ella Hathaway (ellahathaway)
as code owners
November 10, 2026 05:13
Member
Author
|
Approved for inclusion in release/17.0. Do not merge yet. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-45-pr21898
branch
from
November 10, 2026 06:14
bd3d1da to
5f85a44
Compare
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22043Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22043" |
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-45-pr21898
branch
from
November 10, 2026 06:23
5f85a44 to
bd3d1da
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-45-pr21898
branch
from
November 10, 2026 07:58
bd3d1da to
5f85a44
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-45-pr21898
branch
from
November 10, 2026 08:33
5f85a44 to
bd3d1da
Compare
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.
Description
Backport of #21898 to
release/17.0(cherry-picked from 7dc0df2 with no modifications).Layer 45 of 55 in the release/17.0 backport stack; stacked on #22042.
Backport recommendation: No — Extension E2E tests only.
Validation: Stable patch IDs match (
0843a8233826e1a5043a3f178e994e8243ba8f28). Builds/tests not run for this unchanged cherry-pick.Backport of #21898
Checklist
<remarks />and<code />elements on your triple slash comments?