Skip to content

Commit 1d44694

Browse files
authored
Merge pull request #8732 from RasmusWL/dataflow-imports
Python: Don't re-export `python` under `DataFlow::`
2 parents 231def0 + 888a38c commit 1d44694

File tree

9 files changed

+26
-2
lines changed

9 files changed

+26
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: breaking
3+
---
4+
* The imports made available from `import python` are no longer exposed under `DataFlow::` after doing `import semmle.python.dataflow.new.DataFlow`, for example using `DataFlow::Add` will now cause a compile error.

python/ql/lib/semmle/python/SpecialMethods.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Extend `SpecialMethod::Potential` to capture more cases.
99
*/
1010

11-
import python
11+
private import python
1212

1313
/** A control flow node which might correspond to a special method call. */
1414
class PotentialSpecialMethodCallNode extends ControlFlowNode {

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
/**
22
* Provides Python-specific definitions for use in the data flow library.
33
*/
4+
5+
// we need to export `Unit` for the DataFlowImpl* files
6+
private import python as Python
7+
48
module Private {
59
import DataFlowPrivate
10+
611
// import DataFlowDispatch
12+
class Unit = Python::Unit;
713
}
814

915
module Public {

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowUtil.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Contains utility functions for writing data flow queries
33
*/
44

5+
private import python
56
private import DataFlowPrivate
67
import DataFlowPublic
78

python/ql/lib/semmle/python/dataflow/new/internal/LocalSources.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* local tracking within a function.
77
*/
88

9-
import python
9+
private import python
1010
import DataFlowPublic
1111
private import DataFlowPrivate
1212
private import semmle.python.internal.CachedStages
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Sometimes we accidentally re-export too much from `DataFlow` such that for example we can access `Add` from `DataFlow::Add` :disappointed:
2+
3+
This test should always FAIL to compile!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ERROR: Could not resolve type DataFlow::Add (Test.ql:7,6-19)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import python
2+
private import semmle.python.dataflow.new.DataFlow
3+
4+
// Sometimes we accidentally re-export too much from `DataFlow` such that for example we can access `Add` from `DataFlow::Add` :(
5+
//
6+
// This test should always FAIL to compile!
7+
from DataFlow::Add this_should_not_work
8+
select this_should_not_work
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1+1

0 commit comments

Comments
 (0)