-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Dispose secret instances #51253
Merged
Merged
Dispose secret instances #51253
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5cf5a56
Add dispose created and not used secrets
alex-inftx c8bd3c5
rename variable
alex-inftx b5c239c
Add dispose created and not used secrets
alex-inftx 3632172
rename variable
alex-inftx 722cdc1
Merge remote-tracking branch 'origin/dispose-secret-instances' into d…
alex-inftx 2a2a4bc
Add dispose created and not used secrets
alex-inftx 205f46d
rename variable
alex-inftx ee82296
Merge remote-tracking branch 'origin/dispose-secret-instances' into d…
alex-inftx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this is wrong because the key passed in with the returned object will already be disposed when the caller will try to use it.
@halter73 would you agree?
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 at the implementation of
CbcAuthenticatedEncryptor
, it copies the buffer and then releases all references to theSecret
inside the constructor. So, it's probably safe, but it feels like it's relying on an implementation detail.@GrabYourPitchforks is right that there is no memory leak, but it does look like it has a
SafeHandle
field that needs to be finalized if you don't dispose it. It looks like this is generally used only once per key by the singletonKeyRingProvider
, so maybe the finalization is okay in order to not rely on the implementation details of theEncryptor
constructors.What's your recommendation @GrabYourPitchforks?
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.
The general pattern of passing
Secret
instances around is that the receiver should make a standalone copy (via.ctor(ISecret)
) if they need a copy with a standalone lifetime, which allows the caller to maintain control over their own instance's lifetime. So I don't see any issues with this PR from a "this might break in the future" perspective.The PR seems to be fine from a correctness / regression perspective.
This PR would prevent the finalization of a few objects: let's ballpark it at single digits count per day. The determination of whether this is valuable I'll leave up to the aspnet team. :)