Skip to content

.Net: [BREAKING] Consolidate file access - #14679

Merged
westey (westey-m) merged 7 commits into
microsoft:mainfrom
westey-m:dotnet-shared-file-access
Oct 30, 2026
Merged

westey (westey-m) merged 7 commits into
microsoft:mainfrom
westey-m:dotnet-shared-file-access

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

Different plugins were using their own code for various file checks and file access.

Description

This PR consolidates file access to some common shared components.

Contribution Checklist

Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:28
@westey-m
westey (westey-m) requested a review from a team as a code owner October 29, 2026 16:28
@semantic-kernel-automation semantic-kernel-automation Bot added the .NET Issue or Pull requests regarding .NET code label Oct 29, 2026
@github-actions github-actions Bot changed the title Consolidate file access .Net: Consolidate file access Oct 29, 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.

🟡 Changes recommended

Active issues cause Linux uploads to fail beneath searchable but non-listable ancestors and expose filesystem resolution errors for paths outside the upload allow-list instead of returning the normal denial.

2 open issues
What changed in this PR

This PR consolidates local file access across the .NET plugins into a shared helper that validates allowed directories and opens files using platform-specific handles.

Changes:

  • Routes file reads, writes, downloads, and uploads through shared secure file access.
  • Updates connector contracts to use caller-owned streams and atomic open-or-create operations; local session downloads now require allowed directories.
  • Adds regression tests and a Windows, Linux, and macOS test workflow.
File Description
dotnet/​src/​Plugins/​Plugins.Web/​WebFileDownloadPlugin.cs Uses shared path normalization and secure destination opening.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Web/​WebFileDownloadPluginTests.cs Tests replacement links, overwrite races, and rejected responses.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Support/​SymbolicLinkFactAttribute.cs Adds platform-aware attributes for filesystem tests.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Plugins.UnitTests.csproj Removes directly compiled utility sources.
dotnet/​src/​Plugins/​Plugins.UnitTests/​MsGraph/​OneDriveConnectorTests.cs Tests upload stream ownership, position, and size limits.
dotnet/​src/​Plugins/​Plugins.UnitTests/​MsGraph/​CloudDrivePluginTests.cs Updates stream mocks and adds outside-link rejection coverage.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Document/​LocalFileSystemConnectorTests.cs Tests secure document access, preservation, and cancellation.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Document/​DocumentPluginTests.cs Adapts mocks to the revised filesystem contract.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Core/​SessionsPythonPluginTests.cs Tests download restrictions and link replacement.
dotnet/​src/​Plugins/​Plugins.UnitTests/​Core/​SecureFileSystemTests.cs Covers allowed paths, file modes, links, and special files.
dotnet/​src/​Plugins/​Plugins.MsGraph/​ICloudDriveConnector.cs Changes uploads from local paths to caller-owned streams.
dotnet/​src/​Plugins/​Plugins.MsGraph/​Connectors/​OneDriveConnector.cs Uploads provided streams without taking ownership.
dotnet/​src/​Plugins/​Plugins.MsGraph/​CloudDrivePlugin.cs Securely opens local upload content.
dotnet/​src/​Plugins/​Plugins.Document/​FileSystem/​LocalFileSystemConnector.cs Delegates restricted reads and updates to the shared helper.
dotnet/​src/​Plugins/​Plugins.Document/​FileSystem/​IFileSystemConnector.cs Defines restricted reads and atomic open-or-create updates.
dotnet/​src/​Plugins/​Plugins.Document/​DocumentPlugin.cs Passes allowed directories and uses creation status when appending.
dotnet/​src/​Plugins/​Plugins.Core/​Plugins.Core.csproj Exposes internals to plugin unit tests.
dotnet/​src/​Plugins/​Plugins.Core/​FileIOPlugin.cs Uses secure reads and atomic overwrite protection.
dotnet/​src/​Plugins/​Plugins.Core/​CodeInterpreter/​SessionsPythonSettings.cs Documents deny-by-default local download saves.
dotnet/​src/​Plugins/​Plugins.Core/​CodeInterpreter/​SessionsPythonPlugin.cs Uses secure upload and download streams.
dotnet/​src/​InternalUtilities/​src/​System/​SecureFileSystem.cs Adds shared validation and platform-specific secure file opening.
dotnet/​samples/​Demos/​CodeInterpreterPlugin/​Program.cs Clarifies download configuration in a comment.
.github/​workflows/​dotnet-secure-file-tests.yml Runs focused filesystem tests across three operating systems.

Review effort: Balanced

SergeyMenshykh
SergeyMenshykh previously approved these changes Oct 30, 2026
@westey-m westey (westey-m) changed the title .Net: Consolidate file access .Net: [BREAKING] Consolidate file access Oct 30, 2026
SergeyMenshykh
SergeyMenshykh previously approved these changes Oct 30, 2026
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 30, 2026
Merged via the queue into microsoft:main with commit 96c9e86 Oct 30, 2026
22 of 23 checks passed
@westey-m
westey (westey-m) deleted the dotnet-shared-file-access branch October 30, 2026 18:47

This branch was successfully deployed

1 active deployment
github-app-auth — 273e8410 Deployed Oct 30, 2026 by westey-m via add_label #29511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants