1
1
/** Provides definitions for working with uses of Android external storage */
2
2
3
3
import java
4
- import semmle.code.java.dataflow.DataFlow
4
+ private import semmle.code.java.dataflow.DataFlow
5
5
private import semmle.code.java.dataflow.ExternalFlow
6
6
7
7
private class ExternalStorageDirSourceModel extends SourceModelCsv {
@@ -10,11 +10,11 @@ private class ExternalStorageDirSourceModel extends SourceModelCsv {
10
10
[
11
11
//"package;type;overrides;name;signature;ext;spec;kind"
12
12
"android.content;Context;true;getExternalFilesDir;(String);;ReturnValue;android-external-storage-dir" ,
13
- "android.content;Context;true;getExternalFilesDirs;(String);;ReturnValue.ArrayElement ;android-external-storage-dir" ,
14
- "android.content;Context;true;getExternalCachesDir;(String );;ReturnValue;android-external-storage-dir" ,
15
- "android.content;Context;true;getExternalCachesDirs;(String );;ReturnValue.ArrayElement ;android-external-storage-dir" ,
16
- "android.os;Environment;false;getExternalStorageDirectory;(String );;ReturnValue.ArrayElement ;android-external-storage-dir" ,
17
- "android.os;Environment;false;getExternalStoragePublicDirectory;(String);;ReturnValue.ArrayElement ;android-external-storage-dir" ,
13
+ "android.content;Context;true;getExternalFilesDirs;(String);;ReturnValue;android-external-storage-dir" ,
14
+ "android.content;Context;true;getExternalCacheDir;( );;ReturnValue;android-external-storage-dir" ,
15
+ "android.content;Context;true;getExternalCacheDirs;( );;ReturnValue;android-external-storage-dir" ,
16
+ "android.os;Environment;false;getExternalStorageDirectory;();;ReturnValue;android-external-storage-dir" ,
17
+ "android.os;Environment;false;getExternalStoragePublicDirectory;(String);;ReturnValue;android-external-storage-dir" ,
18
18
]
19
19
}
20
20
}
@@ -23,9 +23,13 @@ private predicate externalStorageFlowStep(DataFlow::Node node1, DataFlow::Node n
23
23
DataFlow:: localFlowStep ( node1 , node2 )
24
24
or
25
25
exists ( ConstructorCall c | c .getConstructedType ( ) instanceof TypeFile |
26
- node1 .asExpr ( ) = c .getArgument ( 1 ) and
26
+ node1 .asExpr ( ) = c .getArgument ( 0 ) and
27
27
node2 .asExpr ( ) = c
28
28
)
29
+ or
30
+ node2 .asExpr ( ) .( ArrayAccess ) .getArray ( ) = node1 .asExpr ( )
31
+ or
32
+ node2 .asExpr ( ) .( FieldRead ) .getField ( ) .getInitializer ( ) = node1 .asExpr ( )
29
33
}
30
34
31
35
private predicate externalStorageFlow ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
0 commit comments