diff options
author | Michael Weiser <michael.weiser@gmx.de> | 2019-04-08 13:58:32 +0000 |
---|---|---|
committer | Michael Weiser <michael.weiser@gmx.de> | 2019-04-08 13:58:32 +0000 |
commit | b1148823a6365c89fae6f3077a33275c2fdc6fa1 (patch) | |
tree | 5158a8eafe024eb9fa4c150bf554453e7237c148 /peekaboo/ruleset/rules.py | |
parent | aaf0e1ae4b6e10398530affc95d3d9305e38f39a (diff) |
Avoid the str() constructor
Do not force string representations of stuff using the str() constructor
because in almost all cases it is unnecessary and can cause funky
encoding problems, most notably the notorious:
UnicodeEncodeError: 'ascii' codec can't encode character '\ua000' in
position 0: ordinal not in range(128)
Instead, rely on python to convert the input object to the required
target type, oblivious of the actual type until we do input/output.
Diffstat (limited to 'peekaboo/ruleset/rules.py')
-rw-r--r-- | peekaboo/ruleset/rules.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/peekaboo/ruleset/rules.py b/peekaboo/ruleset/rules.py index f112a70..e7eff77 100644 --- a/peekaboo/ruleset/rules.py +++ b/peekaboo/ruleset/rules.py @@ -159,7 +159,7 @@ class FileTypeOnGreylistRule(Rule): return self.result(Result.unknown, _("File type is not on the list of types to " - "analyse (%s)") % (str(sample.mimetypes)), + "analyse (%s)") % sample.mimetypes, False) @@ -248,7 +248,7 @@ class CuckooEvilSigRule(CuckooRule): # check if there is a "bad" signatures and return bad matched_bad_sigs = [] for sig in bad_sigs: - match = re.search(sig, str(sigs)) + match = re.search(sig, "\n".join(sigs)) if match: matched_bad_sigs.append(sig) |