def flatten_rf(flow):
    """
    Flattens the Risky Flow objects into a flat dict to write to CSV.
    """
    return {
        "id": flow.get("id"),
        "businessUnit": flow.get("businessUnit", {}).get("name"),
        "riskRule": flow.get("riskRule", {}).get("name"),
        "internalAddress": flow.get("internalAddress"),
        "internalPort": flow.get("internalPort"),
        "externalAddress": flow.get("externalAddress"),
        "externalPort": flow.get("externalPort"),
        "flowDirection": flow.get("flowDirection"),
        "acked": flow.get("acked"),
        "protocol": flow.get("protocol"),
        "externalCountryCode": flow.get("externalCountryCode"),
        "internalCountryCode": flow.get("internalCountryCode"),
        "observationTimestamp": flow.get("observationTimestamp"),
        "created": flow.get("created"),
        "internalExposureTypes": ",".join(flow.get("internalExposureTypes")),
        "internalDomains": ",".join(flow.get("internalDomains")),
    }