# Buggy code
def put_cidr_name(
    aws_config, current_config, path, current_path, resource_id, callback_args
):
    """Add a display name for all known CIDRs."""

    if "cidrs" in current_config:
        cidr_list = []
        for cidr in current_config["cidrs"]:
            if type(cidr) == dict:
                cidr = cidr["CIDR"]
            if cidr in known_cidrs:
                cidr_name = known_cidrs[cidr]
            else:
                cidr_name = get_cidr_name(
                    cidr,
                    callback_args["ip_ranges"],
                    callback_args["ip_ranges_name_key"],
                )
                known_cidrs[cidr] = cidr_name
            cidr_list.append({"CIDR": cidr, "CIDRName": cidr_name})
        current_config["cidrs"] = cidr_list


# Traceback (TypeError)
scout aws --ip-ranges ./ip-ranges-default2.json --ip-ranges-name-key name
scout[78207] INFO Fetching resources for the ACM service
scout[78207] INFO Fetching resources for the Lambda service
scout[78207] INFO Fetching resources for the CloudFormation service
scout[78207] INFO Fetching resources for the CloudTrail service
scout[78207] INFO Fetching resources for the CloudWatch service
scout[78207] INFO Fetching resources for the Config service
scout[78207] INFO Fetching resources for the Direct Connect service
scout[78207] INFO Fetching resources for the EC2 service
scout[78207] INFO Fetching resources for the EFS service
scout[78207] INFO Fetching resources for the ElastiCache service
scout[78207] INFO Fetching resources for the ELB service
scout[78207] INFO Fetching resources for the ELBv2 service
scout[78207] INFO Fetching resources for the EMR service
scout[78207] INFO Fetching resources for the IAM service
scout[78207] INFO Fetching resources for the RDS service
scout[78207] INFO Fetching resources for the RedShift service
scout[78207] INFO Fetching resources for the Route53 service
scout[78207] INFO Fetching resources for the S3 service
scout[78207] INFO Fetching resources for the SES service
scout[78207] INFO Fetching resources for the SNS service
scout[78207] INFO Fetching resources for the SQS service
scout[78207] INFO Fetching resources for the VPC service
scout[78207] ERROR provider.py L315: put_cidr_name() missing 1 required positional argument: 'callback_args'
Traceback (most recent call last):
File "/Users/xxxx.local/share/virtualenvs/security-DQzaLIPv/lib/python3.7/site-packages/ScoutSuite/providers/base/provider.py", line 315, in _go_to_and_do
callback(current_config_key[value], path, current_path, value, callback_args)
TypeError: put_cidr_name() missing 1 required positional argument: 'callback_args'
<< repeated many times >>
scout[78207] INFO Running rule engine
scout[78207] INFO Applying display filters

cat ip-ranges-default2.json
{
"createDate": "2020-01-30-10-50-40",
"prefixes": [
{
"ip_prefix": "10.4.163.0/24",
"name": "My Description"
}
]
}

# Fixed code
def put_cidr_name(current_config, path, current_path, resource_id, callback_args):
    """Add a display name for all known CIDRs."""

    if "cidrs" in current_config:
        cidr_list = []
        for cidr in current_config["cidrs"]:
            if type(cidr) == dict:
                cidr = cidr["CIDR"]
            if cidr in known_cidrs:
                cidr_name = known_cidrs[cidr]
            else:
                cidr_name = get_cidr_name(
                    cidr,
                    callback_args["ip_ranges"],
                    callback_args["ip_ranges_name_key"],
                )
                known_cidrs[cidr] = cidr_name
            cidr_list.append({"CIDR": cidr, "CIDRName": cidr_name})
        current_config["cidrs"] = cidr_list