Yelp / fuzz-lightyear

A pytest-inspired, DAST framework, capable of identifying vulnerabilities in a distributed, micro-service ecosystem through chaos engineering testing and stateful, Swagger fuzzing.
Other
205 stars 25 forks source link

Disable color printing when not printing to terminal #51

Closed domanchi closed 4 years ago

domanchi commented 4 years ago

Summary

ANSI colorization is only good if the output is to a terminal. When it goes into a file instead, the ANSI color codes makes it hard to read. This fixes that.

Testing

Manual testing.

Before Change:

$ make vulnerable_app
$ fuzz-lightyear http://localhost:5000/schema -f test_data > output.fuzz
$ vim output.fuzz
^[[1m======================= fuzzing session starts =======================^[[0m
Hypothesis Seed: 45681616869573565430211526758451148904

basic ^[[92m.^[[0m^[[91mE^[[0m^[[91mE^[[0m

After Change:

$ make vulnerable_app
$ fuzz-lightyear http://localhost:5000/schema -f test_data > output.fuzz
$ vim output.fuzz
======================= fuzzing session starts =======================
Hypothesis Seed: 242999052542582450454317716917191761814

basic .EE

Notes

We could probably create a flag --no-color to manually enable this, but YAGNI for now.