Skip to content

Commit dc0d940

Browse files
committed
Python: Ensure all concept tests ignore irrelevant results
Since this was causing a CI error. also changed things a bit so we do it in a consistent way :)
1 parent bc4a0bc commit dc0d940

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

python/ql/test/experimental/meta/ConceptsTest.qll

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class CodeExecutionTest extends InlineExpectationsTest {
111111
override string getARelevantTag() { result = "getCode" }
112112

113113
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
114+
exists(___location.getFile().getRelativePath()) and
114115
exists(CodeExecution ce, DataFlow::Node code |
115116
exists(___location.getFile().getRelativePath()) and
116117
code = ce.getCode() and
@@ -128,6 +129,7 @@ class SqlExecutionTest extends InlineExpectationsTest {
128129
override string getARelevantTag() { result = "getSql" }
129130

130131
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
132+
exists(___location.getFile().getRelativePath()) and
131133
exists(SqlExecution e, DataFlow::Node sql |
132134
exists(___location.getFile().getRelativePath()) and
133135
sql = e.getSql() and
@@ -145,6 +147,7 @@ class HttpServerRouteSetupTest extends InlineExpectationsTest {
145147
override string getARelevantTag() { result in ["routeSetup"] }
146148

147149
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
150+
exists(___location.getFile().getRelativePath()) and
148151
exists(HTTP::Server::RouteSetup setup |
149152
___location = setup.getLocation() and
150153
element = setup.toString() and
@@ -165,19 +168,22 @@ class HttpServerRequestHandlerTest extends InlineExpectationsTest {
165168
override string getARelevantTag() { result in ["requestHandler", "routedParameter"] }
166169

167170
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
168-
exists(HTTP::Server::RequestHandler handler |
169-
___location = handler.getLocation() and
170-
element = handler.toString() and
171-
value = "" and
172-
tag = "requestHandler"
173-
)
174-
or
175-
exists(HTTP::Server::RequestHandler handler, Parameter param |
176-
param = handler.getARoutedParameter() and
177-
___location = param.getLocation() and
178-
element = param.toString() and
179-
value = param.asName().getId() and
180-
tag = "routedParameter"
171+
exists(___location.getFile().getRelativePath()) and
172+
(
173+
exists(HTTP::Server::RequestHandler handler |
174+
___location = handler.getLocation() and
175+
element = handler.toString() and
176+
value = "" and
177+
tag = "requestHandler"
178+
)
179+
or
180+
exists(HTTP::Server::RequestHandler handler, Parameter param |
181+
param = handler.getARoutedParameter() and
182+
___location = param.getLocation() and
183+
element = param.toString() and
184+
value = param.asName().getId() and
185+
tag = "routedParameter"
186+
)
181187
)
182188
}
183189
}
@@ -198,7 +204,7 @@ class HttpServerHttpResponseTest extends InlineExpectationsTest {
198204
// flask tests more readable since adding full annotations for HttpResponses in the
199205
// the tests for routing setup is both annoying and not very useful.
200206
___location.getFile() = file and
201-
tag = getARelevantTag() and
207+
exists(file.getRelativePath()) and
202208
(
203209
exists(HTTP::Server::HttpResponse response |
204210
___location = response.getLocation() and
@@ -237,8 +243,8 @@ class FileSystemAccessTest extends InlineExpectationsTest {
237243
override string getARelevantTag() { result = "getAPathArgument" }
238244

239245
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
246+
exists(___location.getFile().getRelativePath()) and
240247
exists(FileSystemAccess a, DataFlow::Node path |
241-
exists(___location.getFile().getRelativePath()) and
242248
path = a.getAPathArgument() and
243249
___location = a.getLocation() and
244250
element = path.toString() and
@@ -254,8 +260,8 @@ class PathNormalizationTest extends InlineExpectationsTest {
254260
override string getARelevantTag() { result = "pathNormalization" }
255261

256262
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
263+
exists(___location.getFile().getRelativePath()) and
257264
exists(Path::PathNormalization n |
258-
exists(___location.getFile().getRelativePath()) and
259265
___location = n.getLocation() and
260266
element = n.toString() and
261267
value = "" and
@@ -270,8 +276,8 @@ class SafeAccessCheckTest extends InlineExpectationsTest {
270276
override string getARelevantTag() { result in ["checks", "branch"] }
271277

272278
override predicate hasActualResult(Location ___location, string element, string tag, string value) {
279+
exists(___location.getFile().getRelativePath()) and
273280
exists(Path::SafeAccessCheck c, DataFlow::Node checks, boolean branch |
274-
exists(___location.getFile().getRelativePath()) and
275281
c.checks(checks.asCfgNode(), branch) and
276282
___location = c.getLocation() and
277283
(

0 commit comments

Comments
 (0)