Skip to content

Commit a0f4421

Browse files
authored
Merge pull request diffblue#283 from diffblue/marek/taint_summaries_of_all_functions
SEC-142: Compute taint summaries for functions that have taint rules
2 parents 32a45ae + b9a4cd4 commit a0f4421

File tree

5 files changed

+14
-46
lines changed

5 files changed

+14
-46
lines changed

regression/end_to_end/tainted-string-type-concat/test_tainted_string_type_concat.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import regression.end_to_end.driver as pipeline_executor
22
import os.path
3-
import pytest
43
import subprocess
54
import regression.utils as utils
65

76

8-
@pytest.mark.xfail
97
def test_taint_crossing_substr_and_concatenation():
108
with utils.working_dir(os.path.abspath(os.path.dirname(__file__))):
119
subprocess.call("ant")

src/summaries/summary_dump.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,29 +1025,6 @@ void dump_irept(const irept &irep, std::ostream &ostr, const std::string &shift)
10251025
}
10261026

10271027

1028-
bool skip_fn_summary(const std::string &fname)
1029-
{
1030-
if (fname.find("java::sun.") == 0UL
1031-
|| fname.find("java::com.oracle.") == 0UL
1032-
|| fname.find("java::com.sun.") == 0UL
1033-
|| fname.find("java::java.") == 0UL
1034-
|| fname.find("java::javax.") == 0UL
1035-
|| fname.find("java::org.ietf.") == 0UL
1036-
|| fname.find("java::org.jpc.") == 0UL
1037-
|| fname.find("java::org.omg.") == 0UL
1038-
|| fname.find("java::org.w3c.") == 0UL
1039-
|| fname.find("java::org.xml.") == 0UL
1040-
|| fname.find("java::jdk.") == 0UL
1041-
|| fname.find("java::org.apache.") == 0UL
1042-
|| fname.find("java::org.springframework.") == 0UL
1043-
|| fname.find("java::org.json.") == 0UL
1044-
|| fname.find("java::junit.") == 0UL
1045-
)
1046-
return true;
1047-
return false;
1048-
}
1049-
1050-
10511028
std::string to_file_name(std::string file_name, std::size_t suffix_length)
10521029
{
10531030
// The maximum file name length is 255 on most Linux file systems

src/summaries/summary_dump.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ void dump_instruction_code_in_html(
101101
);
102102

103103
std::string to_file_name(std::string file_name, std::size_t suffix_length=15);
104-
bool skip_fn_summary(const std::string &fname);
105104

106105

107106
/// Functions to dump summaries to HTML.
@@ -152,8 +151,6 @@ class summary_dumpt:public messaget
152151
for(const std::pair<irep_idt, std::shared_ptr<summary_typet>> &summary
153152
: computed_summaries)
154153
{
155-
if(skip_fn_summary(id2string(summary.first)))
156-
continue;
157154
dump_in_html(
158155
summary.first,
159156
*summary.second,
@@ -182,8 +179,6 @@ class summary_dumpt:public messaget
182179
" </tr>\n";
183180
for(const irep_idt &id : computed_summaries.keys())
184181
{
185-
if(skip_fn_summary(id2string(id)))
186-
continue;
187182
ostr
188183
<< " <tr>\n"
189184
" <td>" << to_html_text(id2string(id)) << "</td>\n"

src/taint-analysis/taint_summary.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,17 @@ void taint_algorithm_computing_summary_of_functiont::initialise_domain(
702702
const auto &fn_type=
703703
program->get_functions().function_map.at(callee_id).type;
704704

705-
if(!database.contains(callee_id))
705+
if(!database.contains(callee_id) || transition_rules->has_rule(callee_id))
706706
{
707-
// Normally should have already processed called functions as we
708-
// follow an inverted topological ordering
709-
// This callee must recursively call us
707+
// This is either a recursive function or a function for which we have
708+
// a rule (any function not in the database has not been processed and
709+
// since we're following an inverted topological ordering it therefore
710+
// must recursively call us)
711+
// If we don't have a summary then we assume that the function could
712+
// use any of its arguments. If the function has a rule then it
713+
// probably will use some of its arguments.
714+
// In the future we could be more precise about exactly which arguments
715+
// are used in the rule.
710716
for(const auto &arg : fn_call.arguments())
711717
{
712718
collect_lvsa_access_paths(
@@ -717,8 +723,10 @@ void taint_algorithm_computing_summary_of_functiont::initialise_domain(
717723
it,
718724
*numbering);
719725
}
720-
continue;
726+
if(!database.contains(callee_id))
727+
continue;
721728
}
729+
722730
const std::shared_ptr<taint_summaryt> summary = database.at(callee_id);
723731
for(const std::pair<taint_lvalue_numbert, taint_variablet>& input
724732
: summary->input)
@@ -1499,7 +1507,6 @@ void taint_algorithm_computing_summary_of_functiont::
14991507
void taint_algorithm_computing_summary_of_functiont::
15001508
taint_summarise_function(
15011509
const irep_idt &function_id,
1502-
bool function_has_taint_rule,
15031510
taint_summaryt::dbt &database,
15041511
local_value_set_analysist::dbt &lvsa_db)
15051512
{
@@ -1539,11 +1546,6 @@ void taint_algorithm_computing_summary_of_functiont::
15391546
lvsa.nstubs,
15401547
lvsa.nstub_assignments);
15411548

1542-
// No need to analyse the internal taint flow of functions that have
1543-
// a taint axiom (source, sink or sanitizer) associated with them:
1544-
if(function_has_taint_rule)
1545-
return;
1546-
15471549
if(database.contains(function_id))
15481550
// Already been pre-computed
15491551
return;
@@ -1700,7 +1702,6 @@ void taint_summarise_all_functions(
17001702
const goto_functionst::function_mapt &functions_map =
17011703
program->get_functions().function_map;
17021704
const auto fn_it = functions_map.find(fn_name);
1703-
bool has_rule = transition_rules->has_rule(fn_name);
17041705
if(fn_it!=functions_map.cend() && fn_it->second.body_available()
17051706
&& fn_name!="_start")
17061707
{
@@ -1723,7 +1724,6 @@ void taint_summarise_all_functions(
17231724
log);
17241725
summariser.taint_summarise_function(
17251726
fn_name,
1726-
has_rule,
17271727
summaries_to_compute,
17281728
lvsa_db);
17291729
++processed;
@@ -1738,8 +1738,7 @@ void taint_summarise_all_functions(
17381738
(double)topological_order_size)
17391739
<< "%] Skipping"
17401740
<< (fn_it!=functions_map.cend() && !fn_it->second.body_available()
1741-
? " [function without a body]"
1742-
: has_rule ? " [function call representing a transition rule]" : "")
1741+
? " [function without a body]" : "")
17431742
<< ": "
17441743
<< fn_name
17451744
<< messaget::eom;

src/taint-analysis/taint_summary.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class taint_algorithm_computing_summary_of_functiont
189189

190190
void taint_summarise_function(
191191
const irep_idt &function_id,
192-
bool function_has_taint_rule,
193192
taint_summaryt::dbt &database,
194193
local_value_set_analysist::dbt &lvsa_db);
195194

0 commit comments

Comments
 (0)