-
Notifications
You must be signed in to change notification settings - Fork 317
Merge | SqlCommand Encryption Methods #3676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge | SqlCommand Encryption Methods #3676
Conversation
…ncryptionParameterResults
…ncryptionParameterResults
… the server returns the right number of rows for the sp_describe_parameter_encryption, but since it's just a debug build check, it has no bearing on prod builds.
…sEnclaveComputations
…roviders, HasColumnEncryptionKeyStoreProviderRegistered
…ParameterEncryptionRPC, IsDescribeParameterEncryptionRPCCurrentlyInProgress
…DescribeParameterEncryption
…yptionKeyStoreProvider
There was a problem hiding this comment.
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 merges SqlCommand encryption-related methods from platform-specific files into a shared partial class file for better code organization and maintainability. The changes consolidate encryption functionality that was previously duplicated across .NET Framework and .NET Core implementations.
- Moves encryption-related methods from platform-specific SqlCommand files to a new shared SqlCommand.Encryption.cs file
- Consolidates fields, properties, and methods related to column encryption and enclave operations
- Removes code duplication between netfx and netcore implementations
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| SqlCommand.Encryption.cs | New shared partial class containing all encryption-related methods and fields |
| SqlCommand.cs | Added encryption-related fields and properties to shared base class |
| SqlParameter.cs | Added TODO comment about parameter name prefixing logic |
| SqlSecurityUtility.cs | Added debug assertion for connection null check |
| EnclaveDelegate.cs | Added TODO comment about class naming |
| SqlCommand.netfx.cs | Removed encryption methods now in shared file |
| SqlCommand.netcore.cs | Removed encryption methods now in shared file |
| Project files | Added reference to new SqlCommand.Encryption.cs file |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good - we're almost there!
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs
Outdated
Show resolved
Hide resolved
…up on the code within.
040aef4 to
ca5037e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3676 +/- ##
==========================================
- Coverage 77.35% 76.75% -0.61%
==========================================
Files 271 273 +2
Lines 45123 44914 -209
==========================================
- Hits 34907 34474 -433
- Misses 10216 10440 +224
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Found all the bugs! Requesting new reviews from @mdaigle @paulmedynski :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see the build passing. Some commentary on the fixes will be nice.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding context to the fixes
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Encryption.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood and thought the latest commits were true modifications, not corrections of merge issues.


Description
This is the second to last PR I have planned for merging SqlCommand. In this installment, the methods related to parameter encryption are merged, as well as some other blocks that don't have well defined organization. I'm not certain that these should have their own partial, but to avoid the base partial being too large to navigate, I made the executive decision to make a partial. Each commit is bite-sized and focuses on a single or a couple related methods at a time.
The following methods were merged in this PR:
BuildStoredProcedureStatementForColumnEncryptionClearDescribeParameterEncryptionRequests_currentlyExecutingDescribeParameterEncryptionRPC_customColumnEncryptionKeyStoreProviderscustomDatacustomDataLengthenclaveAttestationParametersGetColumnEncryptionCustomKeyProvidersNamesGetEnclaveSessionParametersGetParameterEncryptionDataReader- code from netcore taken since it is more conciseGetParameterEncryptionDataReaderAsync- code from netcore taken since it is more conciseHasColumnEncryptionKeyStoreProviderRegisteredInvalidateEnclaveSessionIsDescribeParameterEncryptionRPCCurrentlyInProgresskeysToBeSentToEnclavePrepareDescribeParameterEncryptionRequestPrepareTransparentEncryptionFinallyBlockReadDescribeEncryptionParameterResultssp_describe_parameter_encryptionrowsAffectedmember as it was only being used to check if the server returned the right number of rows fromsp_describe_parameter_encryptionin debug mode.requiresEnclaveComputationsResetEncryptionStateRowsAffectedByDescribeParameterEncryption_rowsAffectedBySpDescribeParameterEncryption_rpcForEncryptionSetColumnEncryptionSettingShouldCacheEncryptionMetadataShouldUseEnclaveBasedWorkflow_sqlRPCParameterEncryptionRegArray_forceInternalEndQuery_forceRetryableEnclaveQueryExecutionExceptionDuringGenerateEnclavePackage_sleepAfterReadDescribeEncryptionParameterResults_sleepDuringRunExecuteReaderTdsForSpDescribeParameterEncryption_sleepDuringTryFetchInputParameterEncryptionInfoTryFetchInputParameterEncryptionInfoTryGetColumnEncryptionKeyStoreProviderValidateCustomProviders_wasBatchModeColumnEncryptionSettingsSetOnceIssues
Continuation of work in #1261
Testing
Build passes, SqlCommandTests pass locally. CI should validate the rest of it.