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