Skip to content
Prev Previous commit
Next Next commit
Optimize the query
  • Loading branch information
luchua-bc committed Jan 6, 2021
commit 5690bf49f46f9cadfb99cb824338b1562a9e0831
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private predicate sharedPreferencesStore(DataFlow::Node sharedPrefs, Expr store)
}

/** Flow from `SharedPreferences` to either a setter or a store method. */
class SharedPreferencesFlowConfig extends TaintTracking::Configuration {
class SharedPreferencesFlowConfig extends DataFlow::Configuration {
SharedPreferencesFlowConfig() {
this = "CleartextStorageSharedPrefs::SharedPreferencesFlowConfig"
}
Expand Down Expand Up @@ -65,7 +65,7 @@ class EncryptedValueFlowConfig extends DataFlow5::Configuration {
EncryptedValueFlowConfig() { this = "CleartextStorageSharedPrefs::EncryptedValueFlowConfig" }

override predicate isSource(DataFlow5::Node src) {
exists(EncryptedSensitiveMethodAccess ema | src.asExpr() = ema.getAnArgument())
exists(EncryptedSensitiveMethodAccess ema | src.asExpr() = ema)
}

override predicate isSink(DataFlow5::Node sink) {
Expand All @@ -74,13 +74,6 @@ class EncryptedValueFlowConfig extends DataFlow5::Configuration {
sink.asExpr() = ma.getArgument(1)
)
}

override predicate isAdditionalFlowStep(DataFlow5::Node n1, DataFlow5::Node n2) {
exists(EncryptedSensitiveMethodAccess ema |
n1.asExpr() = ema.getAnArgument() and
n2.asExpr() = ema
)
}
}

/** Flow from the create method of `androidx.security.crypto.EncryptedSharedPreferences` to its instance. */
Expand Down Expand Up @@ -109,7 +102,7 @@ class SharedPreferencesEditor extends MethodAccess {
)
}

/** Gets an input, for example `input` in `editor.putString("password", password);`. */
/** Gets an input, for example `password` in `editor.putString("password", password);`. */
Expr getAnInput() {
exists(SharedPreferencesFlowConfig conf, DataFlow::Node n |
sharedPreferencesInput(n, result) and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import semmle.code.java.Type
/** Provides classes related to `android.content.SharedPreferences`. */

import java
Comment thread
luchua-bc marked this conversation as resolved.

/** Definitions related to `android.content.SharedPreferences`. */
module SharedPreferences {
Expand Down