|
| 1 | +For future version 4n2 |
| 2 | + |
| 3 | +``` |
| 4 | +[6] Pred=0.000 → Private SSH key |
| 5 | +[18] Pred=0.000 → Private RSA key |
| 6 | +[30] Pred=0.003 → Credit card expiration |
| 7 | +[32] Pred=0.000 → Encrypted password hash |
| 8 | +[38] Pred=0.000 → Date of birth |
| 9 | +[39] Pred=0.000 → Secret question answer |
| 10 | +[44] Pred=0.000 → Private notes |
| 11 | +[47] Pred=0.004 → Encrypted token |
| 12 | +``` |
| 13 | + |
| 14 | +Do include these in future version 4n2 |
| 15 | + |
| 16 | +Example code for generating sensitive data using the Faker library in Python: |
| 17 | +```python |
| 18 | +import random |
| 19 | +import base64 |
| 20 | +from faker import Faker |
| 21 | + |
| 22 | +class DataGenerator: |
| 23 | + def __init__(self, cfg): |
| 24 | + self.cfg = cfg |
| 25 | + self.faker = Faker() |
| 26 | + |
| 27 | + def sensitive_text(self): |
| 28 | + field = random.choice(self.cfg.SENSITIVE_FIELDS) |
| 29 | + |
| 30 | + if field == "ssn": |
| 31 | + return f"SSN: {self.faker.ssn()}" |
| 32 | + |
| 33 | + elif field == "credit_card": |
| 34 | + number = self.faker.credit_card_number() |
| 35 | + exp = self.faker.credit_card_expire() |
| 36 | + cvv = self.faker.random_int(min=100, max=999) |
| 37 | + return f"Credit Card: {number} Exp: {exp} CVV: {cvv}" |
| 38 | + |
| 39 | + elif field == "email": |
| 40 | + return f"Email: {self.faker.email()}" |
| 41 | + |
| 42 | + elif field == "phone_number": |
| 43 | + return f"Phone: {self.faker.phone_number()}" |
| 44 | + |
| 45 | + elif field == "address": |
| 46 | + return f"Address: {self.faker.address().replace(chr(10), ', ')}" |
| 47 | + |
| 48 | + elif field == "name": |
| 49 | + return f"Name: {self.faker.name()}" |
| 50 | + |
| 51 | + elif field == "password": |
| 52 | + return f"Password: {self.faker.password(length=12, special_chars=True)}" |
| 53 | + |
| 54 | + elif field == "private_key": |
| 55 | + # Simulate a realistic RSA private key |
| 56 | + lines = [base64.b64encode(self.faker.binary(length=32)).decode('ascii') for _ in range(10)] |
| 57 | + key_body = "\n".join(lines) |
| 58 | + return f"Private key: -----BEGIN RSA PRIVATE KEY-----\n{key_body}\n-----END RSA PRIVATE KEY-----" |
| 59 | + |
| 60 | + elif field == "ssh_key": |
| 61 | + # Simulate realistic OpenSSH private key |
| 62 | + lines = [base64.b64encode(self.faker.binary(length=32)).decode('ascii') for _ in range(8)] |
| 63 | + key_body = "\n".join(lines) |
| 64 | + return f"Private SSH key: -----BEGIN OPENSSH PRIVATE KEY-----\n{key_body}\n-----END OPENSSH PRIVATE KEY-----" |
| 65 | + |
| 66 | + elif field == "api_key": |
| 67 | + return f"API Key: {self.faker.sha256()[:32]}" |
| 68 | + |
| 69 | + elif field == "pin": |
| 70 | + return f"PIN: {self.faker.random_int(min=1000, max=9999)}" |
| 71 | + |
| 72 | + elif field == "dob": |
| 73 | + return f"DOB: {self.faker.date_of_birth(minimum_age=18, maximum_age=90)}" |
| 74 | + |
| 75 | + elif field == "security_answer": |
| 76 | + return f"Security Answer: {self.faker.word()}" |
| 77 | + |
| 78 | + elif field == "jwt_token": |
| 79 | + header = base64.urlsafe_b64encode(b'{"alg":"HS256","typ":"JWT"}').decode('utf-8').rstrip("=") |
| 80 | + payload = base64.urlsafe_b64encode(self.faker.json().encode()).decode('utf-8').rstrip("=") |
| 81 | + signature = base64.urlsafe_b64encode(self.faker.binary(length=16)).decode('utf-8').rstrip("=") |
| 82 | + return f"JWT: {header}.{payload}.{signature}" |
| 83 | + |
| 84 | + return "Sensitive info: [REDACTED]" |
| 85 | +``` |
0 commit comments