Skip to content

Commit 5690bf4

Browse files
committed
Optimize the query
1 parent ad0ac5b commit 5690bf4

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

java/ql/src/experimental/Security/CWE/CWE-312/CleartextStorageSharedPrefs.ql

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private predicate sharedPreferencesStore(DataFlow::Node sharedPrefs, Expr store)
3535
}
3636

3737
/** Flow from `SharedPreferences` to either a setter or a store method. */
38-
class SharedPreferencesFlowConfig extends TaintTracking::Configuration {
38+
class SharedPreferencesFlowConfig extends DataFlow::Configuration {
3939
SharedPreferencesFlowConfig() {
4040
this = "CleartextStorageSharedPrefs::SharedPreferencesFlowConfig"
4141
}
@@ -65,7 +65,7 @@ class EncryptedValueFlowConfig extends DataFlow5::Configuration {
6565
EncryptedValueFlowConfig() { this = "CleartextStorageSharedPrefs::EncryptedValueFlowConfig" }
6666

6767
override predicate isSource(DataFlow5::Node src) {
68-
exists(EncryptedSensitiveMethodAccess ema | src.asExpr() = ema.getAnArgument())
68+
exists(EncryptedSensitiveMethodAccess ema | src.asExpr() = ema)
6969
}
7070

7171
override predicate isSink(DataFlow5::Node sink) {
@@ -74,13 +74,6 @@ class EncryptedValueFlowConfig extends DataFlow5::Configuration {
7474
sink.asExpr() = ma.getArgument(1)
7575
)
7676
}
77-
78-
override predicate isAdditionalFlowStep(DataFlow5::Node n1, DataFlow5::Node n2) {
79-
exists(EncryptedSensitiveMethodAccess ema |
80-
n1.asExpr() = ema.getAnArgument() and
81-
n2.asExpr() = ema
82-
)
83-
}
8477
}
8578

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

112-
/** Gets an input, for example `input` in `editor.putString("password", password);`. */
105+
/** Gets an input, for example `password` in `editor.putString("password", password);`. */
113106
Expr getAnInput() {
114107
exists(SharedPreferencesFlowConfig conf, DataFlow::Node n |
115108
sharedPreferencesInput(n, result) and

java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import semmle.code.java.Type
1+
/** Provides classes related to `android.content.SharedPreferences`. */
2+
3+
import java
24

35
/** Definitions related to `android.content.SharedPreferences`. */
46
module SharedPreferences {

0 commit comments

Comments
 (0)