@@ -18,11 +18,10 @@ private import codeql.mad.modelgenerator.internal.ModelGeneratorImpl
1818private import modeling.ModelEditor
1919
2020module ModelGeneratorInput implements ModelGeneratorInputSig< P:: Location , PythonDataFlow > {
21- class Type = Unit ; // P::Type ?
21+ class Type = Unit ;
2222
2323 class Parameter = DataFlow:: ParameterNode ;
2424
25- // class Callable = Callable;
2625 class Callable instanceof DataFlowCallable {
2726 string toString ( ) { result = super .toString ( ) }
2827 }
@@ -34,16 +33,6 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
3433
3534 override Callable getEnclosingCallable ( ) { result = super .getEnclosingCallable ( ) }
3635
37- // override Callable getEnclosingCallable() {
38- // result = this.(DataFlow::Node).getEnclosingCallable().(DataFlowFunction).getScope()
39- // // result = this.(DataFlow::Node).getEnclosingCallable().(DataFlowFunction).getScope()
40- // // exists(P::Function func |
41- // // func.getScope() = this.(DataFlow::Node).getEnclosingCallable().getScope()
42- // // |
43- // // result = func
44- // // )
45- // }
46-
4736 Parameter asParameter ( ) { result = this }
4837 }
4938
@@ -74,23 +63,17 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
7463 predicate isRelevant ( ) { relevant ( this ) }
7564 }
7665
77- // /**
78- // * `
79- // */
80- // private predicate qualifiedName(Callable c, string package, string type) {
81- // result = c.
82- // }
83-
8466 predicate isRelevantType ( Type t ) { any ( ) }
8567
8668 Type getUnderlyingContentType ( DataFlow:: ContentSet c ) { result = any ( Type t ) and exists ( c ) }
8769
8870 string qualifierString ( ) { result = "Argument[this]" }
8971
9072 string parameterAccess ( Parameter p ) {
91- // TODO: Implement this to support named parameters
92- result = "Argument[" + p .getPosition ( ) .toString ( ) + "]"
93- // result = "param[]"
73+ result = "Argument[" + p .getParameter ( ) .getName ( ) + "]"
74+ or
75+ not exists ( p .getParameter ( ) .getName ( ) ) and
76+ result = "Argument[" + p .getParameter ( ) .getPosition ( ) .toString ( ) + "]"
9477 }
9578
9679 string parameterContentAccess ( Parameter p ) { result = "Argument[]" }
@@ -112,7 +95,7 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
11295 }
11396
11497 Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
115- // TODO
98+ // TODO: Check if we need the complexity of the Java implementation.
11699 result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret )
117100 }
118101
@@ -149,44 +132,14 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
149132
150133 string getSyntheticName ( DataFlow:: ContentSet c ) { none ( ) }
151134
152- string printContent ( DataFlow:: ContentSet c ) {
153- // TODO
154- result = "Memeber[]"
155- // exists(Parameter param |
156- // param = c.(Public::ParameterNode).getParameter()
157- // |
158- // result = "Member[" + param.getName() + "]"
159- // )
160- // exists(string name, string arg |
161- // name = "Member" and
162- // if arg = "" then result = name else result = "Memeber[" + arg + "]"
163- // )
164- }
135+ string printContent ( DataFlow:: ContentSet c ) { result = c .toString ( ) }
165136
166- /**
167- * - ["argparse.ArgumentParser", "Member[_parse_known_args,_read_args_from_files]", "Argument[0,arg_strings:]", "ReturnValue", "taint"]
168- */
169137 string partialModelRow ( Callable api , int i ) {
170- exists ( Endpoint e | e = api .( DataFlowFunction ) .getScope ( ) |
171- i = 0 and result = e .getNamespace ( )
172- or
173- i = 1 and result = e .getClass ( )
138+ exists ( Endpoint e | e = api .( DataFlowFunction ) .getScope ( ) |
139+ i = 0 and result = e .getNamespace ( ) + "." + e .getClass ( )
174140 or
175- i = 2 and result = e .getFunctionName ( )
176- or
177- i = 3 and result = e .getParameters ( )
178-
141+ i = 1 and result = "Member[" + e .getFunctionName ( ) + "]"
179142 )
180- // and
181- // // i = 0 and qualifiedName(api, result, _) // package[.Class]
182- // i = 0 and result = api.(DataFlowCallable)
183- // or
184- // i = 1 and result = "1" // name
185- // or
186- // i = 2 and
187- // result = "2"
188- // TODO
189- // exists(Parameter p | p = api.getArg(_) | result = "Member[" + p.getName() + "]") // parameters
190143 }
191144
192145 string partialNeutralModelRow ( Callable api , int i ) { result = partialModelRow ( api , i ) }
0 commit comments