rspec/rules/S6301/kotlin/rule.adoc

47 lines
1.0 KiB
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/[SQLCipher]
[source,kotlin]
----
val key = "gb09ym9ydoolp3w886d0tciczj6ve9kszqd65u7d126040gwy86xqimjpuuc788g"
val db = SQLiteDatabase.openOrCreateDatabase("test.db", key, null) // Noncompliant
----
https://github.com/realm/realm-kotlin/[Realm]
[source,kotlin]
----
val key = "gb09ym9ydoolp3w886d0tciczj6ve9kszqd65u7d126040gwy86xqimjpuuc788g"
val config = RealmConfiguration.Builder()
.encryptionKey(key.toByteArray()) // Noncompliant
.build()
val realm = Realm.getInstance(config)
----
=== Compliant solution
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/[SQLCipher]
[source,kotlin]
----
val db = SQLiteDatabase.openOrCreateDatabase("test.db", getKey(), null)
----
https://github.com/realm/realm-kotlin/[Realm]
[source,kotlin]
----
val config = RealmConfiguration.Builder()
.encryptionKey(getKey())
.build()
val realm = Realm.getInstance(config)
----
include::../see.adoc[]