|
10 | 10 | def test_tainted_integers_taint_flows_inwards():
|
11 | 11 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
12 | 12 | 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) |
20 | 20 |
|
21 | 21 |
|
22 | 22 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
23 | 23 | def test_tainted_integers_taint_flows_outwards():
|
24 | 24 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
25 | 25 | 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) |
33 | 33 |
|
34 | 34 |
|
35 | 35 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
36 | 36 | def test_tainted_integers_single_function():
|
37 | 37 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
38 | 38 | 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) |
46 | 46 |
|
47 | 47 |
|
48 | 48 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
49 | 49 | def test_tainted_integers_taint_stored_in_array():
|
50 | 50 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
51 | 51 | 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) |
59 | 59 |
|
60 | 60 |
|
61 | 61 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
62 | 62 | def test_tainted_integers_taint_stored_in_fields():
|
63 | 63 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
64 | 64 | 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) |
72 | 72 |
|
73 | 73 |
|
74 | 74 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
75 | 75 | def test_tainted_integers_dependent_taint():
|
76 | 76 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
77 | 77 | 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) |
86 | 86 |
|
87 | 87 |
|
88 | 88 | @fasteners.interprocess_locked(os.path.join(os.path.dirname(__file__), ".build_lock"))
|
89 | 89 | def test_tainted_integers_dependent_taint_in_summary():
|
90 | 90 | with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
|
91 | 91 | 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