Skip to content

Python: Extend InMemoryCollection filter attribute blocklist#13897

Merged
moonbox3 merged 1 commit intomicrosoft:mainfrom
moonbox3:python/block-base-attr-in-memory-filter
Apr 22, 2026
Merged

Python: Extend InMemoryCollection filter attribute blocklist#13897
moonbox3 merged 1 commit intomicrosoft:mainfrom
moonbox3:python/block-base-attr-in-memory-filter

Conversation

@moonbox3
Copy link
Copy Markdown
Collaborator

Summary

  • Minor defense-in-depth hardening for InMemoryCollection filter parsing.
  • Extends the internal dunder attribute blocklist and adds a regression test covering the blocked set.

Test plan

  • uv run pytest tests/unit/connectors/memory/test_in_memory.py

Copilot AI review requested due to automatic review settings April 21, 2026 00:41
@moonbox3 moonbox3 requested a review from a team as a code owner April 21, 2026 00:41
@moonbox3 moonbox3 added the python Pull requests for the Python Semantic Kernel label Apr 21, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 93% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by moonbox3's agents

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens InMemoryCollection’s string-filter sandboxing by expanding the blocked attribute set and adding a regression test to ensure common introspection/function-internals dunder attributes are rejected during filter parsing.

Changes:

  • Add __base__ to the blocked_filter_attributes set used by the in-memory filter validator/evaluator.
  • Add a parametrized unit test asserting several dangerous dunder attributes are rejected with a clear error.

Reviewed changes

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

File Description
python/semantic_kernel/connectors/in_memory.py Extends the filter attribute blocklist to include __base__ (defense-in-depth against sandbox escape chains).
python/tests/unit/connectors/memory/test_in_memory.py Adds regression coverage to ensure key blocked dunder attributes are consistently rejected.

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

@moonbox3
Copy link
Copy Markdown
Collaborator Author

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
connectors
   in_memory.py40113566%67–70, 74, 78–81, 97, 101, 107–108, 138, 147, 155, 161, 167–168, 178–179, 183–186, 195–196, 200–201, 205–211, 215–229, 235–238, 258, 260, 263–268, 270, 279–282, 285, 290–292, 296–297, 302, 307, 315–333, 339–347, 354, 356, 359, 366, 381–382, 385, 390, 401–402, 405, 409, 614, 626, 628, 669, 673, 677, 692, 709, 724, 751, 771, 777, 790, 818, 823, 832, 845, 866, 901
TOTAL28578564780% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3874 23 💤 0 ❌ 0 🔥 1m 53s ⏱️

@moonbox3 moonbox3 enabled auto-merge April 21, 2026 00:52
@moonbox3 moonbox3 added this pull request to the merge queue Apr 22, 2026
Merged via the queue into microsoft:main with commit 79ef93b Apr 22, 2026
38 checks passed
@moonbox3 moonbox3 deleted the python/block-base-attr-in-memory-filter branch April 22, 2026 23:48
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.

4 participants