-
Notifications
You must be signed in to change notification settings - Fork 4k
[Storage] Fix MD5 not work on FIPS enabled machine issue #5746
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
Conversation
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.
@blueww
Thanks for fixing the issue :)
The changes look good to me... but this is a scenario we would like to have tests for. Do kindly add tests for this.
Currently, we don't have Unit test for E2E of Storage data plan cmdlets. But will cover it in another test framework. So for this change, the test we can do is to check FIPSEnabled is disable on normal machine. But dur to the protect level, we can't access FIPSEnabled from test case. I can change FIPSEnabled to public to add a test. But it looks not proper to change an object from protected to public just for test. So I think we can wait for @MiYanni to add the storage Unit test, then add test case for it. |
@blueww I'm not involved in this situation/issue. What's going on? |
@MiYanni |
@blueww Thanks for the explanation. |
{ | ||
get | ||
{ | ||
if (fIPSEnabled.HasValue) |
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.
typo?
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.
fixed, use fipsEnabled
return false; | ||
} | ||
} | ||
private static bool? fIPSEnabled = null; |
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.
variable name should be fipsEnabled
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.
fixed, use fipsEnabled
fIPSEnabled = true; | ||
return true; | ||
} | ||
fIPSEnabled = false; |
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.
vertical space
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.
public static bool FipsEnabled {get;} = IsFIPSEnabled();
internal static bool ISFIPSEnabled()
{
try
{
System.Security.Cryptography.MD5.Create();
return false;
}
catch (System.Reflection.TargetInvocationException)
{
return true;
}
}
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 we can take advantage of the fact that the static initializer will run once to simploify the code - so we cans et the value and then use it 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.
Fixed as the code from you. Thanks!
// if FIPS policy is enabled, must use native MD5 | ||
if (FIPSEnabled) | ||
{ | ||
CloudStorageAccount.UseV1MD5 = false; |
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.
Is this the only cmdlet that would be impacted? Wouldn't every blob-related cmdlet need this setting?
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.
Only upload blob/file cmdlets need use MD5 function to calculate blob/file Property "ContentMD5". Other cmdlets don't use this function. So only need change cmdlets Set-AzureStorageBlob(File)Content
I have fixed the comments from you, please help to check. Change log is also added. |
Description
Fix the issue #4807
The resolution:
With this change:
Checklist
CONTRIBUTING.md
platyPS
module