#!/usr/bin/env python3 # SOF-ELKĀ® Supporting script # (C)2025 Lewes Technology Consulting, LLC # Updated Jan 2025 by GH user @za to refactor into a date-hashed directory tree # # This script will recursively read a file or directory tree of JSON AWS # Cloudtrail logs and output in a format that SOF-ELKĀ® can read. Both gzipped # and native JSON is supported. # Assumes the filename contains a date in the format YYYYMMDD, such as: # 123456789012_CloudTrail_us-east-1_20250110T0805Z_Ba3uiALBNRSB1c4v.json.gz import argparse import gzip import json import os import re import sys from datetime import datetime from collections import defaultdict default_destdir = os.path.join(os.sep, "logstash", "aws") filename_regex_string = "(?P\\d{12})_CloudTrail_(?P[A-Za-z0-9-]+)_(?P\\d{4})(?P\\d{2})(?P\\d{2})T(?P