Skip to content

Commit a385e87

Browse files
committed
Python: Add change note for module resolution
Also adapts the version-specific tests to support results specific to Python 2 (though at the moment there are no such tests).
1 parent d79eed5 commit a385e87

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The data-flow library has been rewritten to no longer rely on the points-to analysis in order to
5+
resolve references to modules. This should result in more results for data-flow queries.

python/ql/test/experimental/import-resolution/importflow.ql

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,29 @@ class ResolutionTest extends InlineExpectationsTest {
9393
}
9494
}
9595

96-
class ResolutionTest3 extends InlineExpectationsTest {
97-
ResolutionTest3() { this = "ResolutionTest3" }
96+
class VersionSpecificResolutionTest extends InlineExpectationsTest {
97+
VersionSpecificResolutionTest() { this = "VersionSpecificResolutionTest" }
9898

99-
override string getARelevantTag() { result = "prints3" and major_version() = 3 }
99+
override string getARelevantTag() { result = getTagForVersion(_) }
100+
101+
private string getTagForVersion(int version) {
102+
result = "prints" + version and
103+
version = major_version()
104+
}
100105

101106
override predicate hasActualResult(Location location, string element, string tag, string value) {
102107
(
103108
exists(DataFlow::PathNode source, DataFlow::PathNode sink, ImportConfiguration config |
104109
config.hasFlowPath(source, sink) and
105-
sink.getNode().(VersionGuardedNode).getVersion() = 3 and
106-
tag = "prints3" and
110+
tag = getTagForVersion(sink.getNode().(VersionGuardedNode).getVersion()) and
107111
location = sink.getNode().getLocation() and
108112
value = source.getNode().(SourceString).getContents() and
109113
element = sink.getNode().toString()
110114
)
111115
or
112116
exists(ModuleRef ref |
113-
ref.(VersionGuardedNode).getVersion() = 3 and
114117
ref instanceof CheckArgument and
115-
tag = "prints3" and
118+
tag = getTagForVersion(ref.(VersionGuardedNode).getVersion()) and
116119
location = ref.getLocation() and
117120
value = "\"<module " + ref.getName() + ">\"" and
118121
element = ref.toString()

0 commit comments

Comments
 (0)