Sharing logs or activity records often risks exposing private information because the data contains sensitive details mixed with useful progress updates. It is difficult to share these logs without manually scrubbing every piece of private data.
It looks at a series of changes and filters out specific private fields while keeping the rest of the timeline intact. It produces a clean version of the activity history that hides sensitive details.
It allows for sharing progress logs without exposing private information.
It was run in the sandbox and it failed. run produced no meaningful output (empty or near-empty).
$ python3 tool.py
Traceback (most recent call last):
File "/work/trace_anonymizer.py", line 60, in <module>
output_file = open('output.json', 'w')
^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: 'output.json'No screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.
All of it — 47 lines, one file, standard library only.
import sys
import json
SENSITIVE_FIELDS = ['email', 'phone', 'ssn', 'user.address.zip', 'user.phone']
def anonymize_data(data, sensitive_paths):
for path in sensitive_paths:
parts = path.split('.')
current = data
for i, part in enumerate(parts):
if isinstance(current, dict) and part in current:
if i == len(parts) - 1:
current[part] = 'ANONYMIZED'
else:
current = current[part]
else:
break
return data
state = {}
output_file = open('/tmp/output.json', 'w')
for line in sys.stdin:
try:
event = json.loads(line.strip())
except json.JSONDecodeError:
print("Invalid JSON in input", file=sys.stderr)
continue
entity_id = event.get('id')
timestamp = event.get('timestamp')
changes = event.get('changes', {})
if not entity_id or not timestamp:
print("Event missing 'id' or 'timestamp'", file=sys.stderr)
continue
previous_state = state.get(entity_id, {})
new_state = previous_state.copy()
new_state.update(changes)
state[entity_id] = new_state
delta = {field: changes[field] for field in changes if changes[field] != previous_state.get(field)}
anonymized_delta = anonymize_data(delta.copy(), SENSITIVE_FIELDS)
output_file.write(json.dumps({
'entity_id': entity_id,
'timestamp': timestamp,
'anonymized_delta': anonymized_delta
}) + "\n")
output_file.close()