Skip to content
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

[#6590] Error while saving bot state to azure blob storage #6595

Merged
merged 2 commits into from Mar 8, 2023

Conversation

sw-joelmut
Copy link
Collaborator

Fixes #6590

Description

This PR refactors the use of AllowedTypesSerializationBinder to be optionally provided through a JsonSerializer configuration across Blobs and CosmosDB storage constructors.

Behavior of AllowedTypesSerializationBinder:

  • It will only be used in the Blobs and CosmosDB storage when provided through the JsonSerializer.SerializationBinder, otherwise it will not execute any related code to the class.
  • When provided, it will evaluate which types need to be allowed and fail with a message to do so.
  • When provided with all the types to allow, it will behave as normal, but with an extra layer of security to allow only desired types in the application.

Specific Changes

  • Removed all code that was making Blobs, AzureBlobs (removed altogether, since it's deprecated) and CosmosDB storage dependent of the AllowedTypesSerializationBinder class, leaving only the verification process when the class is provided.
  • Updated the AllowedTypesSerializationBinder internal class behavior, removing the process that loads the types dynamically to use only the ones provided by the user, and added a step to recognize types that are represented as a generic type (e.g. List).
  • Updated the tests related to this process by removing the ones that weren't necessary anymore, and adding new ones to test when the AllowedTypesSerializationBinder is provided through the JsonSerializer instance.

Testing

The following images show the unit tests passing successfully and how the new binder implementation works.
image
image

@sw-joelmut sw-joelmut added the Automation: No parity PR does not need to be applied to other languages. label Feb 27, 2023
@sw-joelmut sw-joelmut requested a review from a team as a code owner February 27, 2023 16:46
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 342214

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 79.098%

Files with Coverage Reduction New Missed Lines %
/libraries/AdaptiveExpressions/BuiltinFunctions/GetNextViableTime.cs 1 90.91%
/libraries/AdaptiveExpressions/BuiltinFunctions/GetPreviousViableTime.cs 1 90.91%
/libraries/Microsoft.Bot.Builder/AllowedTypesSerializationBinder.cs 3 95.65%
Totals Coverage Status
Change from base Build 341699: -0.01%
Covered Lines: 25813
Relevant Lines: 32634

💛 - Coveralls

@BruceHaley
Copy link
Contributor

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Azure.dll

@tracyboehrer tracyboehrer merged commit dc923ad into main Mar 8, 2023
1 check passed
@tracyboehrer tracyboehrer deleted the southworks/update/serialization-binder branch March 8, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation: No parity PR does not need to be applied to other languages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while saving bot state to azure blob storage
5 participants