Skip to content

Commit e6f4a67

Browse files
leveretkaGodin
authored andcommitted
SONARKT-400 Migrate StrongCipherAlgorithmCheck to kotlin-analysis-api
1 parent 2269c53 commit e6f4a67

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/StrongCipherAlgorithmCheck.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,14 @@ private const val msg = "Use a strong cipher algorithm."
3939
private val cipherGetInstanceMatcher = FunMatcher(qualifier = "javax.crypto.Cipher", name = "getInstance")
4040
private val nullCipherConstructorMatcher = ConstructorMatcher("javax.crypto.NullCipher")
4141

42-
@org.sonarsource.kotlin.api.frontend.K1only
4342
@Rule(key = "S5547")
4443
class StrongCipherAlgorithmCheck : AbstractCheck() {
4544
override fun visitCallExpression(callExpr: KtCallExpression, kotlinFileContext: KotlinFileContext) {
46-
val (_, _, bindingContext) = kotlinFileContext
47-
if (nullCipherConstructorMatcher.matches(callExpr, bindingContext)) {
45+
if (nullCipherConstructorMatcher.matches(callExpr)) {
4846
kotlinFileContext.reportIssue(callExpr, msg)
49-
} else if (cipherGetInstanceMatcher.matches(callExpr, bindingContext)) {
47+
} else if (cipherGetInstanceMatcher.matches(callExpr)) {
5048
callExpr.valueArguments.firstOrNull()?.let { arg ->
51-
arg.getArgumentExpression()?.predictRuntimeStringValue(bindingContext)?.uppercase()?.let { candidateString ->
49+
arg.getArgumentExpression()?.predictRuntimeStringValue()?.uppercase()?.let { candidateString ->
5250
if (weakCiphers.any { cipher -> candidateString == cipher || candidateString.startsWith("$cipher/") }) {
5351
kotlinFileContext.reportIssue(arg, msg)
5452
}

0 commit comments

Comments
 (0)