-
Notifications
You must be signed in to change notification settings - Fork 470
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
Hopefully fixed the bug. #2710
Hopefully fixed the bug. #2710
Conversation
@@ -179,7 +179,7 @@ public override void Initialize(AnalysisContext context) | |||
operationAnalysisContext => | |||
{ | |||
IArrayInitializerOperation arrayInitializerOperation = (IArrayInitializerOperation)operationAnalysisContext.Operation; | |||
if (sourceInfoSymbolMap.IsSourceConstantArrayOfType(arrayInitializerOperation.Parent.Type as IArrayTypeSymbol)) | |||
if (sourceInfoSymbolMap.IsSourceConstantArrayOfType(arrayInitializerOperation.GetAncestor<IArrayCreationOperation>(OperationKind.ArrayCreation).Type as IArrayTypeSymbol)) |
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.
Can we be even more defensive and handle GetAncestor returning null gracefully by using “?.Type”?
@@ -343,10 +343,12 @@ public override TaintedDataAbstractValue VisitArrayInitializer(IArrayInitializer | |||
result = TaintedDataAbstractValue.MergeTainted(taintedAbstractValues); | |||
} | |||
|
|||
if (this.DataFlowAnalysisContext.SourceInfos.IsSourceConstantArrayOfType(operation.Parent.Type as IArrayTypeSymbol) | |||
IArrayCreationOperation arrayCreationOperation = operation.GetAncestor<IArrayCreationOperation>(OperationKind.ArrayCreation); | |||
IArrayTypeSymbol arrayTypeSymbol = arrayCreationOperation.Type as IArrayTypeSymbol; |
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.
Same here. I would handle null value return by GetAncestor and also null check before invoking IsSourceConstantArrayOfType (unless that method handles null input).
@@ -292,6 +292,26 @@ public void CreateEncryptor(byte[] rgbKey) | |||
GetCSharpResultAt(16, 9, 9, 22, "byte[] SymmetricAlgorithm.Key", "void TestClass.CreateEncryptor(byte[] rgbKey)", "byte[] Convert.FromBase64String(string s)", "void TestClass.TestMethod()")); | |||
} | |||
|
|||
[Fact] | |||
public void Test_HardcodedIn2DByteArray_CreateEncryptor_Diagnostic() |
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.
Test_HardcodedIn2DByteArray_CreateEncryptor_Diagnostic [](start = 20, length = 54)
It'd be good to add a test for a jagged array (like byte[][]) also.
Is there a test case that covers the assert from #2708?
#2707
#2708