|
8 | 8 | public class AndroidIntentRedirectionTest extends Activity { |
9 | 9 |
|
10 | 10 | public void onCreate(Bundle savedInstanceState) { |
11 | | - // @formatter:off |
12 | | - { |
13 | | - Intent intent = (Intent) getIntent().getParcelableExtra("forward_intent"); |
14 | | - startActivities(new Intent[] {intent}); // $ hasAndroidIntentRedirection |
15 | | - startActivities(new Intent[] {intent}, null); // $ hasAndroidIntentRedirection |
| 11 | + Intent intent = (Intent) getIntent().getParcelableExtra("forward_intent"); |
| 12 | + |
| 13 | + if (intent.getComponent().getPackageName().equals("something")) { |
| 14 | + startActivity(intent); // Safe - sanitized |
| 15 | + } else { |
16 | 16 | startActivity(intent); // $ hasAndroidIntentRedirection |
17 | | - startActivity(intent, null); // $ hasAndroidIntentRedirection |
18 | | - startActivityAsUser(intent, null); // $ hasAndroidIntentRedirection |
19 | | - startActivityAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
20 | | - startActivityAsCaller(intent, null, false, 0); // $ hasAndroidIntentRedirection |
21 | | - startActivityForResult(intent, 0); // $ hasAndroidIntentRedirection |
22 | | - startActivityForResult(intent, 0, null); // $ hasAndroidIntentRedirection |
23 | | - startActivityForResult(null, intent, 0, null); // $ hasAndroidIntentRedirection |
24 | | - startActivityForResultAsUser(intent, null, 0, null, null); // $ hasAndroidIntentRedirection |
25 | | - startActivityForResultAsUser(intent, 0, null, null); // $ hasAndroidIntentRedirection |
26 | | - startActivityForResultAsUser(intent, 0, null); // $ hasAndroidIntentRedirection |
27 | | - } |
28 | | - { |
29 | | - Intent intent = (Intent) getIntent().getParcelableExtra("forward_intent"); |
30 | | - startService(intent); // $ hasAndroidIntentRedirection |
31 | | - startServiceAsUser(intent, null); // $ hasAndroidIntentRedirection |
32 | 17 | } |
33 | | - { |
34 | | - Intent intent = (Intent) getIntent().getParcelableExtra("forward_intent"); |
35 | | - sendBroadcast(intent); // $ hasAndroidIntentRedirection |
36 | | - sendBroadcast(intent, null); // $ hasAndroidIntentRedirection |
37 | | - sendBroadcast(intent, null, null); // $ hasAndroidIntentRedirection |
38 | | - sendBroadcast(intent, null, 0); // $ hasAndroidIntentRedirection |
39 | | - sendBroadcastAsUser(intent, null); // $ hasAndroidIntentRedirection |
40 | | - sendBroadcastAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
41 | | - sendBroadcastAsUser(intent, null, null, null); // $ hasAndroidIntentRedirection |
42 | | - sendBroadcastAsUser(intent, null, null, 0); // $ hasAndroidIntentRedirection |
43 | | - sendBroadcastWithMultiplePermissions(intent, null); // $ hasAndroidIntentRedirection |
44 | | - sendStickyBroadcast(intent); // $ hasAndroidIntentRedirection |
45 | | - sendStickyBroadcastAsUser(intent, null); // $ hasAndroidIntentRedirection |
46 | | - sendStickyBroadcastAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
47 | | - sendStickyOrderedBroadcast(intent, null, null, 0, null, null); // $ hasAndroidIntentRedirection |
48 | | - sendStickyOrderedBroadcastAsUser(intent, null, null, null, 0, null, null); // $ hasAndroidIntentRedirection |
| 18 | + if (intent.getComponent().getClassName().equals("something")) { |
| 19 | + startActivity(intent); // Safe - sanitized |
| 20 | + } else { |
| 21 | + startActivity(intent); // $ hasAndroidIntentRedirection |
49 | 22 | } |
| 23 | + |
| 24 | + // @formatter:off |
| 25 | + startActivities(new Intent[] {intent}); // $ hasAndroidIntentRedirection |
| 26 | + startActivities(new Intent[] {intent}, null); // $ hasAndroidIntentRedirection |
| 27 | + startActivity(intent); // $ hasAndroidIntentRedirection |
| 28 | + startActivity(intent, null); // $ hasAndroidIntentRedirection |
| 29 | + startActivityAsUser(intent, null); // $ hasAndroidIntentRedirection |
| 30 | + startActivityAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
| 31 | + startActivityAsCaller(intent, null, false, 0); // $ hasAndroidIntentRedirection |
| 32 | + startActivityForResult(intent, 0); // $ hasAndroidIntentRedirection |
| 33 | + startActivityForResult(intent, 0, null); // $ hasAndroidIntentRedirection |
| 34 | + startActivityForResult(null, intent, 0, null); // $ hasAndroidIntentRedirection |
| 35 | + startActivityForResultAsUser(intent, null, 0, null, null); // $ hasAndroidIntentRedirection |
| 36 | + startActivityForResultAsUser(intent, 0, null, null); // $ hasAndroidIntentRedirection |
| 37 | + startActivityForResultAsUser(intent, 0, null); // $ hasAndroidIntentRedirection |
| 38 | + startService(intent); // $ hasAndroidIntentRedirection |
| 39 | + startServiceAsUser(intent, null); // $ hasAndroidIntentRedirection |
| 40 | + sendBroadcast(intent); // $ hasAndroidIntentRedirection |
| 41 | + sendBroadcast(intent, null); // $ hasAndroidIntentRedirection |
| 42 | + sendBroadcast(intent, null, null); // $ hasAndroidIntentRedirection |
| 43 | + sendBroadcast(intent, null, 0); // $ hasAndroidIntentRedirection |
| 44 | + sendBroadcastAsUser(intent, null); // $ hasAndroidIntentRedirection |
| 45 | + sendBroadcastAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
| 46 | + sendBroadcastAsUser(intent, null, null, null); // $ hasAndroidIntentRedirection |
| 47 | + sendBroadcastAsUser(intent, null, null, 0); // $ hasAndroidIntentRedirection |
| 48 | + sendBroadcastWithMultiplePermissions(intent, null); // $ hasAndroidIntentRedirection |
| 49 | + sendStickyBroadcast(intent); // $ hasAndroidIntentRedirection |
| 50 | + sendStickyBroadcastAsUser(intent, null); // $ hasAndroidIntentRedirection |
| 51 | + sendStickyBroadcastAsUser(intent, null, null); // $ hasAndroidIntentRedirection |
| 52 | + sendStickyOrderedBroadcast(intent, null, null, 0, null, null); // $ hasAndroidIntentRedirection |
| 53 | + sendStickyOrderedBroadcastAsUser(intent, null, null, null, 0, null, null); // $ hasAndroidIntentRedirection |
50 | 54 | // @formatter:on |
51 | 55 | } |
52 | 56 | } |
0 commit comments