@@ -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 { }
@@ -68,3 +69,47 @@ private class SqlDatabaseUpdateMethod extends DatabaseUpdateMethod {
6869 )
6970 }
7071}
72+
73+ module CallGraph {
74+ newtype TPathNode =
75+ TMethod ( Method m ) or
76+ TCall ( Call c )
77+
78+ class PathNode extends TPathNode {
79+ Method asMethod ( ) { this = TMethod ( result ) }
80+
81+ Call asCall ( ) { this = TCall ( result ) }
82+
83+ string toString ( ) {
84+ result = this .asMethod ( ) .toString ( )
85+ or
86+ result = this .asCall ( ) .toString ( )
87+ }
88+
89+ private PathNode getACallee ( ) {
90+ [ viableCallable ( this .asCall ( ) ) , this .asCall ( ) .getCallee ( ) ] = result .asMethod ( )
91+ }
92+
93+ PathNode getASuccessor ( ) {
94+ this .asMethod ( ) = result .asCall ( ) .getEnclosingCallable ( )
95+ or
96+ result = this .getACallee ( ) and
97+ (
98+ exists ( PathNode p |
99+ p = this .getACallee ( ) and
100+ p .asMethod ( ) instanceof DatabaseUpdateMethod
101+ )
102+ implies
103+ result .asMethod ( ) instanceof DatabaseUpdateMethod
104+ )
105+ }
106+
107+ Location getLocation ( ) {
108+ result = this .asMethod ( ) .getLocation ( )
109+ or
110+ result = this .asCall ( ) .getLocation ( )
111+ }
112+ }
113+
114+ query predicate edges ( PathNode pred , PathNode succ ) { pred .getASuccessor ( ) = succ }
115+ }
0 commit comments