Skip to content

Python: fix(python): Pin HttpPlugin requests to validated DNS addresses - #14649

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
mainfrom
sk-httpplugin-url-safety
Oct 23, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
mainfrom
sk-httpplugin-url-safety

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation and Context

HttpPlugin validates the DNS addresses for allow-listed hosts before sending a request, but previously discarded those validated addresses before opening the connection. The HTTP transport could therefore resolve the hostname independently at connection time.

This change keeps validation and connection behavior consistent without redesigning the plugin or changing its explicit unrestricted/private-network opt-ins. No public issue is linked.

Description

  • Retain the IPv4/IPv6 addresses returned by the existing public-network validator.
  • Supply aiohttp with a host-scoped resolver that returns only those validated addresses.
  • Keep the original normalized URL for the request so Host headers, TLS SNI, and certificate validation retain the hostname identity.
  • Apply the same pinned connector path to GET, POST, PUT, and DELETE.
  • Preserve existing behavior for literal IP URLs and the explicit allow_all_domains / allow_private_network_access opt-ins.
  • Add regression coverage for every HTTP method and a real connection test proving a later hostname lookup is not used.

Validation:

  • uv build — passed; source distribution and wheel built successfully.
  • uv run --python 3.12 --frozen ruff check semantic_kernel\core_plugins\http_plugin.py tests\unit\core_plugins\test_http_plugin.py — passed.
  • uv run --python 3.12 --frozen pytest -q tests\unit\core_plugins\test_http_plugin.py — passed (226 tests).
  • uv run --python 3.12 --frozen pytest -q tests\unit\connectors\openapi_plugin\test_server_url_validator.py tests\unit\connectors\openapi_plugin\test_openapi_runner_dns_pinning.py — passed (91 tests).
  • uv run --python 3.12 --frozen mypy semantic_kernel\core_plugins\http_plugin.py — passed.
  • The repository pre-commit wrapper was attempted, but local hook-environment initialization did not complete; the changed Python files passed the direct Ruff formatting/lint checks above.

Contribution Checklist

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:55
@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Oct 23, 2026
@github-actions github-actions Bot changed the title fix(python): Pin HttpPlugin requests to validated DNS addresses Python: fix(python): Pin HttpPlugin requests to validated DNS addresses Oct 23, 2026

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.

🟢 Approval recommended

The implementation consistently pins all four HTTP methods to validated addresses, with focused regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR closes the gap between DNS validation and connection establishment in Python’s HttpPlugin by connecting only to validated addresses.

Changes:

  • Adds a host-scoped resolver and uses it for GET, POST, PUT, and DELETE.
  • Preserves the normalized hostname for HTTP headers and TLS, along with existing network-access opt-ins.
  • Adds per-method regression coverage and a real-connection test verifying that no second DNS lookup occurs.
File Description
python/​tests/​unit/​core_plugins/​test_http_plugin.py Adds resolver-pinning and real-connection regression tests.
python/​semantic_kernel/​core_plugins/​http_plugin.py Retains validated addresses and supplies a pinned resolver to each HTTP method.

Review effort: Balanced

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
core_plugins
   http_plugin.py112298%45, 66
TOTAL29187546681% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4522 22 💤 0 ❌ 0 🔥 2m 19s ⏱️

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 23, 2026
Merged via the queue into main with commit 483ffb4 Oct 23, 2026
33 checks passed
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) deleted the sk-httpplugin-url-safety branch October 23, 2026 19:30

This branch was successfully deployed

1 active and 1 inactive deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants