forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tombstone_redaction.py
More file actions
59 lines (52 loc) 路 1.65 KB
/
Copy pathtest_tombstone_redaction.py
File metadata and controls
59 lines (52 loc) 路 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
import unittest
from pathlib import Path
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT / "scripts"))
from tombstone_to_draft import redact_snippet
class TestTombstoneRedaction(unittest.TestCase):
def test_redacts_sensitive_snippets(self):
cases = [
(
"github token",
"ghp_abcdefghijklmnopqrstuvwxyzABCDEFGHIJ",
"[REDACTED_GITHUB_TOKEN]",
),
(
"bearer token",
"Bearer abcdefghijklmnopqrstuvwxyz1234567890",
"Bearer [REDACTED]",
),
(
"email address",
"developer@example.internal",
"[REDACTED_EMAIL]",
),
(
"windows path",
r"C:\Users\alice\project\secret.txt",
"[REDACTED_PATH]",
),
(
"linux path",
"/home/alice/project/secret.txt",
"[REDACTED_PATH]",
),
(
"192.168 internal ip",
"192.168.10.25",
"[REDACTED_IP]",
),
(
"10.x internal ip",
"10.42.0.7",
"[REDACTED_IP]",
),
]
for name, sensitive_value, expected_marker in cases:
with self.subTest(name=name):
redacted = redact_snippet(f"crash detail: {sensitive_value}")
self.assertNotIn(sensitive_value, redacted)
self.assertIn(expected_marker, redacted)
if __name__ == "__main__":
unittest.main()