@@ -42,7 +42,7 @@ class TypeApacheHttpRequestBuilder extends Class {
4242}
4343
4444/**
45- * The `request` parameter of an implementation of `org.apache.http.protocol.HttpRequestHandler.handle`
45+ * The `request` parameter of an implementation of `org.apache.http.protocol.HttpRequestHandler.handle`.
4646 */
4747class ApacheHttpRequestHandlerParameter extends Parameter {
4848 ApacheHttpRequestHandlerParameter ( ) {
@@ -55,6 +55,30 @@ class ApacheHttpRequestHandlerParameter extends Parameter {
5555 }
5656}
5757
58+ /**
59+ * A call that sets the entity of an instance of `org.apache.http.HttpResponse`.
60+ */
61+ class ApacheHttpResponseSetEntityCall extends MethodAccess {
62+ int arg ;
63+
64+ ApacheHttpResponseSetEntityCall ( ) {
65+ exists ( Method m | this .getMethod ( ) .overrides * ( m ) |
66+ m .getDeclaringType ( ) .hasQualifiedName ( "org.apache.http" , "HttpResponse" ) and
67+ m .hasName ( "setEntity" ) and
68+ arg = 0
69+ or
70+ m .getDeclaringType ( ) .hasQualifiedName ( "org.apache.http.util" , "EntityUtils" ) and
71+ m .hasName ( "updateEntity" ) and
72+ arg = 1
73+ )
74+ }
75+
76+ /**
77+ * Gets the entity that is set by this call.
78+ */
79+ Expr getEntity ( ) { result = this .getArgument ( arg ) }
80+ }
81+
5882private class ApacheHttpGetter extends TaintPreservingCallable {
5983 ApacheHttpGetter ( ) {
6084 exists ( string pkg , string ty , string mtd , Method m |
@@ -105,12 +129,69 @@ private class ApacheHttpGetter extends TaintPreservingCallable {
105129 override predicate returnsTaintFrom ( int arg ) { arg = - 1 }
106130}
107131
108- private class EntityUtilMethod extends TaintPreservingCallable {
109- EntityUtilMethod ( ) {
110- this .getDeclaringType ( ) .hasQualifiedName ( "org.apache.http.util" , "EntityUtils" ) and
111- this .isStatic ( ) and
112- this .hasName ( [ "toString" , "toByteArray" ] )
132+ private class UtilMethod extends TaintPreservingCallable {
133+ UtilMethod ( ) {
134+ exists ( string ty , string mtd |
135+ this .isStatic ( ) and
136+ this .getDeclaringType ( ) .hasQualifiedName ( "org.apache.http.util" , ty ) and
137+ this .hasName ( mtd )
138+ |
139+ ty = "EntityUtils" and
140+ mtd = [ "toString" , "toByteArray" ]
141+ or
142+ ty = "EncodingUtils" and
143+ mtd = [ "getAsciiBytes" , "getAsciiString" , "getBytes" , "getString" ]
144+ or
145+ ty = "Args" and
146+ mtd = [ "containsNoBlanks" , "notBlank" , "notEmpty" , "notNull" ]
147+ )
148+ }
149+
150+ override predicate returnsTaintFrom ( int arg ) { arg = 0 }
151+ }
152+
153+ private class EntitySetter extends TaintPreservingCallable {
154+ EntitySetter ( ) {
155+ this .getDeclaringType ( )
156+ .getASourceSupertype * ( )
157+ .hasQualifiedName ( "org.apache.http.entity" , "BasicHttpEntity" ) and
158+ this .hasName ( "setContent" )
159+ }
160+
161+ override predicate transfersTaint ( int src , int sink ) { src = 0 and sink = - 1 }
162+ }
163+
164+ private class EntityConsructor extends TaintPreservingCallable , Constructor {
165+ EntityConsructor ( ) {
166+ this .getDeclaringType ( )
167+ .hasQualifiedName ( "org.apache.http.entity" ,
168+ [
169+ "BufferedHttpEntity" , "ByteArrayEntity" , "HttpEntityWrapper" , "InputStreamEntity" ,
170+ "StringEntity"
171+ ] )
113172 }
114173
115174 override predicate returnsTaintFrom ( int arg ) { arg = 0 }
116175}
176+
177+ private class BufferMethod extends TaintPreservingCallable {
178+ BufferMethod ( ) {
179+ exists ( Method m |
180+ this .( Method ) .overrides * ( m ) and
181+ m .getDeclaringType ( )
182+ .hasQualifiedName ( "org.apache.http.util" , [ "ByteArrayBuffer" , "CharArrayBuffer" ] ) and
183+ m .hasName ( [
184+ "append" , "buffer" , "subSequence" , "substring" , "substringTrimmed" , "toByteAray" ,
185+ "toCharArray" , "toString"
186+ ] )
187+ )
188+ }
189+
190+ override predicate returnsTaintFrom ( int arg ) { arg = - 1 }
191+
192+ override predicate transfersTaint ( int src , int sink ) {
193+ this .hasName ( "append" ) and
194+ src = 0 and
195+ sink = - 1
196+ }
197+ }
0 commit comments