Skip to content

Commit

Permalink
identation + remove equals
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Jul 20, 2023
1 parent 926551e commit 0935a93
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ protected override ProgramState PreProcessSimple(SymbolicContext context)
return ProcessAssignmentToIVProperty(state, assignment) ?? state;
}
else if (operation.AsPropertyReference() is { } property
&& property.Instance is { } propertyInstance
&& state.ResolveCaptureAndUnwrapConversion(propertyInstance).TrackedSymbol() is { } propertyInstanceSymbol
&& IsIVProperty(property, propertyInstanceSymbol)
&& state[propertyInstance]?.Constraint<ByteCollectionConstraint>() is { } constraint)
&& property.Instance is { } propertyInstance
&& state.ResolveCaptureAndUnwrapConversion(propertyInstance).TrackedSymbol() is { } propertyInstanceSymbol
&& IsIVProperty(property, propertyInstanceSymbol)
&& state[propertyInstance]?.Constraint<ByteCollectionConstraint>() is { } constraint)
{
return state.SetOperationConstraint(property, constraint);
}
else if (operation.AsInvocation() is { } invocation)
{
return ProcessGenerateIV(state, invocation)
?? ProcessCreateEncryptorMethodInvocation(state, invocation)
?? state;
?? ProcessCreateEncryptorMethodInvocation(state, invocation)
?? state;
}
else
{
Expand All @@ -66,7 +66,7 @@ private static ProgramState ProcessAssignmentToIVProperty(ProgramState state, IA
: null;

private static ProgramState ProcessGenerateIV(ProgramState state, IInvocationOperationWrapper invocation) =>
invocation.TargetMethod.Name.Equals(nameof(SymmetricAlgorithm.GenerateIV))
invocation.TargetMethod.Name == nameof(SymmetricAlgorithm.GenerateIV)
&& invocation.TargetMethod.ContainingType.DerivesFrom(KnownType.System_Security_Cryptography_SymmetricAlgorithm)
? state.SetSymbolConstraint(state.ResolveCaptureAndUnwrapConversion(invocation.Instance).TrackedSymbol(), ByteCollectionConstraint.CryptographicallyStrong)
: null;
Expand All @@ -88,10 +88,10 @@ bool UsesCryptographicallyWeakIVProperty(ProgramState state, IInvocationOperatio
}

private static bool IsCreateEncryptorMethod(IInvocationOperationWrapper invocation) =>
invocation.TargetMethod.Name.Equals(nameof(SymmetricAlgorithm.CreateEncryptor))
invocation.TargetMethod.Name == nameof(SymmetricAlgorithm.CreateEncryptor)
&& invocation.TargetMethod.ContainingType.DerivesFrom(KnownType.System_Security_Cryptography_SymmetricAlgorithm);

private static bool IsIVProperty(IPropertyReferenceOperationWrapper property, ISymbol propertyInstance) =>
property.Property.Name.Equals("IV")
property.Property.Name == "IV"
&& propertyInstance.GetSymbolType().DerivesFrom(KnownType.System_Security_Cryptography_SymmetricAlgorithm);
}

0 comments on commit 0935a93

Please sign in to comment.