def cleanse(tarinfo):
    """Cleanse sources of nondeterminism from tar entries.

    To be passed as the `filter` kwarg to `tarfile.TarFile.add`.

    Args:
      tarinfo: A `tarfile.TarInfo` object to be mutated.

    Returns:
      The same `tarinfo` object, but mutated.
    """
    tarinfo.uid = 0
    tarinfo.gid = 0
    tarinfo.uname = "root"
    tarinfo.gname = "root"
    tarinfo.mtime = 0
    return tarinfo