Skip to content

Commit 05d156b

Browse files
committed
Python: add comments
1 parent 39c5e0d commit 05d156b

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

python/ql/test/experimental/dataflow/variable-capture/dict.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Here we test writing to a captured variable via a dictionary (see `out`).
2+
# We also test reading one captured variable and writing the value to another (see `through`).
3+
14
# All functions starting with "test_" should run and execute `print("OK")` exactly once.
25
# This can be checked by running validTest.py.
36

@@ -29,7 +32,7 @@ def SINK_F(x):
2932
print("OK")
3033

3134

32-
def Out():
35+
def out():
3336
sinkO1 = { "x": "" }
3437
def captureOut1():
3538
sinkO1["x"] = SOURCE
@@ -56,10 +59,10 @@ def m():
5659
SINK_F(nonSink0["x"])
5760

5861
@expects(4)
59-
def test_Out():
60-
Out()
62+
def test_out():
63+
out()
6164

62-
def Through(tainted):
65+
def through(tainted):
6366
sinkO1 = { "x": "" }
6467
def captureOut1():
6568
sinkO1["x"] = tainted
@@ -86,5 +89,5 @@ def m():
8689
SINK_F(nonSink0["x"])
8790

8891
@expects(4)
89-
def test_Through():
90-
Through(SOURCE)
92+
def test_through():
93+
through(SOURCE)

python/ql/test/experimental/dataflow/variable-capture/in.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Here we test the case where a captured variable is being read.
2+
13
# All functions starting with "test_" should run and execute `print("OK")` exactly once.
24
# This can be checked by running validTest.py.
35

@@ -28,7 +30,7 @@ def SINK_F(x):
2830
else:
2931
print("OK")
3032

31-
33+
# Capture the parameter of an outer function.
3234
def inParam(tainted):
3335
def captureIn1():
3436
sinkI1 = tainted
@@ -59,6 +61,7 @@ def m():
5961
def test_inParam():
6062
inParam(SOURCE)
6163

64+
# Capture the local variable of an outer function.
6265
def inLocal():
6366
tainted = SOURCE
6467

python/ql/test/experimental/dataflow/variable-capture/nonlocal.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Here we test writing to a captured variable via the `nonlocal` keyword (see `out`).
2+
# We also test reading one captured variable and writing the value to another (see `through`).
3+
14
# All functions starting with "test_" should run and execute `print("OK")` exactly once.
25
# This can be checked by running validTest.py.
36

@@ -29,7 +32,7 @@ def SINK_F(x):
2932
print("OK")
3033

3134

32-
def Out():
35+
def out():
3336
sinkO1 = ""
3437
def captureOut1():
3538
nonlocal sinkO1
@@ -60,10 +63,10 @@ def m():
6063
SINK_F(nonSink0)
6164

6265
@expects(4)
63-
def test_Out():
64-
Out()
66+
def test_out():
67+
out()
6568

66-
def Through(tainted):
69+
def through(tainted):
6770
sinkO1 = ""
6871
def captureOut1():
6972
nonlocal sinkO1
@@ -94,5 +97,5 @@ def m():
9497
SINK_F(nonSink0)
9598

9699
@expects(4)
97-
def test_Through():
98-
Through(SOURCE)
100+
def test_through():
101+
through(SOURCE)

0 commit comments

Comments
 (0)