44 */
55
66private import binary
7- import semmle.code.binary.cil.CilCallable
7+ private import semmle.code.binary.ast.ir.IR
88
99/**
1010 * Holds if any call identified by `(namespace, className, methodName)` should be flagged
@@ -19,21 +19,21 @@ extensible predicate vulnerableCallModel(
1919/**
2020 * A method call that has been marked as vulnerable by a model.
2121 */
22- class VulnerableMethodCall extends CilCallExt {
22+ class VulnerableMethodCall extends CallInstruction {
2323 string vulnerabilityId ;
2424
2525 VulnerableMethodCall ( ) {
2626 exists ( string namespace , string className , string methodName |
2727 vulnerableCallModel ( namespace , className , methodName , vulnerabilityId ) and
28- this .targetsMethod ( namespace , className , methodName )
28+ this .getTargetOperand ( )
29+ .getAnyDef ( )
30+ .( ExternalRefInstruction )
31+ .hasFullyQualifiedName ( namespace , className , methodName )
2932 )
3033 }
3134
3235 /** Gets the vulnerability ID associated with this call. */
3336 string getVulnerabilityId ( ) { result = vulnerabilityId }
34-
35- /** Gets the enclosing method. */
36- CilMethodExt getEnclosingVulnerableMethod ( ) { result = this .getEnclosingMethodExt ( ) }
3737}
3838
3939/**
@@ -44,30 +44,31 @@ VulnerableMethodCall getAVulnerableCallFromModel(string id) { result.getVulnerab
4444/**
4545 * Gets a method that directly contains a vulnerable call.
4646 */
47- CilMethodExt getADirectlyVulnerableMethod ( string id ) {
48- result = getAVulnerableCallFromModel ( id ) .getEnclosingVulnerableMethod ( )
47+ Function getADirectlyVulnerableMethod ( string id ) {
48+ result = getAVulnerableCallFromModel ( id ) .getEnclosingFunction ( )
4949}
5050
5151/**
5252 * Gets a method that transitively calls a vulnerable method.
5353 * This computes the transitive closure of the call graph.
5454 */
55- CilMethodExt getAVulnerableMethod ( string id ) {
55+ Function getAVulnerableMethod ( string id ) {
5656 // Direct call to vulnerable method
5757 result = getADirectlyVulnerableMethod ( id )
5858 or
5959 // Transitive: method calls another method that is vulnerable
60- exists ( CilCallExt call , CilMethodExt callee |
61- call .getEnclosingMethodExt ( ) = result and
60+ exists ( CallInstruction call , Function callee |
61+ call .getEnclosingFunction ( ) = result and
6262 callee = getAVulnerableMethod ( id ) and
63- call .getCallTargetFullyQualifiedName ( ) = callee .getFullyQualifiedName ( )
63+ call .getTargetOperand ( ) .getAnyDef ( ) .( ExternalRefInstruction ) .getFullyQualifiedName ( ) =
64+ callee .getFullyQualifiedName ( )
6465 )
6566}
6667
6768/**
6869 * Gets a public method that transitively calls a vulnerable method.
6970 */
70- CilMethodExt getAPublicVulnerableMethod ( string id ) {
71+ Function getAPublicVulnerableMethod ( string id ) {
7172 result = getAVulnerableMethod ( id ) and
7273 result .isPublic ( )
7374}
@@ -81,10 +82,8 @@ module ExportedVulnerableCalls {
8182 * Holds if `(namespace, className, methodName)` identifies a method that
8283 * leads to a vulnerable call identified by `id`.
8384 */
84- predicate pathToVulnerableMethod (
85- string namespace , string className , string methodName , string id
86- ) {
87- exists ( CilMethodExt m |
85+ predicate pathToVulnerableMethod ( string namespace , string className , string methodName , string id ) {
86+ exists ( Function m |
8887 m = getAVulnerableMethod ( id ) and
8988 m .hasFullyQualifiedName ( namespace , className , methodName )
9089 )
@@ -97,7 +96,7 @@ module ExportedVulnerableCalls {
9796 predicate publicPathToVulnerableMethod (
9897 string namespace , string className , string methodName , string id
9998 ) {
100- exists ( CilMethodExt m |
99+ exists ( Function m |
101100 m = getAPublicVulnerableMethod ( id ) and
102101 m .hasFullyQualifiedName ( namespace , className , methodName )
103102 )
0 commit comments