1+ import org .apache .hc .core5 .http .*;
2+ import org .apache .hc .core5 .http .protocol .HttpContext ;
3+ import org .apache .hc .core5 .http .io .HttpRequestHandler ;
4+ import org .apache .hc .core5 .http .io .HttpServerRequestHandler ;
5+ import org .apache .hc .core5 .http .message .*;
6+ import org .apache .hc .core5 .http .io .entity .*;
7+ import org .apache .hc .core5 .util .*;
8+ import java .io .IOException ;
9+
10+ class B {
11+ static Object taint () { return null ; }
12+
13+ static void sink (Object o ) { }
14+
15+ class Test1 implements HttpRequestHandler {
16+ public void handle (ClassicHttpRequest req , ClassicHttpResponse res , HttpContext ctx ) throws IOException , ParseException {
17+ B .sink (req .getAuthority ().getHostName ()); //$hasTaintFlow=y
18+ B .sink (req .getAuthority ().toString ()); //$hasTaintFlow=y
19+ B .sink (req .getMethod ()); //$hasTaintFlow=y
20+ B .sink (req .getPath ()); //$hasTaintFlow=y
21+ B .sink (req .getScheme ());
22+ B .sink (req .getRequestUri ()); //$hasTaintFlow=y
23+ RequestLine line = new RequestLine (req );
24+ B .sink (line .getUri ()); //$hasTaintFlow=y
25+ B .sink (line .getMethod ()); //$hasTaintFlow=y
26+ B .sink (req .getHeaders ()); //$hasTaintFlow=y
27+ B .sink (req .headerIterator ()); //$hasTaintFlow=y
28+ Header h = req .getHeaders ("abc" )[3 ];
29+ B .sink (h .getName ()); //$hasTaintFlow=y
30+ B .sink (h .getValue ()); //$hasTaintFlow=y
31+ B .sink (req .getFirstHeader ("abc" )); //$hasTaintFlow=y
32+ B .sink (req .getLastHeader ("abc" )); //$hasTaintFlow=y
33+ HttpEntity ent = req .getEntity ();
34+ B .sink (ent .getContent ()); //$hasTaintFlow=y
35+ B .sink (ent .getContentEncoding ()); //$hasTaintFlow=y
36+ B .sink (ent .getContentType ()); //$hasTaintFlow=y
37+ B .sink (ent .getTrailerNames ()); //$hasTaintFlow=y
38+ B .sink (ent .getTrailers ().get ()); //$hasTaintFlow=y
39+ B .sink (EntityUtils .toString (ent )); //$hasTaintFlow=y
40+ B .sink (EntityUtils .toByteArray (ent )); //$hasTaintFlow=y
41+ B .sink (EntityUtils .parse (ent )); //$hasTaintFlow=y
42+ res .setEntity (new StringEntity ("<a href='" + req .getRequestUri () + "'>a</a>" )); //$hasTaintFlow=y
43+ res .setEntity (new ByteArrayEntity (EntityUtils .toByteArray (ent ), ContentType .TEXT_HTML )); //$hasTaintFlow=y
44+ res .setEntity (HttpEntities .create ("<a href='" + req .getRequestUri () + "'>a</a>" )); //$hasTaintFlow=y
45+ res .setHeader ("Location" , req .getRequestUri ()); //$hasTaintFlow=y
46+ res .setHeader (new BasicHeader ("Location" , req .getRequestUri ())); //$hasTaintFlow=y
47+ }
48+ }
49+
50+ void test2 () {
51+ ByteArrayBuffer bbuf = new ByteArrayBuffer (42 );
52+ bbuf .append ((byte []) taint (), 0 , 3 );
53+ sink (bbuf .array ()); //$hasTaintFlow=y
54+ sink (bbuf .toByteArray ()); //$hasTaintFlow=y
55+ sink (bbuf .toString ());
56+
57+ CharArrayBuffer cbuf = new CharArrayBuffer (42 );
58+ cbuf .append (bbuf .toByteArray (), 0 , 3 );
59+ sink (cbuf .toCharArray ()); //$hasTaintFlow=y
60+ sink (cbuf .toString ()); //$hasTaintFlow=y
61+ sink (cbuf .subSequence (0 , 3 )); //$hasTaintFlow=y
62+ sink (cbuf .substring (0 , 3 )); //$hasTaintFlow=y
63+ sink (cbuf .substringTrimmed (0 , 3 )); //$hasTaintFlow=y
64+
65+ sink (Args .notNull (taint (), "x" )); //$hasTaintFlow=y
66+ sink (Args .notEmpty ((String ) taint (), "x" )); //$hasTaintFlow=y
67+ sink (Args .notBlank ((String ) taint (), "x" )); //$hasTaintFlow=y
68+ sink (Args .notNull ("x" , (String ) taint ()));
69+ }
70+
71+ class Test3 implements HttpServerRequestHandler {
72+ public void handle (ClassicHttpRequest req , HttpServerRequestHandler .ResponseTrigger restr , HttpContext ctx ) throws HttpException , IOException {
73+ B .sink (req .getEntity ()); //$hasTaintFlow=y
74+ }
75+ }
76+ }
0 commit comments