tests/test_hygiene.py — Message History Reader for iMessage and SMS

From version 0.1.1 of Message History Reader for iMessage and SMS, shown publicly by its creator. 3.8 KiB · SHA-256 1d1030b745eaecfb5ba317c54a4844c648f878c596028ee1f6640bae9aa40ce8.

#!/usr/bin/env python3
# Publication and privacy checks for the shipped package.
# By Zero Width Lab (zerowidthlab.com)
from __future__ import annotations

import ast
import re
import unittest
from pathlib import Path

__author__ = "Zero Width Lab"
ROOT = Path(__file__).resolve().parents[1]
SIGNATURE = "By Zero Width Lab (zerowidthlab.com)"
SHIPPED = [
    "SKILL.md", "README.md", "SETUP.md", "LICENSE.txt",
    "agents/message-history-reader-agent.md", "references/messages-schema.md",
    "scripts/message_history_reader.py", "tests/test_message_history_reader.py",
    "tests/test_hygiene.py", "source-package.json",
]


class HygieneTests(unittest.TestCase):
    def test_release_license_and_version(self) -> None:
        self.assertIn("license: MIT\n", (ROOT / "SKILL.md").read_text())
        license_text = (ROOT / "LICENSE.txt").read_text()
        self.assertTrue(license_text.startswith("MIT License\n"))
        self.assertIn("Copyright (c) 2026 Zero Width Lab", license_text)
        self.assertIn("Permission is hereby granted, free of charge", license_text)
        self.assertIn("version 0.1.1.", (ROOT / "scripts/message_history_reader.py").read_text())

    def test_forbidden_constructs(self) -> None:
        forbidden = {"ev" + "al", "ex" + "ec", "com" + "pile", "os.sy" + "stem", "re.com" + "pile"}
        for relative in SHIPPED:
            if not relative.endswith(".py"):
                continue
            tree = ast.parse((ROOT / relative).read_text())
            for node in ast.walk(tree):
                if isinstance(node, ast.Call):
                    function = node.func
                    name = function.id if isinstance(function, ast.Name) else ""
                    if isinstance(function, ast.Attribute) and isinstance(function.value, ast.Name):
                        name = function.value.id + "." + function.attr
                    self.assertNotIn(name, forbidden)
                    self.assertFalse(any(keyword.arg == "shell" and isinstance(keyword.value, ast.Constant) and keyword.value.value for keyword in node.keywords))
                if isinstance(node, (ast.Import, ast.ImportFrom)):
                    modules = [alias.name for alias in node.names] if isinstance(node, ast.Import) else [node.module or ""]
                    self.assertFalse(any(module.split(".")[0] in {"pic" + "kle", "c" + "types"} for module in modules))

    def test_shipped_text_and_signatures(self) -> None:
        forbidden_names = ["Open" + "AI", "Anth" + "ropic", "Chat" + "G" + "PT",
                           "Gem" + "ini", "Clau" + "de", "Co" + "dex",
                           "Co" + "pilot", "Son" + "net", "Op" + "us"]
        token_name = "G" + "PT"
        for relative in SHIPPED:
            with self.subTest(path=relative):
                content = (ROOT / relative).read_text(encoding="utf-8")
                self.assertNotRegex(content, r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
                self.assertNotRegex(content, r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
                self.assertNotRegex(content, r"[A-Za-z0-9.-]+\.onmicrosoft\.com")
                self.assertNotRegex(content, r"/(?:Users|home)/[A-Za-z0-9._-]+")
                for character in content:
                    self.assertFalse(ord(character) in {0x200B, 0x200C, 0x200D, 0xFEFF, 0x2060})
                for name in forbidden_names:
                    self.assertNotIn(name.casefold(), content.casefold())
                self.assertIsNone(re.search(r"\b" + token_name + r"\b", content))
                if relative.endswith(".md"):
                    self.assertEqual(content.rstrip().splitlines()[-1], SIGNATURE)
                if relative.endswith(".py"):
                    self.assertIn("# " + SIGNATURE, "\n".join(content.splitlines()[:5]))


if __name__ == "__main__":
    unittest.main()

License: MIT (read it).

MITMIT License

Copyright (c) 2026 Zero Width Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Back to the listing