Skip to content

Commit e7fd0e9

Browse files
authored
Merge pull request diffblue#361 from diffblue/conditional_dump_of_svg_of_propagation_chains
Building SVG of the propagation chains graph only if HTML dump is on.
2 parents 9faec92 + f33dcda commit e7fd0e9

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

src/taint-analysis/taint_security_scanner.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ bool taint_do_security_scan(
190190
{
191191
const boost::filesystem::path results_dir =
192192
config.get_slicer_root_directory();
193+
194+
const auto ignore = std::system(
195+
(std::string("dot -Tsvg \"") +
196+
(results_dir / "propagation_chains.dot").native() + "\" -o \"" +
197+
(results_dir / "propagation_chains.svg").native() + "\"")
198+
.c_str());
199+
(void)ignore; // We do not care about the return value, because
200+
// if the call fails, then the link to the SVG
201+
// image in the debug HTML output won't work.
202+
// That is all.
203+
193204
const std::string svg_path =
194205
(results_dir / "tokens_propagation_graph.svg").native();
195206

src/taint-slicer/propagation_chains.cpp

+6-17
Original file line numberDiff line numberDiff line change
@@ -500,25 +500,14 @@ std::ostream &to_dot(
500500
return ostr;
501501
}
502502

503-
void dump_as_svg(
503+
void to_dot(
504504
const taint_propagation_chainst &chains,
505-
const std::string &svg_file_pathname)
505+
const std::string &dot_file_pathname)
506506
{
507-
std::string const dot_filename =
508-
boost::filesystem::path(svg_file_pathname).replace_extension("dot")
509-
.native();
510-
{
511-
std::fstream ostr(dot_filename, std::ios_base::out);
512-
if (!ostr.is_open())
513-
return;
514-
to_dot(chains,ostr);
515-
}
516-
517-
std::string const command =
518-
msgstream() << "dot -Tsvg \"" << dot_filename
519-
<< "\" -o \"" << svg_file_pathname << "\"";
520-
const auto x=std::system(command.c_str());
521-
(void)x;
507+
std::fstream ostr(dot_file_pathname, std::ios_base::out);
508+
if(!ostr.is_open())
509+
return;
510+
to_dot(chains, ostr);
522511
}
523512

524513
std::ostream &operator<<(std::ostream &ostr, const argidx_and_tokennamet &atp)

src/taint-slicer/propagation_chains.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ std::ostream &to_dot(
263263
const taint_propagation_chainst &chains,
264264
std::ostream &ostr);
265265

266-
void dump_as_svg(
266+
void to_dot(
267267
const taint_propagation_chainst &chains,
268-
const std::string &svg_file_pathname);
268+
const std::string &dot_file_pathname);
269269

270270
#endif

src/taint-slicer/slicer.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ void taint_slicert::compute_slice(
7373
map_from_functions_to_rule_application_sites,
7474
statistics);
7575

76-
dump_as_svg(
77-
propagation_chains,
78-
(results_dir / "propagation_chains.svg").native());
76+
to_dot(propagation_chains, (results_dir / "propagation_chains.dot").native());
7977

8078
std::vector<taint_instrumentation_propst> instrumentation_props;
8179
taint_build_instrumentation_props(

0 commit comments

Comments
 (0)