@@ -2,19 +2,7 @@ import python
22import semmle.python.dataflow.new.DataFlow
33import semmle.python.Concepts
44import TestUtilities.InlineExpectationsTest
5-
6- string value_from_expr ( Expr e ) {
7- // TODO: This one is starting to look like `repr` predicate from TestTaintLib
8- result =
9- e .( StrConst ) .getPrefix ( ) + e .( StrConst ) .getText ( ) +
10- e .( StrConst ) .getPrefix ( ) .regexpReplaceAll ( "[a-zA-Z]+" , "" )
11- or
12- result = e .( Name ) .getId ( )
13- or
14- not e instanceof StrConst and
15- not e instanceof Name and
16- result = e .toString ( )
17- }
5+ import experimental.dataflow.TestUtil.PrintNode
186
197class SystemCommandExecutionTest extends InlineExpectationsTest {
208 SystemCommandExecutionTest ( ) { this = "SystemCommandExecutionTest" }
@@ -27,7 +15,7 @@ class SystemCommandExecutionTest extends InlineExpectationsTest {
2715 command = sce .getCommand ( ) and
2816 location = command .getLocation ( ) and
2917 element = command .toString ( ) and
30- value = value_from_expr ( command . asExpr ( ) ) and
18+ value = prettyNodeForInlineTest ( command ) and
3119 tag = "getCommand"
3220 )
3321 }
@@ -46,7 +34,7 @@ class DecodingTest extends InlineExpectationsTest {
4634 exists ( DataFlow:: Node data |
4735 location = data .getLocation ( ) and
4836 element = data .toString ( ) and
49- value = value_from_expr ( data . asExpr ( ) ) and
37+ value = prettyNodeForInlineTest ( data ) and
5038 (
5139 data = d .getAnInput ( ) and
5240 tag = "decodeInput"
@@ -84,7 +72,7 @@ class EncodingTest extends InlineExpectationsTest {
8472 exists ( DataFlow:: Node data |
8573 location = data .getLocation ( ) and
8674 element = data .toString ( ) and
87- value = value_from_expr ( data . asExpr ( ) ) and
75+ value = prettyNodeForInlineTest ( data ) and
8876 (
8977 data = e .getAnInput ( ) and
9078 tag = "encodeInput"
@@ -117,7 +105,7 @@ class CodeExecutionTest extends InlineExpectationsTest {
117105 code = ce .getCode ( ) and
118106 location = code .getLocation ( ) and
119107 element = code .toString ( ) and
120- value = value_from_expr ( code . asExpr ( ) ) and
108+ value = prettyNodeForInlineTest ( code ) and
121109 tag = "getCode"
122110 )
123111 }
@@ -135,7 +123,7 @@ class SqlExecutionTest extends InlineExpectationsTest {
135123 sql = e .getSql ( ) and
136124 location = e .getLocation ( ) and
137125 element = sql .toString ( ) and
138- value = value_from_expr ( sql . asExpr ( ) ) and
126+ value = prettyNodeForInlineTest ( sql ) and
139127 tag = "getSql"
140128 )
141129 }
@@ -218,7 +206,7 @@ class HttpServerHttpResponseTest extends InlineExpectationsTest {
218206 exists ( HTTP:: Server:: HttpResponse response |
219207 location = response .getLocation ( ) and
220208 element = response .toString ( ) and
221- value = value_from_expr ( response .getBody ( ) . asExpr ( ) ) and
209+ value = prettyNodeForInlineTest ( response .getBody ( ) ) and
222210 tag = "responseBody"
223211 )
224212 or
@@ -257,7 +245,7 @@ class HttpServerHttpRedirectResponseTest extends InlineExpectationsTest {
257245 exists ( HTTP:: Server:: HttpRedirectResponse redirect |
258246 location = redirect .getLocation ( ) and
259247 element = redirect .toString ( ) and
260- value = value_from_expr ( redirect .getRedirectLocation ( ) . asExpr ( ) ) and
248+ value = prettyNodeForInlineTest ( redirect .getRedirectLocation ( ) ) and
261249 tag = "redirectLocation"
262250 )
263251 )
@@ -275,7 +263,7 @@ class FileSystemAccessTest extends InlineExpectationsTest {
275263 path = a .getAPathArgument ( ) and
276264 location = a .getLocation ( ) and
277265 element = path .toString ( ) and
278- value = value_from_expr ( path . asExpr ( ) ) and
266+ value = prettyNodeForInlineTest ( path ) and
279267 tag = "getAPathArgument"
280268 )
281269 }
@@ -309,7 +297,7 @@ class SafeAccessCheckTest extends InlineExpectationsTest {
309297 location = c .getLocation ( ) and
310298 (
311299 element = checks .toString ( ) and
312- value = value_from_expr ( checks . asExpr ( ) ) and
300+ value = prettyNodeForInlineTest ( checks ) and
313301 tag = "checks"
314302 or
315303 element = branch .toString ( ) and
0 commit comments