Skip to content

Commit f7beab7

Browse files
authored
Merge pull request diffblue#426 from diffblue/smowton/admin/test-use-with-statements
Tainted integer tests: use with-statements
2 parents 27adfc8 + 2a69325 commit f7beab7

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

regression/end_to_end/tainted-integers/test_tainted_integers.py

+50-50
Original file line numberDiff line numberDiff line change
@@ -10,89 +10,89 @@
1010
def test_tainted_integers_taint_flows_inwards():
1111
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
1212
subprocess.call(["ant", "compile1"])
13-
traces = run_security_analyser_pipeline(
14-
"build_flow_in",
15-
"rules.json",
16-
os.path.realpath(os.path.dirname(__file__)),
17-
"flow_in.main")
18-
assert traces.count_traces() == 1
19-
assert traces.trace_exists("java::flow_in.checker:(I)V", 5)
13+
with run_security_analyser_pipeline(
14+
"build_flow_in",
15+
"rules.json",
16+
os.path.realpath(os.path.dirname(__file__)),
17+
"flow_in.main") as traces:
18+
assert traces.count_traces() == 1
19+
assert traces.trace_exists("java::flow_in.checker:(I)V", 5)
2020

2121

2222
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
2323
def test_tainted_integers_taint_flows_outwards():
2424
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
2525
subprocess.call(["ant", "compile2"])
26-
traces = run_security_analyser_pipeline(
27-
"build_flow_out",
28-
"rules.json",
29-
os.path.realpath(os.path.dirname(__file__)),
30-
"flow_out.main")
31-
assert traces.count_traces() == 1
32-
assert traces.trace_exists("java::flow_out.main:(I)V", 21)
26+
with run_security_analyser_pipeline(
27+
"build_flow_out",
28+
"rules.json",
29+
os.path.realpath(os.path.dirname(__file__)),
30+
"flow_out.main") as traces:
31+
assert traces.count_traces() == 1
32+
assert traces.trace_exists("java::flow_out.main:(I)V", 21)
3333

3434

3535
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
3636
def test_tainted_integers_single_function():
3737
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
3838
subprocess.call(["ant", "compile3"])
39-
traces = run_security_analyser_pipeline(
40-
"build_single_function",
41-
"rules.json",
42-
os.path.realpath(os.path.dirname(__file__)),
43-
"single_function.main")
44-
assert traces.count_traces() == 1
45-
assert traces.trace_exists("java::single_function.main:(I)V", 13)
39+
with run_security_analyser_pipeline(
40+
"build_single_function",
41+
"rules.json",
42+
os.path.realpath(os.path.dirname(__file__)),
43+
"single_function.main") as traces:
44+
assert traces.count_traces() == 1
45+
assert traces.trace_exists("java::single_function.main:(I)V", 13)
4646

4747

4848
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
4949
def test_tainted_integers_taint_stored_in_array():
5050
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
5151
subprocess.call(["ant", "compile4"])
52-
traces = run_security_analyser_pipeline(
53-
"build_stored_in_array",
54-
"rules.json",
55-
os.path.realpath(os.path.dirname(__file__)),
56-
"stored_in_array.main")
57-
assert traces.count_traces() == 1
58-
assert traces.trace_exists("java::stored_in_array.main:(I)V", 16)
52+
with run_security_analyser_pipeline(
53+
"build_stored_in_array",
54+
"rules.json",
55+
os.path.realpath(os.path.dirname(__file__)),
56+
"stored_in_array.main") as traces:
57+
assert traces.count_traces() == 1
58+
assert traces.trace_exists("java::stored_in_array.main:(I)V", 16)
5959

6060

6161
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
6262
def test_tainted_integers_taint_stored_in_fields():
6363
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
6464
subprocess.call(["ant", "compile5"])
65-
traces = run_security_analyser_pipeline(
66-
"build_stored_in_fields",
67-
"rules.json",
68-
os.path.realpath(os.path.dirname(__file__)),
69-
"stored_in_fields.main")
70-
assert traces.count_traces() == 1
71-
assert traces.trace_exists("java::stored_in_fields.main:(I)V", 18)
65+
with run_security_analyser_pipeline(
66+
"build_stored_in_fields",
67+
"rules.json",
68+
os.path.realpath(os.path.dirname(__file__)),
69+
"stored_in_fields.main") as traces:
70+
assert traces.count_traces() == 1
71+
assert traces.trace_exists("java::stored_in_fields.main:(I)V", 18)
7272

7373

7474
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
7575
def test_tainted_integers_dependent_taint():
7676
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
7777
subprocess.call(["ant", "compile6"])
78-
traces = run_security_analyser_pipeline(
79-
"build_dependent_taint",
80-
"rules.json",
81-
os.path.realpath(os.path.dirname(__file__)),
82-
"dependent_taint.main")
83-
assert traces.count_traces() == 1
84-
assert traces.trace_exists("java::dependent_taint.main:(I)V", 15)
85-
assert not traces.trace_exists("java::dependent_taint.main:(I)V", 18)
78+
with run_security_analyser_pipeline(
79+
"build_dependent_taint",
80+
"rules.json",
81+
os.path.realpath(os.path.dirname(__file__)),
82+
"dependent_taint.main") as traces:
83+
assert traces.count_traces() == 1
84+
assert traces.trace_exists("java::dependent_taint.main:(I)V", 15)
85+
assert not traces.trace_exists("java::dependent_taint.main:(I)V", 18)
8686

8787

8888
@fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
8989
def test_tainted_integers_dependent_taint_in_summary():
9090
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
9191
subprocess.call(["ant", "compile7"])
92-
traces = run_security_analyser_pipeline(
93-
"build_dependent_taint_in_summary",
94-
"rules.json",
95-
os.path.realpath(os.path.dirname(__file__)),
96-
"dependent_taint_in_summary.main")
97-
assert traces.count_traces() == 1
98-
assert traces.trace_exists("java::dependent_taint_in_summary.main:()V", 11)
92+
with run_security_analyser_pipeline(
93+
"build_dependent_taint_in_summary",
94+
"rules.json",
95+
os.path.realpath(os.path.dirname(__file__)),
96+
"dependent_taint_in_summary.main") as traces:
97+
assert traces.count_traces() == 1
98+
assert traces.trace_exists("java::dependent_taint_in_summary.main:()V", 11)

0 commit comments

Comments
 (0)