Skip to content

Commit

Permalink
Add additional known obscured subjects from k-9/thunderbird-android.
Browse files Browse the repository at this point in the history
These additional subjects were extracted from the thunderbird-android
source (which is inherited from k-9).

The extraction was done with:

```
git clone https://github.com/thunderbird/thunderbird-android/
cd thunderbird-android/legacy/ui/legacy/src/main/res
grep string\ name=\"encrypted_subject values-*/strings.xml | cut -f2 -d'>' | cut -f1 -d'<' | sort -u | sed -e 's/^/    "/' -e 's/$/",/'
```

(i did need to clean up one line's escaping to pass the linter's
expectations)

See also thunderbird/thunderbird-android#8011
  • Loading branch information
dkg authored and hpk42 committed Jul 17, 2024
1 parent e8bf051 commit c132957
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
60 changes: 59 additions & 1 deletion chatmaild/src/chatmaild/filtermail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,64 @@

from .config import read_config

"""Generated from deltachat, draft-ietf-lamps-header-protection, and
encrypted_subject localizations in
https://github.com/thunderbird/thunderbird-android/
"""
common_encrypted_subjects = {
"...",
"[...]",
"암호화된 메시지",
"Ĉifrita mesaĝo",
"Courriel chiffré",
"Dulrituð skilaboð",
"Encrypted Message",
"Fersifere berjocht",
"Kemennadenn enrineget",
"Krüptitud kiri",
"Krypterat meddelande",
"Krypteret besked",
"Kryptert melding",
"Mensagem criptografada",
"Mensagem encriptada",
"Mensaje cifrado",
"Mensaxe cifrada",
"Mesaj Criptat",
"Mesazh i Fshehtëzuar",
"Messaggio criptato",
"Messaghju cifratu",
"Missatge encriptat",
"Neges wedi'i Hamgryptio",
"Pesan terenkripsi",
"Salattu viesti",
"Şifreli İleti",
"Šifrēta ziņa",
"Šifrirana poruka",
"Šifrirano sporočilo",
"Šifruotas laiškas",
"Tin nhắn được mã hóa",
"Titkosított üzenet",
"Verschlüsselte Nachricht",
"Versleuteld bericht",
"Zašifrovaná zpráva",
"Zaszyfrowana wiadomość",
"Zifratu mezua",
"Κρυπτογραφημένο μήνυμα",
"Зашифроване повідомлення",
"Зашифрованное сообщение",
"Зашыфраваны ліст",
"Криптирано съобщение",
"Шифрована порука",
"დაშიფრული წერილი",
"הודעה מוצפנת",
"پیام رمزنگاری‌شده",
"رسالة مشفّرة",
"എൻക്രിപ്റ്റുചെയ്‌ത സന്ദേശം",
"加密邮件",
"已加密的訊息",
"暗号化されたメッセージ",
}


def check_openpgp_payload(payload: bytes):
"""Checks the OpenPGP payload.
Expand Down Expand Up @@ -111,7 +169,7 @@ def check_encrypted(message):
"""
if not message.is_multipart():
return False
if message.get("subject") not in {"...", "[...]"}:
if message.get("subject") not in common_encrypted_subjects:
return False
if message.get_content_type() != "multipart/encrypted":
return False
Expand Down
3 changes: 2 additions & 1 deletion chatmaild/src/chatmaild/tests/test_filtermail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
SendRateLimiter,
check_armored_payload,
check_encrypted,
common_encrypted_subjects,
)


Expand Down Expand Up @@ -54,7 +55,7 @@ def test_filtermail_no_encryption_detection(maildata):


def test_filtermail_encryption_detection(maildata):
for subject in ("...", "[...]"):
for subject in common_encrypted_subjects:
msg = maildata(
"encrypted.eml",
from_addr="1@example.org",
Expand Down

0 comments on commit c132957

Please sign in to comment.