@@ -18,7 +18,6 @@ package org.sonarsource.kotlin.checks
18
18
19
19
import org.jetbrains.kotlin.psi.KtCallExpression
20
20
import org.jetbrains.kotlin.psi.KtExpression
21
- import org.jetbrains.kotlin.resolve.BindingContext
22
21
import org.sonar.check.Rule
23
22
import org.sonarsource.kotlin.api.checks.AbstractCheck
24
23
import org.sonarsource.kotlin.api.checks.ArgumentMatcher
@@ -94,19 +93,17 @@ private val WEAK_METHOD_MATCHERS = listOf(
94
93
private val DEPRECATED_SPRING_PASSWORD_ENCODER_METHODS = DEPRECATED_SPRING_PASSWORD_ENCODERS .map(::ConstructorMatcher ).toList() +
95
94
FunMatcher (qualifier = " org.springframework.security.crypto.password.NoOpPasswordEncoder" , name = GET_INSTANCE )
96
95
97
- @org.sonarsource.kotlin.api.frontend.K1only
98
96
@Rule(key = " S4790" )
99
97
class DataHashingCheck : AbstractCheck () {
100
98
101
99
override fun visitCallExpression (expression : KtCallExpression , kotlinFileContext : KotlinFileContext ) {
102
- val bindingContext = kotlinFileContext.bindingContext
103
100
val calleeExpression = expression.calleeExpression ? : return
104
101
105
- if (DEPRECATED_SPRING_PASSWORD_ENCODER_METHODS .any { it.matches(expression, bindingContext ) }) {
102
+ if (DEPRECATED_SPRING_PASSWORD_ENCODER_METHODS .any { it.matches(expression) }) {
106
103
kotlinFileContext.reportIssue(calleeExpression, MESSAGE )
107
- } else if (WEAK_METHOD_MATCHERS .any { it.matches(expression, bindingContext ) }) {
104
+ } else if (WEAK_METHOD_MATCHERS .any { it.matches(expression) }) {
108
105
val algorithm = ALGORITHM_BY_METHOD_NAME [calleeExpression.text]
109
- ? : algorithm(expression.valueArguments.firstOrNull()?.getArgumentExpression(), bindingContext )
106
+ ? : algorithm(expression.valueArguments.firstOrNull()?.getArgumentExpression())
110
107
algorithm?.let { kotlinFileContext.reportIssue(calleeExpression, MESSAGE ) }
111
108
}
112
109
}
@@ -133,7 +130,7 @@ enum class InsecureAlgorithm {
133
130
}
134
131
}
135
132
136
- private fun algorithm (invocationArgument : KtExpression ? , bindingContext : BindingContext ) =
137
- invocationArgument?.predictRuntimeStringValue(bindingContext )?.let { algorithmName ->
133
+ private fun algorithm (invocationArgument : KtExpression ? ) =
134
+ invocationArgument?.predictRuntimeStringValue()?.let { algorithmName ->
138
135
InsecureAlgorithm .values().firstOrNull { it.match(algorithmName) }
139
136
}
0 commit comments