Skip to content

Python: Adjust request validation#14114

Merged
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-fix-http-plugin-port-validation
Jun 23, 2026
Merged

Python: Adjust request validation#14114
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-fix-http-plugin-port-validation

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Updates request validation behavior and related tests.

Refine request validation behavior and update related tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 11:57
@SergeyMenshykh SergeyMenshykh requested a review from a team as a code owner June 23, 2026 11:57
@moonbox3 moonbox3 added the python Pull requests for the Python Semantic Kernel label Jun 23, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Jun 23, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Jun 23, 2026
@SergeyMenshykh SergeyMenshykh moved this to Sprint: In Review in Semantic Kernel Jun 23, 2026
@github-actions github-actions Bot changed the title Adjust request validation Python: Adjust request validation Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
core_plugins
   http_plugin.py700100% 
TOTAL28899565780% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4051 23 💤 0 ❌ 0 🔥 1m 54s ⏱️

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.

Pull request overview

This PR tightens HttpPlugin request validation by adding port-based allow-listing, aiming to harden outbound HTTP requests (SSRF mitigation) and updates unit tests to reflect the new behavior.

Changes:

  • Added allowed_ports configuration to HttpPlugin with default behavior allowing only ports 80 and 443 unless overridden.
  • Implemented port parsing/enforcement as part of _is_uri_allowed validation logic.
  • Updated and expanded unit tests to cover default port restrictions, custom port allow-lists, and malformed ports.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
python/semantic_kernel/core_plugins/http_plugin.py Adds allowed_ports and enforces default-deny for non-standard ports during URL allow checks.
python/tests/unit/core_plugins/test_http_plugin.py Updates/extends tests to assert the new port validation behavior and configuration options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/semantic_kernel/core_plugins/http_plugin.py Outdated
Comment thread python/semantic_kernel/core_plugins/http_plugin.py Outdated
Comment thread python/semantic_kernel/core_plugins/http_plugin.py Outdated
Mark class constants as ClassVar, validate port syntax regardless of allow_all_domains, and clarify docstrings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SergeyMenshykh SergeyMenshykh enabled auto-merge June 23, 2026 12:52
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Jun 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Jun 23, 2026
Merged via the queue into microsoft:main with commit 88e1060 Jun 23, 2026
32 checks passed
@SergeyMenshykh SergeyMenshykh deleted the sergeymenshykh-fix-http-plugin-port-validation branch June 23, 2026 21:08
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Jun 23, 2026
@github-project-automation github-project-automation Bot moved this from Sprint: In Review to Sprint: Done in Semantic Kernel Jun 23, 2026
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

Status: Done
Status: Sprint: Done

Development

Successfully merging this pull request may close these issues.

5 participants