Don't attempt to decode output from Suricata stderr/stdout as utf-8, it
is required for relaying the output from Suricata to the log files,
in fact, its not even desired. The log files should have a verbatim
copy of the output for analysis.
Only attempt to utf-8 decode the output when logging in verbose mode,
and then if that fails, fallback to logging the data as a byte buffer.
def pipe_reader(fileobj, output=None, verbose=False):
for line in fileobj:
- line = line.decode()
if output:
output.write(line)
output.flush()
if verbose:
- print(line.strip())
+ try:
+ line = line.decode().strip()
+ except:
+ pass
+ print(line)
def handle_exceptions(func):
os.makedirs(self.output)
self.setup()
- stdout = open(os.path.join(self.output, "stdout"), "w")
- stderr = open(os.path.join(self.output, "stderr"), "w")
+ stdout = open(os.path.join(self.output, "stdout"), "wb")
+ stderr = open(os.path.join(self.output, "stderr"), "wb")
if shell:
template = string.Template(args)