File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
lib/semmle/code/java/frameworks/android
test/library-tests/frameworks/android/intent Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,25 @@ class GrantWriteUriPermissionFlag extends GrantUriPermissionFlag {
176
176
GrantWriteUriPermissionFlag ( ) { this .hasName ( "FLAG_GRANT_WRITE_URI_PERMISSION" ) }
177
177
}
178
178
179
+ /**
180
+ * A value-preserving step from the Intent argument of a `startActivity` call to
181
+ * a `getIntent` call in the Activity the Intent pointed to in its constructor.
182
+ */
183
+ private class StartActivityIntentStep extends AdditionalValueStep {
184
+ override predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
185
+ exists ( MethodAccess startActivity , MethodAccess getIntent , ClassInstanceExpr newIntent |
186
+ startActivity .getMethod ( ) .overrides * ( any ( ContextStartActivityMethod m ) ) and
187
+ getIntent .getMethod ( ) .overrides * ( any ( AndroidGetIntentMethod m ) ) and
188
+ newIntent .getConstructedType ( ) instanceof TypeIntent and
189
+ DataFlow:: localExprFlow ( newIntent , startActivity .getArgument ( 0 ) ) and
190
+ newIntent .getArgument ( 1 ) .getType ( ) .( ParameterizedType ) .getATypeArgument ( ) =
191
+ getIntent .getReceiverType ( ) and
192
+ n1 .asExpr ( ) = startActivity .getArgument ( 0 ) and
193
+ n2 .asExpr ( ) = getIntent
194
+ )
195
+ }
196
+ }
197
+
179
198
private class IntentBundleFlowSteps extends SummaryModelCsv {
180
199
override predicate row ( string row ) {
181
200
row =
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <manifest
3
+ xmlns : android =" http://schemas.android.com/apk/res/android"
4
+ android : versionCode =" 1"
5
+ android : versionName =" 1.0"
6
+ package =" com.example.app" >
7
+
8
+ <application
9
+ android : allowBackup =" true"
10
+ android : icon =" @mipmap/ic_launcher"
11
+ android : roundIcon =" @mipmap/ic_launcher_round"
12
+ android : label =" @string/app_name"
13
+ android : supportsRtl =" true"
14
+ android : theme =" @style/AppTheme" >
15
+
16
+ <activity
17
+ android : name =" .TestStartActivityToGetIntent.SomeActivity"
18
+ android : exported =" false" >
19
+ </activity >
20
+
21
+ </application >
22
+ </manifest >
Original file line number Diff line number Diff line change
1
+ import android .app .Activity ;
2
+ import android .content .Context ;
3
+ import android .content .Intent ;
4
+
5
+ public class TestStartActivityToGetIntent {
6
+
7
+ static Object source () {
8
+ return null ;
9
+ }
10
+
11
+ static void sink (Object sink ) {}
12
+
13
+ public void test (Context ctx ) {
14
+ Intent intent = new Intent (null , SomeActivity .class );
15
+ intent .putExtra ("data" , (String ) source ());
16
+ ctx .startActivity (intent );
17
+ }
18
+
19
+ static class SomeActivity extends Activity {
20
+
21
+ public void test () {
22
+ sink (getIntent ().getStringExtra ("data" )); // $ hasValueFlow
23
+ }
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments