Skip to content

Commit a2d7c87

Browse files
authored
Merge pull request diffblue#387 from diffblue/reduced_size_of_taint_summaries
SEC-359: Reducing the size of domain of the taint analysis.
2 parents c329163 + abe557e commit a2d7c87

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/taint-analysis/taint_summary.cpp

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,6 @@ void taint_algorithm_computing_summary_of_functiont::initialise_domain(
836836
}
837837
}
838838

839-
numbered_lvalue_to_taint_mapt entry_map;
840-
numbered_lvalue_to_taint_mapt others_map;
841839
for(const auto lvaluenum : environment)
842840
{
843841
const taint_lvaluet &lvalue=numbering->at(lvaluenum);
@@ -852,18 +850,15 @@ void taint_algorithm_computing_summary_of_functiont::initialise_domain(
852850
{
853851
taint_variablet v = taint_variablet::fresh();
854852
caller_summary.input.insert({ lvaluenum, v });
855-
entry_map.insert({lvaluenum, taint_sett::from_variable(v) });
856-
others_map.insert({lvaluenum, taint_sett() });
857853
}
858854
}
859855

860-
caller_summary.domain.insert(
861-
{ function.body.instructions.cbegin(), entry_map });
862-
for(auto it = std::next(function.body.instructions.cbegin());
856+
numbered_lvalue_to_taint_mapt initial_map;
857+
for(auto it = function.body.instructions.cbegin();
863858
it != function.body.instructions.cend();
864859
++it)
865860
{
866-
caller_summary.domain.insert({ it, others_map });
861+
caller_summary.domain.insert({ it, initial_map });
867862
}
868863

869864
// Now that all maps have been created, replace those with a unique
@@ -913,6 +908,7 @@ void taint_algorithm_computing_summary_of_functiont::initialise_domain(
913908
void taint_algorithm_computing_summary_of_functiont::handle_assignment(
914909
const code_assignt& asgn,
915910
numbered_lvalue_to_taint_mapt const& a,
911+
const taint_summary_inputt &input,
916912
numbered_lvalue_to_taint_mapt& result,
917913
instruction_iteratort const& Iit,
918914
local_value_set_analysist &lvsa)
@@ -931,30 +927,16 @@ void taint_algorithm_computing_summary_of_functiont::handle_assignment(
931927
handle_assignment(
932928
member_assign,
933929
a,
930+
input,
934931
result,
935932
Iit,
936933
lvsa);
937934
}
938935
return;
939936
}
940937

941-
taint_sett taint;
942-
{
943-
lvalue_numbers_sett rhs;
944-
collect_lvsa_access_paths(
945-
asgn.rhs(),
946-
program->get_namespace(),
947-
rhs,
948-
lvsa,
949-
Iit,
950-
*numbering);
951-
for(const auto &lvalue : rhs)
952-
{
953-
const auto it=a.find(lvalue);
954-
if(it!=a.cend())
955-
taint|=it->second;
956-
}
957-
}
938+
taint_sett taint = compute_taint_of_aliased_numbers_of_lvalue(
939+
asgn.rhs(), Iit, lvsa, input, a);
958940

959941
lvalue_numbers_sett lhs;
960942
bool singular=false;
@@ -987,6 +969,7 @@ taint_sett taint_algorithm_computing_summary_of_functiont::
987969
const taint_lvaluet &lvalue,
988970
const instruction_iteratort &Iit,
989971
local_value_set_analysist &lvsa,
972+
const taint_summary_inputt &input,
990973
const numbered_lvalue_to_taint_mapt &a)
991974
{
992975
TMPROF_BLOCK();
@@ -1005,6 +988,12 @@ taint_sett taint_algorithm_computing_summary_of_functiont::
1005988
auto it=a.find(lvalue_number);
1006989
if(it!=a.cend())
1007990
result |= it->second;
991+
else
992+
{
993+
const auto input_it = input.find(lvalue_number);
994+
if(input_it != input.cend())
995+
result += input_it->second;
996+
}
1008997
}
1009998
return result;
1010999
}
@@ -1059,6 +1048,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
10591048
const numbered_lvalue_to_taint_mapt &a,
10601049
const instruction_iteratort &Iit,
10611050
const irep_idt &caller_ident,
1051+
const taint_summary_inputt &input,
10621052
taint_summaryt::dbt &database,
10631053
local_value_set_analysist &lvsa,
10641054
taint_transition_propertiest &transition_properties)
@@ -1089,7 +1079,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
10891079
{
10901080
taint_sett taint =
10911081
compute_taint_of_aliased_numbers_of_lvalue(
1092-
replace_it->second, Iit, lvsa, a);
1082+
replace_it->second, Iit, lvsa, input, a);
10931083

10941084
lvalue_numbers_sett numbers_of_aliases;
10951085
collect_lvsa_access_paths(
@@ -1140,7 +1130,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
11401130
}
11411131
}
11421132
}
1143-
handle_assignment(asgn, a, result, Iit, lvsa);
1133+
handle_assignment(asgn, a, input, result, Iit, lvsa);
11441134
}
11451135
break;
11461136
case FUNCTION_CALL:
@@ -1230,6 +1220,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
12301220
propagation_rule.get_input_location().arg_index),
12311221
Iit,
12321222
lvsa,
1223+
input,
12331224
a))
12341225
: propagation_rule.apply();
12351226

@@ -1362,13 +1353,15 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
13621353
sink_rule.get_input_location().arg_index),
13631354
Iit,
13641355
lvsa,
1356+
input,
13651357
a)
13661358
: taint_sett{},
13671359
compute_taint_of_aliased_numbers_of_lvalue(
13681360
fn_call.arguments().at(
13691361
sink_rule.get_sink_target_location().arg_index),
13701362
Iit,
13711363
lvsa,
1364+
input,
13721365
a),
13731366
sink_conditions);
13741367

@@ -1449,6 +1442,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
14491442
handle_assignment(
14501443
fake_assignment,
14511444
a,
1445+
input,
14521446
result,
14531447
Iit,
14541448
lvsa);
@@ -1708,6 +1702,7 @@ void taint_algorithm_computing_summary_of_functiont::
17081702
src_value,
17091703
src_instr_it,
17101704
function_id,
1705+
summary->input,
17111706
database,
17121707
lvsa,
17131708
summary->transition_props);

src/taint-analysis/taint_summary.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class taint_algorithm_computing_summary_of_functiont
254254
void handle_assignment(
255255
const code_assignt& asgn,
256256
numbered_lvalue_to_taint_mapt const& a,
257+
const taint_summary_inputt &input,
257258
numbered_lvalue_to_taint_mapt& result,
258259
instruction_iteratort const& Iit,
259260
local_value_set_analysist &lvsa);
@@ -262,6 +263,7 @@ class taint_algorithm_computing_summary_of_functiont
262263
const taint_lvaluet &lvalue,
263264
const instruction_iteratort &Iit,
264265
local_value_set_analysist &lvsa,
266+
const taint_summary_inputt &input,
265267
const numbered_lvalue_to_taint_mapt &a);
266268

267269
void apply_taint_to_aliased_numbers_of_lvalue(
@@ -276,6 +278,7 @@ class taint_algorithm_computing_summary_of_functiont
276278
const numbered_lvalue_to_taint_mapt &a,
277279
const instruction_iteratort &Iit,
278280
const irep_idt &caller_ident,
281+
const taint_summary_inputt &input,
279282
taint_summaryt::dbt &database,
280283
local_value_set_analysist &lvsa,
281284
taint_transition_propertiest &transition_properties);

0 commit comments

Comments
 (0)