@@ -55,85 +55,20 @@ string getASystemActionName() {
55
55
}
56
56
57
57
/** An expression or XML attribute that contains the name of a system intent action. */
58
- class SystemActionName extends Top {
58
+ class SystemActionName extends AndroidActionXmlElement {
59
59
string name ;
60
60
61
61
SystemActionName ( ) {
62
62
name = getASystemActionName ( ) and
63
- (
64
- this .( CompileTimeConstantExpr ) .getStringValue ( ) = "android.intent.action." + name
65
- or
66
- this .( FieldRead ) .getField ( ) .hasQualifiedName ( "android.content" , "Intent" , "ACTION_" + name )
67
- or
68
- this .( AndroidActionXmlElement ) .getActionName ( ) = "android.intent.action." + name
69
- )
63
+ this .getActionName ( ) = "android.intent.action." + name
70
64
}
71
65
72
66
/** Gets the name of the system intent that this expression or attribute represents. */
73
- string getName ( ) { result = name }
74
-
75
- override string toString ( ) { result = [ this .( Expr ) .toString ( ) , this .( XMLAttribute ) .toString ( ) ] }
76
- }
77
-
78
- /** A call to `Context.registerReceiver` */
79
- private class RegisterReceiverCall extends MethodAccess {
80
- RegisterReceiverCall ( ) {
81
- this .getMethod ( )
82
- .getASourceOverriddenMethod * ( )
83
- .hasQualifiedName ( "android.content" , "Context" , "registerReceiver" )
84
- }
85
-
86
- /** Gets the `BroadcastReceiver` argument to this call. */
87
- Expr getReceiverArgument ( ) { result = this .getArgument ( 0 ) }
88
-
89
- /** Gets the `IntentFilter` argument to this call. */
90
- Expr getFilterArgument ( ) { result = this .getArgument ( 1 ) }
91
- }
92
-
93
- /** A configuration to detect uses of `registerReceiver` with system intent actions. */
94
- private class RegisterSystemActionConfig extends DataFlow:: Configuration {
95
- RegisterSystemActionConfig ( ) { this = "RegisterSystemActionConfig" }
96
-
97
- override predicate isSource ( DataFlow:: Node node ) { node .asExpr ( ) instanceof SystemActionName }
98
-
99
- override predicate isSink ( DataFlow:: Node node ) {
100
- exists ( RegisterReceiverCall ma | node .asExpr ( ) = ma .getFilterArgument ( ) )
101
- }
102
-
103
- override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
104
- exists ( ConstructorCall cc |
105
- cc .getConstructedType ( ) .hasQualifiedName ( "android.content" , "IntentFilter" ) and
106
- node1 .asExpr ( ) = cc .getArgument ( 0 ) and
107
- node2 .asExpr ( ) = cc
108
- )
109
- or
110
- exists ( MethodAccess ma |
111
- ma .getMethod ( ) .hasQualifiedName ( "android.content" , "IntentFilter" , "create" ) and
112
- node1 .asExpr ( ) = ma .getArgument ( 0 ) and
113
- node2 .asExpr ( ) = ma
114
- )
115
- or
116
- exists ( MethodAccess ma |
117
- ma .getMethod ( ) .hasQualifiedName ( "android.content" , "IntentFilter" , "addAction" ) and
118
- node1 .asExpr ( ) = ma .getArgument ( 0 ) and
119
- node2 .( DataFlow:: PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = ma .getQualifier ( )
120
- )
121
- }
122
- }
123
-
124
- /** Holds if `rrc` registers a receiver `orm` to receive the system action `sa` that doesn't verify the intents it receives. */
125
- private predicate registeredUnverifiedSystemReceiver (
126
- RegisterReceiverCall rrc , UnverifiedOnReceiveMethod orm , SystemActionName sa
127
- ) {
128
- exists ( RegisterSystemActionConfig conf , ConstructorCall cc |
129
- conf .hasFlow ( DataFlow:: exprNode ( sa ) , DataFlow:: exprNode ( rrc .getFilterArgument ( ) ) ) and
130
- cc .getConstructedType ( ) = orm .getDeclaringType ( ) and
131
- DataFlow:: localExprFlow ( cc , rrc .getReceiverArgument ( ) )
132
- )
67
+ string getSystemActionName ( ) { result = name }
133
68
}
134
69
135
70
/** Holds if the XML element `rec` declares a receiver `orm` to receive the system action named `sa` that doesn't verify intents it receives. */
136
- private predicate xmlUnverifiedSystemReceiver (
71
+ predicate unverifiedSystemReceiver (
137
72
AndroidReceiverXmlElement rec , UnverifiedOnReceiveMethod orm , SystemActionName sa
138
73
) {
139
74
exists ( Class ormty |
@@ -142,9 +77,3 @@ private predicate xmlUnverifiedSystemReceiver(
142
77
rec .getAnIntentFilterElement ( ) .getAnActionElement ( ) = sa
143
78
)
144
79
}
145
-
146
- /** Holds if `reg` registers (either explicitly or through XML) a receiver `orm` to receive the system action named `sa` that doesn't verify the intents it receives. */
147
- predicate unverifiedSystemReceiver ( Top reg , Method orm , SystemActionName sa ) {
148
- registeredUnverifiedSystemReceiver ( reg , orm , sa ) or
149
- xmlUnverifiedSystemReceiver ( reg , orm , sa )
150
- }
0 commit comments