Skip to content

Commit 298bd26

Browse files
authored
Merge pull request diffblue#370 from diffblue/bugfix/save_DOT_and_SVG_of_tokens_propagation_graph_on_right_conditions
Saving DOT file of tokens propagation graph always, and SVG only with debug HTML dump.
2 parents fbd9318 + d5efc28 commit 298bd26

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

src/taint-analysis/taint_security_scanner.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ bool taint_do_security_scan(
9191
tokens_propagation_graph_ptr=
9292
std::unique_ptr<taint_tokens_propagation_grapht>(
9393
new taint_tokens_propagation_grapht(*transition_rules, named_tokens));
94+
{
95+
std::fstream ostr(
96+
(boost::filesystem::path(config.get_slicer_root_directory()) /
97+
"tokens_propagation_graph.dot").native(),
98+
std::ios_base::out);
99+
taint_to_dot(*tokens_propagation_graph_ptr, ostr);
100+
}
94101
}
95102

96103
object_numberingt numbering;
@@ -191,7 +198,11 @@ bool taint_do_security_scan(
191198
const boost::filesystem::path results_dir =
192199
config.get_slicer_root_directory();
193200

194-
const auto ignore = std::system(
201+
logger.status()
202+
<< "Saving propagation chains graph (see '"
203+
<< results_dir / "propagation_chains.svg"
204+
<< "')." << messaget::eom;
205+
auto ignore = std::system(
195206
(std::string("dot -Tsvg \"") +
196207
(results_dir / "propagation_chains.dot").native() + "\" -o \"" +
197208
(results_dir / "propagation_chains.svg").native() + "\"")
@@ -208,9 +219,15 @@ bool taint_do_security_scan(
208219
<< "Saving tokens propagation graph (see '"
209220
<< svg_path
210221
<< "')." << messaget::eom;
211-
taint_dump_as_svg(
212-
*tokens_propagation_graph_ptr,
213-
svg_path);
222+
ignore = std::system(
223+
(std::string("dot -Tsvg \"") +
224+
(results_dir / "tokens_propagation_graph.dot").native() + "\" -o \"" +
225+
(results_dir / "tokens_propagation_graph.svg").native() + "\"")
226+
.c_str());
227+
(void)ignore; // We do not care about the return value, because
228+
// if the call fails, then the link to the SVG
229+
// image in the debug HTML output won't work.
230+
// That is all.
214231

215232
logger.status() << "Saving call graph." << messaget::eom;
216233
dump_callgraph_in_svg(

src/taint-analysis/taint_tokens_propagation_graph.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -292,26 +292,3 @@ std::ostream &taint_to_dot(
292292

293293
return ostr;
294294
}
295-
296-
void taint_dump_as_svg(
297-
const taint_tokens_propagation_grapht &graph,
298-
std::string const& svg_file_pathname)
299-
{
300-
const std::string dot_filename=
301-
boost::filesystem::path(svg_file_pathname).replace_extension("dot")
302-
.native();
303-
{
304-
std::fstream ostr(dot_filename, std::ios_base::out);
305-
if(!ostr.is_open())
306-
return;
307-
taint_to_dot(graph, ostr);
308-
}
309-
310-
const std::string command =
311-
msgstream() << "dot -Tsvg \"" << dot_filename
312-
<< "\" -o \"" << svg_file_pathname << "\"";
313-
const auto result=std::system(command.c_str());
314-
if(result!=0)
315-
std::cerr << "ERROR in 'taint_dump_as_svg()' : std::system(" << command
316-
<< ") returned value " << result << ".";
317-
}

src/taint-analysis/taint_tokens_propagation_graph.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,4 @@ std::ostream &taint_to_dot(
131131
const taint_tokens_propagation_grapht &graph,
132132
std::ostream &ostr);
133133

134-
void taint_dump_as_svg(
135-
const taint_tokens_propagation_grapht &graph,
136-
std::string const& svg_file_pathname);
137-
138134
#endif

0 commit comments

Comments
 (0)