@@ -18,11 +18,10 @@ private import codeql.mad.modelgenerator.internal.ModelGeneratorImpl
18
18
private import modeling.ModelEditor
19
19
20
20
module ModelGeneratorInput implements ModelGeneratorInputSig< P:: Location , PythonDataFlow > {
21
- class Type = Unit ; // P::Type ?
21
+ class Type = Unit ;
22
22
23
23
class Parameter = DataFlow:: ParameterNode ;
24
24
25
- // class Callable = Callable;
26
25
class Callable instanceof DataFlowCallable {
27
26
string toString ( ) { result = super .toString ( ) }
28
27
}
@@ -34,16 +33,6 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
34
33
35
34
override Callable getEnclosingCallable ( ) { result = super .getEnclosingCallable ( ) }
36
35
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
-
47
36
Parameter asParameter ( ) { result = this }
48
37
}
49
38
@@ -74,23 +63,17 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
74
63
predicate isRelevant ( ) { relevant ( this ) }
75
64
}
76
65
77
- // /**
78
- // * `
79
- // */
80
- // private predicate qualifiedName(Callable c, string package, string type) {
81
- // result = c.
82
- // }
83
-
84
66
predicate isRelevantType ( Type t ) { any ( ) }
85
67
86
68
Type getUnderlyingContentType ( DataFlow:: ContentSet c ) { result = any ( Type t ) and exists ( c ) }
87
69
88
70
string qualifierString ( ) { result = "Argument[this]" }
89
71
90
72
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 ( ) + "]"
94
77
}
95
78
96
79
string parameterContentAccess ( Parameter p ) { result = "Argument[]" }
@@ -112,7 +95,7 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
112
95
}
113
96
114
97
Callable returnNodeEnclosingCallable ( DataFlow:: Node ret ) {
115
- // TODO
98
+ // TODO: Check if we need the complexity of the Java implementation.
116
99
result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret )
117
100
}
118
101
@@ -149,44 +132,14 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<P::Location, Python
149
132
150
133
string getSyntheticName ( DataFlow:: ContentSet c ) { none ( ) }
151
134
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 ( ) }
165
136
166
- /**
167
- * - ["argparse.ArgumentParser", "Member[_parse_known_args,_read_args_from_files]", "Argument[0,arg_strings:]", "ReturnValue", "taint"]
168
- */
169
137
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 ( )
174
140
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 ( ) + "]"
179
142
)
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
190
143
}
191
144
192
145
string partialNeutralModelRow ( Callable api , int i ) { result = partialModelRow ( api , i ) }
0 commit comments