Skip to content

Commit decba39

Browse files
Jami CogswellJami Cogswell
authored andcommitted
add service flow sources
1 parent 3bd456e commit decba39

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

java/ql/lib/semmle/code/java/dataflow/FlowSources.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ class AndroidIntentInput extends DataFlow::Node {
250250
this.asParameter() = m.getParameter(1) and
251251
receiverType = m.getDeclaringType()
252252
)
253+
or
254+
exists(Method m, AndroidServiceIntentMethod sI |
255+
m.overrides*(sI) and
256+
this.asParameter() = m.getParameter(0) and
257+
receiverType = m.getDeclaringType()
258+
)
253259
}
254260
}
255261

java/ql/lib/semmle/code/java/frameworks/android/Intent.qll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class TypeActivity extends Class {
2222
TypeActivity() { this.hasQualifiedName("android.app", "Activity") }
2323
}
2424

25+
/**
26+
* The class `android.app.Service`.
27+
*/
28+
class TypeService extends Class {
29+
TypeService() { this.hasQualifiedName("android.app", "Service") }
30+
}
31+
2532
/**
2633
* The class `android.content.Context`.
2734
*/
@@ -57,6 +64,22 @@ class AndroidReceiveIntentMethod extends Method {
5764
}
5865
}
5966

67+
/**
68+
* A method of type Service that receives an Intent.
69+
* Namely, `Service.onStart`, `onStartCommand`, `onBind`,
70+
* `onRebind`, `onUnbind`, or `onTaskRemoved`
71+
*/
72+
class AndroidServiceIntentMethod extends Method {
73+
AndroidServiceIntentMethod() {
74+
(
75+
this.getName().matches("onStart%") or
76+
this.getName().matches("on%ind") or
77+
this.hasName("onTaskRemoved")
78+
) and
79+
this.getDeclaringType() instanceof TypeService
80+
}
81+
}
82+
6083
/**
6184
* The method `Context.startActivity` or `startActivities`.
6285
*/

0 commit comments

Comments
 (0)