Skip to content

Commit 72d3b0a

Browse files
authored
Create 3.ql
1 parent 2eb3707 commit 72d3b0a

File tree

1 file changed

+46
-0
lines changed
  • .github/workflows

1 file changed

+46
-0
lines changed

.github/workflows/3.ql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import java
6+
import semmle.code.java.dataflow.FlowSources
7+
import semmle.code.java.dataflow.DataFlow
8+
class Getter extends Method {
9+
Getter() { this.getName().regexpMatch("get.+") }
10+
}
11+
12+
class Source extends Callable {
13+
Source() {
14+
this instanceof Getter and getDeclaringType().getASupertype*() instanceof TypeSerializable
15+
}
16+
}
17+
18+
class GetConnectionMethod extends Method {
19+
GetConnectionMethod() {
20+
this.hasName("getConnection") and
21+
this.getDeclaringType().hasQualifiedName("java.sql", "DriverManager")
22+
}
23+
}
24+
25+
class DangerousMethod extends Callable {
26+
DangerousMethod() { this instanceof GetConnectionMethod }
27+
}
28+
29+
class CallsDangerousMethod extends Callable {
30+
CallsDangerousMethod() {
31+
exists(Callable a |
32+
this.polyCalls(a) and
33+
a instanceof DangerousMethod
34+
)
35+
}
36+
}
37+
38+
query predicate edges(Callable a, Callable b) {
39+
a.polyCalls(b)
40+
}
41+
42+
from Source source, CallsDangerousMethod sink
43+
where edges+(source, sink)
44+
select source, source, sink, "$@ $@ to $@ $@", source.getDeclaringType(),
45+
source.getDeclaringType().getName(), source, source.getName(), sink.getDeclaringType(),
46+
sink.getDeclaringType().getName(), sink, sink.getName()

0 commit comments

Comments
 (0)