import logging


def analyze_policy(sa_iam_policy, sa_resource_name, risky_roles):
    """Check for the existence of risky roles.

    Args:
        sa_iam_policy ([dict]): The IAM policy attached to the sa_resource_name.
        sa_resource_name ([str]): The GCP service account full resource name.
        risky_roles ([list]): A list of risky roles to check current attached roles against.

    Returns:
        [bool]: True is a risky role was found in the IAM policy.
    """

    for binding in sa_iam_policy["bindings"]:
        if binding["role"] in risky_roles:
            logging.info(
                f"Found IAM role from denied list on service account {sa_resource_name}"
            )

            return True