Skip to content

Commit c329163

Browse files
Merge pull request diffblue#385 from diffblue/enabling_reachability_slicer_instead_of_full_one
[SEC-354] Switch default slicer in the pipeline from full- to reachability-slicer
2 parents 0aeed56 + a144dc1 commit c329163

File tree

7 files changed

+37
-30
lines changed

7 files changed

+37
-30
lines changed

driver/analyser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def run_program_slicing(
127127

128128
command = (
129129
get_goto_instrument_pathname() + " " +
130-
# "--reachability-slice " +
131-
"--full-slice " +
130+
"--reachability-slice " +
131+
# "--full-slice " +
132132
"--verbosity " + str(verbosity) + " " +
133133
cfg["goto_binary_file"] + " " +
134134
dst_goto_program_fname + " " +

regression/end_to_end/driver.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def count_traces(self):
1919
for trace in self.traces:
2020
for prog_traces in trace["error_traces"].values():
2121
count += len(prog_traces)
22-
2322
return count
2423

2524
def trace_exists(self, function, line_no):
@@ -36,6 +35,14 @@ def trace_of_length_exists(self, function, line_no, tool_name, trace_length):
3635
return True
3736
return False
3837

38+
def count_specific_traces(self, function, line_no, tool_name):
39+
count = 0
40+
for trace in self.traces:
41+
if trace["function"] == function and trace["line"] == line_no:
42+
for error_trace in trace["error_traces"][tool_name]:
43+
count += 1
44+
return count
45+
3946
def trace_goes_through(
4047
self,
4148
tool_name,

regression/end_to_end/taint_over_list/test_taint_over_list.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import os
2-
import pytest
32
import subprocess
43

54
from regression.end_to_end.driver import run_security_analyser_pipeline
65
import regression.utils as utils
76

87

9-
@pytest.mark.xfail(strict=True)
108
def test_taint_over_list():
11-
"""
12-
The problem is in the full-slicer. It removes code from ArrayList.add.
13-
When the slicer is disabled (skipped) the results is correct.
14-
"""
9+
# This test fails with the full-slicer on because it removes code from
10+
# ArrayList.add.
1511
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
1612
subprocess.call(["flock", ".build_lock", "ant"])
1713
traces = run_security_analyser_pipeline(

regression/end_to_end/taint_over_list_models/test_taint_over_list_models.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
import regression.utils as utils
77

88

9-
@pytest.mark.xfail(strict=True)
9+
# This test also crashes with the full-slicer on
10+
@pytest.mark.xfail("SECURITY_REGRESSION_TESTS_USE_CSVSA" in os.environ,
11+
strict=True, reason="Zero traces found with CSVSA")
1012
def test_taint_over_list_models():
11-
"""
12-
The test crashes in the taint analysis:
13-
security-scanner/src/taint-analysis/taint_summary.cpp:663:
14-
Assertion `replace_it!=program->get_NONDET_retvals_replacements().cend()'
15-
failed.
16-
"""
1713
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
1814
subprocess.call(["flock", ".build_lock", "ant"])
1915
traces = run_security_analyser_pipeline(

regression/end_to_end/taint_two_tokens/rules.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
},
1414
{
15-
"comment": "Read from tainted stream gives tainted string and tainted bytes.",
15+
"comment": "Read from tainted stream taints passed bytes.",
1616
"class": "two.tokens.ServletInputStream",
1717
"method": "read:([B)Ltwo/tokens/String;",
1818
"input": {
@@ -26,7 +26,7 @@
2626
}
2727
},
2828
{
29-
"comment": "Read from tainted stream gives tainted string and tainted bytes.",
29+
"comment": "Read from tainted stream gives tainted string.",
3030
"class": "two.tokens.ServletInputStream",
3131
"method": "read:([B)Ltwo/tokens/String;",
3232
"input": {

regression/end_to_end/taint_two_tokens/test_taint_two_tokens.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
def test_taint_two_tokens():
9-
109
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
1110
subprocess.call(["flock", ".build_lock", "ant"])
1211
with run_security_analyser_pipeline(
@@ -15,16 +14,11 @@ def test_taint_two_tokens():
1514
os.path.realpath(os.path.dirname(__file__)),
1615
"two.tokens.Main.doGet") as traces:
1716

18-
# There are two traces here but they are both linked to the same line number even if the goto assert operation
19-
# is different. Right now we can't tell the difference between the two, except of their length.
20-
assert traces.count_traces() == 2
21-
assert traces.trace_of_length_exists(
17+
# There should be two traces linked to the same line number generated
18+
# from two different goto assert operations.
19+
assert traces.count_specific_traces(
2220
"java::two.tokens.Main.doGet:(Ltwo/tokens/HttpServletRequest;Ltwo/tokens/HttpServletResponse;)V",
2321
28,
24-
"jbmc",
25-
66 if "SECURITY_REGRESSION_TESTS_USE_CSVSA" in os.environ else 63)
26-
assert traces.trace_of_length_exists(
27-
"java::two.tokens.Main.doGet:(Ltwo/tokens/HttpServletRequest;Ltwo/tokens/HttpServletResponse;)V",
28-
28,
29-
"jbmc",
30-
68 if "SECURITY_REGRESSION_TESTS_USE_CSVSA" in os.environ else 65)
22+
"jbmc") == 2
23+
# Check there aren't any other traces
24+
assert traces.count_traces() == 2

src/taint-slicer/instrumenter.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,20 @@ void taint_instrumentert::instrument_instructions_with_shadow_variables(
600600
}
601601
}
602602
break;
603+
case OTHER:
604+
if(instr_it->code.get_statement() == ID_array_set)
605+
{
606+
codet &code = instr_it->code;
607+
code.op0() = drive_access_path_through_super_classes(code.op0());
608+
INVARIANT(
609+
can_cast_type<pointer_typet>(code.op0().type()),
610+
"first argument to array_set must be of pointer type");
611+
code.op1() = make_or_update_initialiser(
612+
code.op1(),
613+
ns.follow(code.op0().type().subtype()),
614+
get_instrumented_symbol_table(),
615+
get_names_of_shadow_variables());
616+
}
603617
default:
604618
break;
605619
}

0 commit comments

Comments
 (0)