Skip to content

Instantly share code, notes, and snippets.

@burnsie7
Last active June 10, 2019 02:35
Show Gist options
  • Save burnsie7/5bb0e213ff7b4e9a20afe4958555e575 to your computer and use it in GitHub Desktop.
Save burnsie7/5bb0e213ff7b4e9a20afe4958555e575 to your computer and use it in GitHub Desktop.
generate logs w/ pii
import time
import json
from faker import Factory
fake = Factory.create()
start_time = time.time() + 900
while time.time() < start_time:
p = fake.profile()
p.pop('website')
p.pop('current_location')
s = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(time.time())) + ' - INFO - '
new_dict = {}
for k, v in p.items():
new_k = str(k).replace('\n', ' ')
new_v = str(v).replace('\n', ' ')
new_dict[new_k] = new_v
j = json.dumps(new_dict)
s += j
s += '\n'
w = open('/home/vagrant/logs/demo/demo.log',"a+")
w.write(s)
w.close()
time.sleep(0.5)
# Global processing rules that are applied to all the logs. The available rules are
# "exclude_at_match", "include_at_match" and "mask_sequences".
# processing_rules:
# - type: exclude_at_match
# name: exclude_sensitive_info
# pattern: \w*sensitive\-info*\w
# - type: mask_sequences
# name: social_security_number
# pattern: (\d{3}-?\d{2}-?\d{4})
# replace_placeholder: "XXX-XX-XXXX"
# - type: mask_sequences
# name: mask_credit_card
# pattern: (?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})
# replace_placeholder: "[Credit Card Number]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment