Repository navigation
Commit 483ffb4
Python: fix(python): Pin HttpPlugin requests to validated DNS addresses (#14649)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
`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
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
- 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
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Copilot App <[email protected]>1 parent a08e050 commit 483ffb4
2 files changed
Lines changed: 156 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
18 | 71 | | |
19 | 72 | | |
20 | 73 | | |
| |||
45 | 98 | | |
46 | 99 | | |
47 | 100 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
53 | 106 | | |
54 | 107 | | |
55 | 108 | | |
| |||
141 | 194 | | |
142 | 195 | | |
143 | 196 | | |
144 | | - | |
| 197 | + | |
145 | 198 | | |
146 | 199 | | |
147 | 200 | | |
| |||
153 | 206 | | |
154 | 207 | | |
155 | 208 | | |
156 | | - | |
| 209 | + | |
157 | 210 | | |
158 | 211 | | |
159 | 212 | | |
| |||
167 | 220 | | |
168 | 221 | | |
169 | 222 | | |
| 223 | + | |
170 | 224 | | |
171 | | - | |
| 225 | + | |
172 | 226 | | |
173 | 227 | | |
174 | 228 | | |
175 | 229 | | |
176 | | - | |
| 230 | + | |
177 | 231 | | |
178 | 232 | | |
179 | 233 | | |
| |||
185 | 239 | | |
186 | 240 | | |
187 | 241 | | |
188 | | - | |
| 242 | + | |
189 | 243 | | |
190 | 244 | | |
191 | | - | |
| 245 | + | |
192 | 246 | | |
193 | 247 | | |
194 | 248 | | |
| |||
207 | 261 | | |
208 | 262 | | |
209 | 263 | | |
210 | | - | |
| 264 | + | |
211 | 265 | | |
212 | 266 | | |
213 | 267 | | |
214 | 268 | | |
215 | | - | |
| 269 | + | |
216 | 270 | | |
217 | 271 | | |
218 | 272 | | |
| |||
234 | 288 | | |
235 | 289 | | |
236 | 290 | | |
237 | | - | |
| 291 | + | |
238 | 292 | | |
239 | 293 | | |
240 | 294 | | |
241 | 295 | | |
242 | | - | |
| 296 | + | |
243 | 297 | | |
244 | 298 | | |
245 | 299 | | |
| |||
256 | 310 | | |
257 | 311 | | |
258 | 312 | | |
259 | | - | |
| 313 | + | |
260 | 314 | | |
261 | 315 | | |
262 | | - | |
| 316 | + | |
263 | 317 | | |
264 | 318 | | |
265 | 319 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
579 | 664 | | |
580 | 665 | | |
581 | 666 | | |
| |||
0 commit comments