Skip to content

Commit 4e29073

Browse files
authored
Update Latin-1 detection with allowed 0x1B symbol (#802)
* ESC code may be latin-1 too * Update CredSweeper banner check in workflow
1 parent eb4fe49 commit 4e29073

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
run: |
9393
banner="$(python -m credsweeper --banner | head -1)"
9494
echo "banner = '${banner}'"
95-
if [ "CredSweeper 1.14.2 crc32:a2e9bad4" != "${banner}" ]; then
95+
if [ "CredSweeper 1.14.2 crc32:4b184311" != "${banner}" ]; then
9696
echo "Update the check for '${banner}'"
9797
exit 1
9898
fi

credsweeper/utils/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def is_binary(data: Union[bytes, bytearray]) -> bool:
153153

154154
NOT_LATIN1_PRINTABLE_SET = set(range(0, 256)) \
155155
.difference(set(x for x in string.printable.encode(ASCII))) \
156+
.difference({0x1B}) \
156157
.difference(set(x for x in range(0xA0, 0x100)))
157158

158159
@staticmethod

tests/utils/test_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ def test_is_latin1_p(self):
406406
self.assertTrue(Util.is_latin1((self.DEUTSCH_PANGRAM + '\0').encode(UTF_8)))
407407
# obsolete encoding may be recognized as Latin1
408408
self.assertTrue(Util.is_latin1(self.KOREAN_PANGRAM.encode("euc_kr")))
409+
# 0x1B ESCAPE code in log
410+
self.assertTrue(Util.is_latin1(b"PASSWORD=2IWJD88FH4Y;"))
409411

410412
def test_is_ascii_entropy_validate_p(self):
411413
self.assertTrue(Util.is_ascii_entropy_validate(b''))

0 commit comments

Comments
 (0)