16
16
*/
17
17
package org.sonarsource.kotlin.checks
18
18
19
+ import org.jetbrains.kotlin.analysis.api.resolution.KaFunctionCall
19
20
import org.jetbrains.kotlin.psi.KtCallExpression
20
- import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
21
21
import org.sonar.check.Rule
22
22
import org.sonarsource.kotlin.api.checks.CallAbstractCheck
23
23
import org.sonarsource.kotlin.api.checks.FunMatcher
24
- import org.sonarsource.kotlin.api.reporting.SecondaryLocation
24
+ import org.sonarsource.kotlin.api.checks.FunMatcherImpl
25
25
import org.sonarsource.kotlin.api.checks.predictRuntimeStringValueWithSecondaries
26
+ import org.sonarsource.kotlin.api.reporting.SecondaryLocation
26
27
import org.sonarsource.kotlin.api.reporting.KotlinTextRanges.textRange
27
28
import org.sonarsource.kotlin.api.frontend.KotlinFileContext
28
29
@@ -33,21 +34,20 @@ val CIPHER_GET_INSTANCE_MATCHER = FunMatcher {
33
34
name = " getInstance"
34
35
}
35
36
36
- @org.sonarsource.kotlin.api.frontend.K1only
37
37
@Rule(key = " S5542" )
38
38
class EncryptionAlgorithmCheck : CallAbstractCheck () {
39
39
40
40
override val functionsToVisit = listOf (CIPHER_GET_INSTANCE_MATCHER )
41
41
42
42
override fun visitFunctionCall (
43
43
callExpression : KtCallExpression ,
44
- resolvedCall : ResolvedCall <* >,
45
- kotlinFileContext : KotlinFileContext ,
44
+ resolvedCall : KaFunctionCall <* >,
45
+ matchedFun : FunMatcherImpl ,
46
+ kotlinFileContext : KotlinFileContext
46
47
) {
47
- val bindingContext = kotlinFileContext.bindingContext
48
48
callExpression.valueArguments.firstOrNull()?.let { argument ->
49
49
argument.getArgumentExpression()!!
50
- .predictRuntimeStringValueWithSecondaries(bindingContext ).let { (algorithm, secondaries) ->
50
+ .predictRuntimeStringValueWithSecondaries().let { (algorithm, secondaries) ->
51
51
algorithm?.getInsecureAlgorithmMessage()?.let { errorMessage ->
52
52
val locations = secondaries.map { secondaryLocation ->
53
53
SecondaryLocation (kotlinFileContext.textRange(secondaryLocation), " Transformation definition" )
0 commit comments