Skip to content

Java: Add new AlarmManager sinks to Use of implicit PendingIntents #10251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ private class PendingIntentSentSinkModels extends SinkModelCsv {
"android.app;PendingIntent;false;send;(Context,int,Intent,OnFinished,Handler,String);;Argument[2];pending-intent-sent;manual",
"android.app;PendingIntent;false;send;(Context,int,Intent,OnFinished,Handler);;Argument[2];pending-intent-sent;manual",
"android.app;PendingIntent;false;send;(Context,int,Intent);;Argument[2];pending-intent-sent;manual",
"android.app;Activity;true;setResult;(int,Intent);;Argument[1];pending-intent-sent;manual"
"android.app;Activity;true;setResult;(int,Intent);;Argument[1];pending-intent-sent;manual",
"android.app;AlarmManager;true;set;(int,long,PendingIntent);;Argument[2];pending-intent-sent;manual",
"android.app;AlarmManager;true;setAlarmClock;;;Argument[1];pending-intent-sent;manual",
"android.app;AlarmManager;true;setAndAllowWhileIdle;;;Argument[2];pending-intent-sent;manual",
"android.app;AlarmManager;true;setExact;(int,long,PendingIntent);;Argument[2];pending-intent-sent;manual",
"android.app;AlarmManager;true;setExactAndAllowWhileIdle;;;Argument[2];pending-intent-sent;manual",
"android.app;AlarmManager;true;setInexactRepeating;;;Argument[3];pending-intent-sent;manual",
"android.app;AlarmManager;true;setRepeating;;;Argument[3];pending-intent-sent;manual",
"android.app;AlarmManager;true;setWindow;(int,long,long,PendingIntent);;Argument[3];pending-intent-sent;manual",
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added new sinks related to Android's `AlarmManager` to the query `java/android/implicit-pendingintents`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.FileNotFoundException;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
Expand Down Expand Up @@ -217,6 +218,28 @@ public static void testPendingIntentInANotification(Context ctx)

}

public static void testPendingIntentInAnAlarm(Context ctx) {
AlarmManager aManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
{
Intent baseIntent = new Intent();
PendingIntent pi = PendingIntent.getActivity(ctx, 0, baseIntent, 0);
aManager.set(0, 0, pi); // $hasImplicitPendingIntent
aManager.setAlarmClock(null, pi); // $hasImplicitPendingIntent
aManager.setAndAllowWhileIdle(0, 0, pi); // $hasImplicitPendingIntent
aManager.setExact(0, 0, pi); // $hasImplicitPendingIntent
aManager.setExactAndAllowWhileIdle(0, 0, pi); // $hasImplicitPendingIntent
aManager.setInexactRepeating(0, 0, 0, pi); // $hasImplicitPendingIntent
aManager.setRepeating(0, 0, 0, pi); // $hasImplicitPendingIntent
aManager.setWindow(0, 0, 0, pi); // $hasImplicitPendingIntent
}
{
Intent baseIntent = new Intent();
PendingIntent pi =
PendingIntent.getActivity(ctx, 0, baseIntent, PendingIntent.FLAG_IMMUTABLE); // Sanitizer
aManager.set(0, 0, pi); // Safe
}
}

static class TestActivity extends Activity {
@Override
public void onCreate(Bundle bundle) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.