- Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathProtobuf.qll
60 lines (55 loc) · 2 KB
/
Protobuf.qll
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
import semmle.code.java.dataflow.FlowSources
module Protobuf {
classProtoToCoreTaintStepextends TaintTracking::AdditionalTaintStep{
overridepredicatestep(DataFlow::Noden1, DataFlow::Noden2){
exists(MethodCallma|
ma.getMethod().getName().matches("toCore%")and
n2.asExpr()=maand
n1.asExpr()=ma.getArgument(0)
)
}
}
classByteStringThisReturnTaintStepextends TaintTracking::AdditionalTaintStep{
overridepredicatestep(DataFlow::Noden1, DataFlow::Noden2){
exists(MethodCallma|
//ma.getMethod().getName().matches(["toByteArray", "toString", "toStringUtf8", "substring", "concat", "asReadOnlyByteBuffer", "asReadOnlyByteBufferList"]) and
ma.getMethod().getName().matches("toByteArray")and
ma.getMethod()
.getDeclaringType()
.getASourceSupertype*()
.(RefType)
.hasQualifiedName("com.google.protobuf","ByteString")and
n1.asExpr()=ma.getQualifier()and
n2.asExpr()=ma
)
}
}
classByteStringArgReturnTaintStepextends TaintTracking::AdditionalTaintStep{
overridepredicatestep(DataFlow::Noden1, DataFlow::Noden2){
exists(MethodCallma|
ma.getMethod().getName().matches(["readFrom","copyFrom","concat"])and
ma.getMethod()
.getDeclaringType()
.getASourceSupertype*()
.(RefType)
.hasQualifiedName("com.google.protobuf","ByteString")and
n1.asExpr()=ma.getArgument(0)and
n2.asExpr()=ma
)
}
}
classRemoteSourceextendsRemoteFlowSource{
RemoteSource(){
exists(MethodCallma,Methodm|
ma.getMethod()=mand
m.getName().matches("get%")and
m.getDeclaringType()
.getASourceSupertype*()
.(RefType)
.hasQualifiedName("com.google.protobuf","GeneratedMessageV3")and
this.asExpr()=ma
)
}
overridestringgetSourceType(){result="Protobuf Source"}
}
}