@@ -6,6 +6,7 @@ private import semmle.code.java.frameworks.MyBatis
66private import semmle.code.java.frameworks.Jdbc
77private import semmle.code.java.dataflow.DataFlow
88private import semmle.code.java.dataflow.ExternalFlow
9+ private import semmle.code.java.dispatch.VirtualDispatch
910
1011/** A method that is not protected from CSRF by default. */
1112abstract class CsrfUnprotectedMethod extends Method { }
@@ -71,3 +72,47 @@ private class SqlDatabaseUpdateMethod extends DatabaseUpdateMethod {
7172 )
7273 }
7374}
75+
76+ module CallGraph {
77+ newtype TPathNode =
78+ TMethod ( Method m ) or
79+ TCall ( Call c )
80+
81+ class PathNode extends TPathNode {
82+ Method asMethod ( ) { this = TMethod ( result ) }
83+
84+ Call asCall ( ) { this = TCall ( result ) }
85+
86+ string toString ( ) {
87+ result = this .asMethod ( ) .toString ( )
88+ or
89+ result = this .asCall ( ) .toString ( )
90+ }
91+
92+ private PathNode getACallee ( ) {
93+ [ viableCallable ( this .asCall ( ) ) , this .asCall ( ) .getCallee ( ) ] = result .asMethod ( )
94+ }
95+
96+ PathNode getASuccessor ( ) {
97+ this .asMethod ( ) = result .asCall ( ) .getEnclosingCallable ( )
98+ or
99+ result = this .getACallee ( ) and
100+ (
101+ exists ( PathNode p |
102+ p = this .getACallee ( ) and
103+ p .asMethod ( ) instanceof DatabaseUpdateMethod
104+ )
105+ implies
106+ result .asMethod ( ) instanceof DatabaseUpdateMethod
107+ )
108+ }
109+
110+ Location getLocation ( ) {
111+ result = this .asMethod ( ) .getLocation ( )
112+ or
113+ result = this .asCall ( ) .getLocation ( )
114+ }
115+ }
116+
117+ query predicate edges ( PathNode pred , PathNode succ ) { pred .getASuccessor ( ) = succ }
118+ }
0 commit comments