diff --git a/docs/services/iam.md b/docs/services/iam.md index fe42c631da..c8124e1284 100644 --- a/docs/services/iam.md +++ b/docs/services/iam.md @@ -3379,7 +3379,9 @@ botocore's models, `src/main/resources/aws/iam-passed-roles.json`. A request mem when its name ends in `Role`, `RoleArn` or `RoleName` (or a plural, or one of those followed by `Update` or `Override`) and it holds a string, or a list or map of them; it is read from a JSON or CBOR body, from Query form parameters, in either list form, or from a REST-XML body by the elements -botocore names, and its role is passed to the service the Service Reference names. A JSON number or +botocore names, and its role is passed to the service the Service Reference names. In a JSON body a +member is also read through a list or map whose values are lists or maps, as an AppConfig extension's +`Actions` maps each action point to a list of actions, each passing the role its `RoleArn` names. A JSON number or Boolean in such a member is read as the text a handler reads it as, so `"JobFlowRole":123456` names the instance profile `123456`, as EMR takes it. Form parameters are read only from a request the Query protocol dispatches, a form posted to the root path, so a @@ -3430,7 +3432,7 @@ when the caller may not pass the role. Kinesis Analytics `ImportSnapshot`, Secrets Manager `AssociateCrossAccountReplica`), whose role the generator reads as soon as a release that has it is pinned. EC2's `RequestSpotFleet` names its roles in EC2's own protocol, one of them as an instance profile. A REST service is read once - Floci routes its requests by operation, as Access Analyzer, Bedrock, Bedrock AgentCore, CloudFront (its XML body, + Floci routes its requests by operation, as Access Analyzer, AppConfig, Bedrock, Bedrock AgentCore, CloudFront (its XML body, the `RoleARN` of each realtime log endpoint), FIS, GuardDuty and Macie are; one it does not route yet is not read, nor OpenSearch's `AssociatePackage`, whose role is in the `opensearch` client's request while the Service Reference lists only the `es` client for it. diff --git a/src/main/java/io/floci/aws/core/common/PassedRoleMembers.java b/src/main/java/io/floci/aws/core/common/PassedRoleMembers.java index 32218cb5c3..393d69d142 100644 --- a/src/main/java/io/floci/aws/core/common/PassedRoleMembers.java +++ b/src/main/java/io/floci/aws/core/common/PassedRoleMembers.java @@ -36,10 +36,15 @@ final class PassedRoleMembers { /** * One step of a member path: a member, then each element of a list, each element of a list whose field holds a - * value ({@code [path=/credentials]}), each value of a map, or one key's value. + * value ({@code [path=/credentials]}), each value of a map, or one key's value, one after another where a list or + * map holds lists or maps ({@code Actions{}[]}, each element of each value). */ private static final Pattern STEP = Pattern.compile( - "([A-Za-z][A-Za-z0-9_]*)(?:\\[([A-Za-z0-9_]*)]|\\[([A-Za-z0-9_]+=/[A-Za-z0-9_]+)]|\\{([A-Za-z0-9_]*)})?"); + "([A-Za-z][A-Za-z0-9_]*)((?:\\[[A-Za-z0-9_]*]|\\[[A-Za-z0-9_]+=/[A-Za-z0-9_]+]|\\{[A-Za-z0-9_]*})*)"); + + /** One step into a list's elements or a map's values, of those {@link #STEP} gives after a member's name. */ + private static final Pattern INTO = Pattern.compile( + "\\[([A-Za-z0-9_]*)]|\\[([A-Za-z0-9_]+=/[A-Za-z0-9_]+)]|\\{([A-Za-z0-9_]*)}"); /** How a member path goes on from a member. */ enum Into { NONE, LIST, MATCH, MAP, KEY } @@ -48,7 +53,8 @@ final class PassedRoleMembers { * A step of a member path: the member {@code name}, then for {@link Into#LIST} each element, named * {@code key} in the Query protocol when its shape names it, for {@link Into#MATCH} each element whose field * holds the value {@code key} gives as {@code field=value}, for {@link Into#MAP} each value, and for - * {@link Into#KEY} the value under {@code key}. + * {@link Into#KEY} the value under {@code key}. A null {@code name} names no member: the step goes on into the + * value the step before reached, each element or value of a list or map that holds lists or maps. */ record Step(String name, Into into, String key) { } @@ -196,15 +202,19 @@ final class PassedRoleMembers { if (!matcher.matches()) { return null; } - Into into = matcher.group(2) != null ? Into.LIST : matcher.group(3) != null ? Into.MATCH - : matcher.group(4) == null ? Into.NONE : matcher.group(4).isEmpty() ? Into.MAP : Into.KEY; - String key = switch (into) { - case LIST -> matcher.group(2); - case MATCH -> matcher.group(3); - case KEY -> matcher.group(4); - case NONE, MAP -> null; - }; - steps.add(new Step(matcher.group(1), into, key)); + String name = matcher.group(1); + Matcher into = INTO.matcher(matcher.group(2)); + if (!into.find()) { + steps.add(new Step(name, Into.NONE, null)); + continue; + } + do { + steps.add(into.group(1) != null ? new Step(name, Into.LIST, into.group(1)) + : into.group(2) != null ? new Step(name, Into.MATCH, into.group(2)) + : new Step(name, into.group(3).isEmpty() ? Into.MAP : Into.KEY, + into.group(3).isEmpty() ? null : into.group(3))); + name = null; + } while (into.find()); } return List.copyOf(steps); } @@ -221,10 +231,12 @@ final class PassedRoleMembers { if (step.into() == Into.KEY || step.into() == Into.MATCH) { return null; } - if (!regex.isEmpty()) { - regex.append("\\."); + if (step.name() != null) { + if (!regex.isEmpty()) { + regex.append("\\."); + } + regex.append(Pattern.quote(step.name())); } - regex.append(Pattern.quote(step.name())); if (step.into() == Into.LIST) { regex.append(step.key().isEmpty() ? "(\\.member)?" : "(\\.member|\\." + Pattern.quote(step.key()) + ")?") .append("\\.\\d+"); diff --git a/src/main/java/io/floci/aws/core/common/PassedRoles.java b/src/main/java/io/floci/aws/core/common/PassedRoles.java index 35c071be31..33489d1b65 100644 --- a/src/main/java/io/floci/aws/core/common/PassedRoles.java +++ b/src/main/java/io/floci/aws/core/common/PassedRoles.java @@ -444,14 +444,15 @@ final class PassedRoles { } /** - * The elements a member path names in an XML body, joined by dots; empty for one stepping into a map, which - * {@code regen_iam_passed_roles.py} gives no REST-XML operation, as it gives none a flattened list. + * The elements a member path names in an XML body, joined by dots; empty for one stepping into a map, or into the + * elements of a list's elements, which {@code regen_iam_passed_roles.py} gives no REST-XML operation, as it gives + * none a flattened list. */ private static Optional xmlPath(List steps) { List elements = new ArrayList<>(); for (PassedRoleMembers.Step step : steps) { - if (step.into() == PassedRoleMembers.Into.MAP || step.into() == PassedRoleMembers.Into.KEY - || step.into() == PassedRoleMembers.Into.MATCH) { + if (step.name() == null || step.into() == PassedRoleMembers.Into.MAP + || step.into() == PassedRoleMembers.Into.KEY || step.into() == PassedRoleMembers.Into.MATCH) { return Optional.empty(); } elements.add(step.name()); @@ -565,7 +566,7 @@ final class PassedRoles { return; } PassedRoleMembers.Step step = steps.get(index); - JsonNode value = node.get(step.name()); + JsonNode value = step.name() == null ? node : node.get(step.name()); switch (step.into()) { case NONE -> collect(value, steps, index + 1, found); case KEY -> collect(value == null ? null : value.get(step.key()), steps, index + 1, found); diff --git a/src/main/java/io/floci/aws/core/common/TagOnCreateMembers.java b/src/main/java/io/floci/aws/core/common/TagOnCreateMembers.java index d62d2b2957..b8ded973a1 100644 --- a/src/main/java/io/floci/aws/core/common/TagOnCreateMembers.java +++ b/src/main/java/io/floci/aws/core/common/TagOnCreateMembers.java @@ -146,7 +146,7 @@ final class TagOnCreateMembers { private static Member member(String operation, JsonNode member) { String path = JsonNodes.asText(member.path("member"), ""); - List steps = PassedRoleMembers.steps(path); + List steps = named(PassedRoleMembers.steps(path)); String key = member.hasNonNull("key") ? JsonNodes.asText(member.get("key")) : null; String value = member.hasNonNull("value") ? JsonNodes.asText(member.get("value")) : null; PassedRoleMembers.Into last = steps == null ? null : steps.getLast().into(); @@ -156,7 +156,7 @@ final class TagOnCreateMembers { + ", which is no path to a tag list or map"); } List querySteps = member.hasNonNull("query") - ? PassedRoleMembers.steps(JsonNodes.asText(member.get("query"))) : steps; + ? named(PassedRoleMembers.steps(JsonNodes.asText(member.get("query")))) : steps; if (querySteps == null || querySteps.getLast().into() != last) { throw new IllegalStateException(RESOURCE_NAME + " reads " + operation + "'s tags at " + path + " from a form by no path to a tag list or map"); @@ -168,4 +168,9 @@ final class TagOnCreateMembers { } return new Member(path, steps, querySteps, key, value, resourceType); } + + /** The steps of a path, or null for none or for one stepping into a list's or map's own lists or maps. */ + private static List named(List steps) { + return steps == null || steps.stream().anyMatch(step -> step.name() == null) ? null : steps; + } } diff --git a/src/main/resources/aws/iam-passed-roles.json b/src/main/resources/aws/iam-passed-roles.json index 162b7fc2d0..5e3e78eb49 100644 --- a/src/main/resources/aws/iam-passed-roles.json +++ b/src/main/resources/aws/iam-passed-roles.json @@ -1,7 +1,7 @@ { - "_source": {"generator": "tools/aws/regen_iam_passed_roles.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.44.18 (local/aws/botocore)", "retrieved": "2026-12-04", "note": "make iam-passed-roles-check re-derives every member from botocore; make iam-passed-roles-verify checks every operation against AWS."}, - "namespaces": {"access-analyzer": ["accessanalyzer"], "airflow": ["mwaa"], "apigateway": ["apigateway", "apigatewayv2"], "application-autoscaling": ["application-autoscaling"], "appsync": ["appsync"], "aps": ["amp"], "athena": ["athena"], "autoscaling": ["autoscaling"], "backup": ["backup"], "batch": ["batch"], "bedrock": ["bedrock", "bedrock-agent"], "bedrock-agentcore": ["bedrock-agentcore", "bedrock-agentcore-control"], "budgets": ["budgets"], "cloudformation": ["cloudcontrol", "cloudformation"], "cloudfront": ["cloudfront"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codebuild": ["codebuild"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "datasync": ["datasync"], "dlm": ["dlm"], "dms": ["dms"], "dsql": ["dsql"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticfilesystem": ["efs"], "elasticloadbalancing": ["elb-proxy"], "elasticmapreduce": ["emr"], "emr-containers": ["emr-containers"], "emr-serverless": ["emr-serverless"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "fis": ["fis"], "glue": ["glue"], "guardduty": ["guardduty"], "iam": ["iam"], "kafka": ["kafka"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "logs": ["logs"], "macie2": ["macie2"], "mq": ["mq"], "observabilityadmin": ["observabilityadmin"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "rum": ["rum"], "s3": ["s3", "s3control"], "s3tables": ["s3tables"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicecatalog": ["servicecatalog"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "sns": ["sns"], "ssm": ["ssm"], "states": ["stepfunctions"], "swf": ["swf"], "textract": ["textract"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"]}, - "notCovered": {"appconfig": "CreateExtension and UpdateExtension pass a role in Actions{}[].RoleArn, a map of lists, which this file does not read yet", "aws-marketplace": "REST routes no rule maps yet", "es": "AssociatePackage passes a role in the opensearch client's AssociationConfiguration.KeyStoreAccessOption.KeyAccessRoleArn, while the Service Reference lists only the es client for it, and this file reads an operation's members from the clients the reference lists for the namespace's role-passing operations", "iot": "REST routes no rule maps yet", "quicksight": "metadata-only REST subset; role passing and iam:PassRole checks are not implemented"}, + "_source": {"generator": "tools/aws/regen_iam_passed_roles.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.44.18 (local/aws/botocore)", "retrieved": "2026-12-05", "note": "make iam-passed-roles-check re-derives every member from botocore; make iam-passed-roles-verify checks every operation against AWS."}, + "namespaces": {"access-analyzer": ["accessanalyzer"], "airflow": ["mwaa"], "apigateway": ["apigateway", "apigatewayv2"], "appconfig": ["appconfig"], "application-autoscaling": ["application-autoscaling"], "appsync": ["appsync"], "aps": ["amp"], "athena": ["athena"], "autoscaling": ["autoscaling"], "backup": ["backup"], "batch": ["batch"], "bedrock": ["bedrock", "bedrock-agent"], "bedrock-agentcore": ["bedrock-agentcore", "bedrock-agentcore-control"], "budgets": ["budgets"], "cloudformation": ["cloudcontrol", "cloudformation"], "cloudfront": ["cloudfront"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codebuild": ["codebuild"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "datasync": ["datasync"], "dlm": ["dlm"], "dms": ["dms"], "dsql": ["dsql"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticfilesystem": ["efs"], "elasticloadbalancing": ["elb-proxy"], "elasticmapreduce": ["emr"], "emr-containers": ["emr-containers"], "emr-serverless": ["emr-serverless"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "fis": ["fis"], "glue": ["glue"], "guardduty": ["guardduty"], "iam": ["iam"], "kafka": ["kafka"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "logs": ["logs"], "macie2": ["macie2"], "mq": ["mq"], "observabilityadmin": ["observabilityadmin"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "rum": ["rum"], "s3": ["s3", "s3control"], "s3tables": ["s3tables"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicecatalog": ["servicecatalog"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "sns": ["sns"], "ssm": ["ssm"], "states": ["stepfunctions"], "swf": ["swf"], "textract": ["textract"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"]}, + "notCovered": {"aws-marketplace": "REST routes no rule maps yet", "es": "AssociatePackage passes a role in the opensearch client's AssociationConfiguration.KeyStoreAccessOption.KeyAccessRoleArn, while the Service Reference lists only the es client for it, and this file reads an operation's members from the clients the reference lists for the namespace's role-passing operations", "iot": "REST routes no rule maps yet", "quicksight": "metadata-only REST subset; role passing and iam:PassRole checks are not implemented"}, "otherNamespaces": ["agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifygen3", "aoss", "appflow", "appmesh", "apprunner", "appstream", "arc-region-switch", "assurance", "backup-external", "backup-gateway", "backup-search", "bcm-dashboards", "braket", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "codeconnections", "codestar-connections", "cognito-sync", "comprehendmedical", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "elemental-inference", "entityresolution", "fms", "forecast", "frauddetector", "gamelift", "gameliftstreams", "geo", "grafana", "greengrass", "groundstation", "health-agent", "healthlake", "imagebuilder", "iotdeviceadvisor", "iotfleetwise", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "kafkaconnect", "kendra", "lex", "lookoutequipment", "m2", "machinelearning", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "medical-imaging", "mobiletargeting", "neptune-graph", "odb", "omics", "opensearch", "osis", "partnercentral", "pcs", "personalize", "profile", "proton", "qbusiness", "repostspace", "resiliencehub", "rolesanywhere", "s3files", "sagemaker-geospatial", "securityagent", "securitylake", "shield", "sms-voice", "snowball", "social-messaging", "ssm-incidents", "ssm-quicksetup", "storagegateway", "supportapp", "synthetics", "timestream", "voiceid", "wellarchitected", "wisdom", "workmail", "workspaces"], "operations": { "access-analyzer:StartPolicyGeneration": {"passedTo": ["access-analyzer"], "roles": [ @@ -60,6 +60,24 @@ {"member": "credentialsArn", "passedTo": "apigateway"}, {"member": "patchOperations[path=/credentials].value", "passedTo": "apigateway"} ]}, + "appconfig:CreateConfigurationProfile": {"passedTo": ["appconfig"], "roles": [ + {"member": "RetrievalRoleArn", "passedTo": "appconfig"} + ]}, + "appconfig:CreateEnvironment": {"passedTo": ["appconfig"], "roles": [ + {"member": "Monitors[].AlarmRoleArn", "passedTo": "appconfig"} + ]}, + "appconfig:CreateExtension": {"passedTo": ["appconfig"], "roles": [ + {"member": "Actions{}[].RoleArn", "passedTo": "appconfig"} + ]}, + "appconfig:UpdateConfigurationProfile": {"passedTo": ["appconfig"], "roles": [ + {"member": "RetrievalRoleArn", "passedTo": "appconfig"} + ]}, + "appconfig:UpdateEnvironment": {"passedTo": ["appconfig"], "roles": [ + {"member": "Monitors[].AlarmRoleArn", "passedTo": "appconfig"} + ]}, + "appconfig:UpdateExtension": {"passedTo": ["appconfig"], "roles": [ + {"member": "Actions{}[].RoleArn", "passedTo": "appconfig"} + ]}, "application-autoscaling:RegisterScalableTarget": {"passedTo": ["application-autoscaling"], "roles": [ {"member": "RoleARN", "passedTo": "application-autoscaling"} ]}, diff --git a/src/main/resources/aws/iam-request-resources.json b/src/main/resources/aws/iam-request-resources.json index 0a4a182e0e..29446f7a14 100644 --- a/src/main/resources/aws/iam-request-resources.json +++ b/src/main/resources/aws/iam-request-resources.json @@ -354,9 +354,9 @@ "app-integrations:UpdateDataIntegrationAssociation": {"action": "app-integrations:UpdateDataIntegrationAssociation", "types": ["data-integration-association"], "resources": [{"type": "data-integration-association", "fill": {"DataIntegrationId": "DataIntegrationIdentifier", "ResourceId": "DataIntegrationAssociationIdentifier"}, "apis": ["rest-json/2020-07-29"]}], "located": {"DataIntegrationAssociationIdentifier": "{DataIntegrationAssociationIdentifier}", "DataIntegrationIdentifier": "{Identifier}"}}, "app-integrations:UpdateEventIntegration": {"action": "app-integrations:UpdateEventIntegration", "types": ["event-integration"], "resources": [{"type": "event-integration", "fill": {"EventIntegrationName": "Name"}, "apis": ["rest-json/2020-07-29"]}], "located": {"Name": "{Name}"}}, "appconfig:CreateApplication": {"action": "appconfig:CreateApplication", "types": [], "resources": [], "makes": [{"type": "application", "fill": {}}]}, - "appconfig:CreateConfigurationProfile": {"action": "appconfig:CreateConfigurationProfile", "types": ["application"], "resources": [{"types": ["application"], "arn": "RetrievalRoleArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "configurationprofile", "fill": {"ApplicationId": "ApplicationId"}}], "located": {"ApplicationId": "{ApplicationId}"}}, + "appconfig:CreateConfigurationProfile": {"action": "appconfig:CreateConfigurationProfile", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "configurationprofile", "fill": {"ApplicationId": "ApplicationId"}}], "located": {"ApplicationId": "{ApplicationId}"}}, "appconfig:CreateDeploymentStrategy": {"action": "appconfig:CreateDeploymentStrategy", "types": [], "resources": [], "makes": [{"type": "deploymentstrategy", "fill": {}}]}, - "appconfig:CreateEnvironment": {"action": "appconfig:CreateEnvironment", "types": ["application"], "resources": [{"types": ["application"], "arn": "Monitors[].AlarmArn", "apis": ["rest-json/2019-10-09"]}, {"types": ["application"], "arn": "Monitors[].AlarmRoleArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "environment", "fill": {"ApplicationId": "ApplicationId"}}], "located": {"ApplicationId": "{ApplicationId}"}}, + "appconfig:CreateEnvironment": {"action": "appconfig:CreateEnvironment", "types": ["application"], "resources": [{"types": ["application"], "arn": "Monitors[].AlarmArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "environment", "fill": {"ApplicationId": "ApplicationId"}}], "located": {"ApplicationId": "{ApplicationId}"}}, "appconfig:CreateExperimentDefinition": {"action": "appconfig:CreateExperimentDefinition", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationIdentifier"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "experimentdefinition", "fill": {}}], "located": {"ApplicationIdentifier": "{ApplicationIdentifier}"}}, "appconfig:CreateExtension": {"action": "appconfig:CreateExtension", "types": [], "resources": [], "makes": [{"type": "extension", "fill": {}}]}, "appconfig:CreateExtensionAssociation": {"action": "appconfig:CreateExtensionAssociation", "types": [], "resources": [], "makes": [{"type": "extensionassociation", "fill": {}}]}, @@ -404,9 +404,9 @@ "appconfig:UntagResource": {"action": "appconfig:UntagResource", "types": ["application", "configuration", "configurationprofile", "deployment", "deploymentstrategy", "environment", "experimentdefinition", "experimentrun", "extension", "extensionassociation"], "resources": [{"types": ["application", "configuration", "configurationprofile", "deployment", "deploymentstrategy", "environment", "experimentdefinition", "experimentrun", "extension", "extensionassociation"], "arn": "ResourceArn", "apis": ["rest-json/2019-10-09"]}], "located": {"ResourceArn": "{ResourceArn}"}}, "appconfig:UpdateAccountSettings": {"action": "appconfig:UpdateAccountSettings", "types": [], "resources": []}, "appconfig:UpdateApplication": {"action": "appconfig:UpdateApplication", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}"}}, - "appconfig:UpdateConfigurationProfile": {"action": "appconfig:UpdateConfigurationProfile", "types": ["application", "configurationprofile"], "resources": [{"types": ["application", "configurationprofile"], "arn": "RetrievalRoleArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "configurationprofile", "fill": {"ApplicationId": "ApplicationId", "ConfigurationProfileId": "ConfigurationProfileId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "ConfigurationProfileId": "{ConfigurationProfileId}"}}, + "appconfig:UpdateConfigurationProfile": {"action": "appconfig:UpdateConfigurationProfile", "types": ["application", "configurationprofile"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "configurationprofile", "fill": {"ApplicationId": "ApplicationId", "ConfigurationProfileId": "ConfigurationProfileId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "ConfigurationProfileId": "{ConfigurationProfileId}"}}, "appconfig:UpdateDeploymentStrategy": {"action": "appconfig:UpdateDeploymentStrategy", "types": ["deploymentstrategy"], "resources": [{"type": "deploymentstrategy", "fill": {"DeploymentStrategyId": "DeploymentStrategyId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"DeploymentStrategyId": "{DeploymentStrategyId}"}}, - "appconfig:UpdateEnvironment": {"action": "appconfig:UpdateEnvironment", "types": ["application", "environment"], "resources": [{"types": ["application", "environment"], "arn": "Monitors[].AlarmArn", "apis": ["rest-json/2019-10-09"]}, {"types": ["application", "environment"], "arn": "Monitors[].AlarmRoleArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "EnvironmentId": "{EnvironmentId}"}}, + "appconfig:UpdateEnvironment": {"action": "appconfig:UpdateEnvironment", "types": ["application", "environment"], "resources": [{"types": ["application", "environment"], "arn": "Monitors[].AlarmArn", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "EnvironmentId": "{EnvironmentId}"}}, "appconfig:UpdateExperimentDefinition": {"action": "appconfig:UpdateExperimentDefinition", "types": ["application", "experimentdefinition"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationIdentifier"}, "apis": ["rest-json/2019-10-09"]}, {"type": "experimentdefinition", "fill": {"ApplicationId": "ApplicationIdentifier", "ExperimentDefinitionId": "ExperimentDefinitionIdentifier"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationIdentifier": "{ApplicationIdentifier}", "ExperimentDefinitionIdentifier": "{ExperimentDefinitionIdentifier}"}}, "appconfig:UpdateExperimentRun": {"action": "appconfig:UpdateExperimentRun", "types": ["application", "experimentdefinition", "experimentrun"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationIdentifier"}, "apis": ["rest-json/2019-10-09"]}, {"type": "experimentdefinition", "fill": {"ApplicationId": "ApplicationIdentifier", "ExperimentDefinitionId": "ExperimentDefinitionIdentifier"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationIdentifier": "{ApplicationIdentifier}", "ExperimentDefinitionIdentifier": "{ExperimentDefinitionIdentifier}"}}, "appconfig:UpdateExtension": {"action": "appconfig:UpdateExtension", "types": ["extension"], "resources": [{"types": ["extension"], "arn": "ExtensionIdentifier", "apis": ["rest-json/2019-10-09"]}, {"type": "extension", "fill": {"ExtensionId": "ExtensionIdentifier"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ExtensionIdentifier": "{ExtensionIdentifier}"}}, diff --git a/src/test/java/io/floci/aws/core/common/PassedRoleMembersTest.java b/src/test/java/io/floci/aws/core/common/PassedRoleMembersTest.java index dd2181c2b5..062eb98679 100644 --- a/src/test/java/io/floci/aws/core/common/PassedRoleMembersTest.java +++ b/src/test/java/io/floci/aws/core/common/PassedRoleMembersTest.java @@ -131,6 +131,21 @@ class PassedRoleMembersTest { assertNull(key.queryKeys()); } + /** + * A map of lists is read value by value, then element by element: the step after the member's own steps into the + * value it reached, so it names no member. + */ + @Test + void aMapOfListsIsReadEachElementOfEachValue() { + Member actions = member("Actions{}[].RoleArn", "appconfig"); + assertEquals(List.of(new Step("Actions", Into.MAP, null), new Step(null, Into.LIST, ""), + new Step("RoleArn", Into.NONE, null)), actions.steps()); + assertTrue(actions.queryKeys().matcher("Actions.entry.1.value.member.2.RoleArn").matches()); + assertFalse(actions.queryKeys().matcher("Actions.entry.1.value.RoleArn").matches()); + assertEquals(List.of(new Step("Grid", Into.LIST, ""), new Step(null, Into.LIST, "")), + PassedRoleMembers.steps("Grid[][]")); + } + @Test void aMalformedTableFailsToLoad() { assertThrows(IllegalStateException.class, () -> parse("{\"operations\":{}}")); @@ -247,6 +262,10 @@ class PassedRoleMembersTest { case MAP -> MAPPER.createObjectNode().set("any", node); case KEY -> MAPPER.createObjectNode().set(step.key(), node); }; + if (step.name() == null) { + node = inner; + continue; + } ObjectNode outer = MAPPER.createObjectNode(); outer.set(step.name(), inner); node = outer; @@ -258,7 +277,9 @@ class PassedRoleMembersTest { private static String formKey(Member member) { List parts = new ArrayList<>(); for (Step step : member.steps()) { - parts.add(step.name()); + if (step.name() != null) { + parts.add(step.name()); + } if (step.into() == Into.LIST) { parts.add("member.1"); } else if (step.into() == Into.MAP) { diff --git a/src/test/java/io/floci/aws/core/common/PassedRolesTest.java b/src/test/java/io/floci/aws/core/common/PassedRolesTest.java index 9e40b55c5a..83278a44d0 100644 --- a/src/test/java/io/floci/aws/core/common/PassedRolesTest.java +++ b/src/test/java/io/floci/aws/core/common/PassedRolesTest.java @@ -710,6 +710,12 @@ class PassedRolesTest { // A member taking only an ARN passes nothing for a name. assertEquals(List.of(), PassedRoles.of("codebuild:CreateProject", json("{\"name\":\"p\",\"serviceRole\":\"app-role\"}"), LOOKUPS)); + // An AppConfig extension's actions are a map of lists: the role of each action under each action point. + assertEquals(List.of(passed("first", "appconfig.amazonaws.com"), passed("second", "appconfig.amazonaws.com"), + passed("third", "appconfig.amazonaws.com")), PassedRoles.of("appconfig:CreateExtension", json(""" + {"Name":"e","Actions":{"ON_DEPLOYMENT_START":[{"RoleArn":"%1$sfirst"},{"RoleArn":"%1$ssecond"}], + "ON_DEPLOYMENT_COMPLETE":[{"RoleArn":"%1$sthird"}],"ON_DEPLOYMENT_BAKING":[]}}""".formatted(ROLES)), + LOOKUPS)); } @Test diff --git a/src/test/java/io/floci/aws/core/common/TagOnCreateMembersTest.java b/src/test/java/io/floci/aws/core/common/TagOnCreateMembersTest.java index a2e4656759..5e5358f074 100644 --- a/src/test/java/io/floci/aws/core/common/TagOnCreateMembersTest.java +++ b/src/test/java/io/floci/aws/core/common/TagOnCreateMembersTest.java @@ -116,6 +116,10 @@ class TagOnCreateMembersTest { assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags[]\"}")); assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags{}\",\"key\":\"K\",\"value\":\"V\"}")); assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags{}\",\"query\":\"Tag[]\"}")); + // Tags are one list or map, never a list or map of them. + assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags{}[]\",\"key\":\"K\",\"value\":\"V\"}")); + assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags[]\",\"key\":\"K\",\"value\":\"V\"," + + "\"query\":\"Tag{}[]\"}")); // A resource type belongs to a list of tag specifications, and its namespace's types need ARNs. assertThrows(IllegalStateException.class, () -> member("{\"member\":\"Tags[]\",\"key\":\"K\",\"value\":\"V\"," + "\"resourceType\":\"ResourceType\"}")); diff --git a/src/test/java/io/floci/aws/services/iam/IamPassRoleEnforcementIntegrationTest.java b/src/test/java/io/floci/aws/services/iam/IamPassRoleEnforcementIntegrationTest.java index c49d892c1a..d79ea67600 100644 --- a/src/test/java/io/floci/aws/services/iam/IamPassRoleEnforcementIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/iam/IamPassRoleEnforcementIntegrationTest.java @@ -284,6 +284,44 @@ class IamPassRoleEnforcementIntegrationTest { user.rest("airflow").body(patch).patch("/environments/" + name).then().statusCode(200); } + @Test + void appConfigNeedsPassRoleOnTheRolesAProfileOrAnEnvironmentNamesForAppConfig() { + // The Service Reference passes a configuration profile's RetrievalRoleArn and each environment monitor's + // AlarmRoleArn to AppConfig, and the role is no resource of the operation: a grant on the application is enough. + // Floci serves no extension, whose actions' roles PassedRolesTest reads. + String role = role("appconfig-retrieval"); + User user = user("passrole-appconfig"); + String application = admin("appconfig").contentType("application/json") + .body("{\"Name\":\"passrole-app-" + suffix() + "\"}") + .post("/applications").then().statusCode(201).extract().path("Id"); + cleanup.register(() -> admin("appconfig").delete("/applications/" + application)); + String applicationArn = "arn:aws:appconfig:us-east-1:" + ACCOUNT + ":application/" + application; + String profiles = "/applications/" + application + "/configurationprofiles"; + String profile = "{\"Name\":\"passrole-profile\",\"LocationUri\":\"hosted\",\"RetrievalRoleArn\":\"" + role + + "\"}"; + String createProfile = allow("appconfig:CreateConfigurationProfile", applicationArn); + + user.policy(createProfile); + denied(user.rest("appconfig").body(profile).post(profiles).then()); + user.policy(createProfile + "," + passRole(role, "ec2.amazonaws.com")); + denied(user.rest("appconfig").body(profile).post(profiles).then()); + user.policy(createProfile + "," + passRole(role, "appconfig.amazonaws.com")); + String profileId = user.rest("appconfig").body(profile).post(profiles).then().statusCode(201) + .extract().path("Id"); + cleanup.register(() -> admin("appconfig").delete(profiles + "/" + profileId)); + + String environments = "/applications/" + application + "/environments"; + String environment = "{\"Name\":\"passrole-environment\",\"Monitors\":[{\"AlarmArn\":" + + "\"arn:aws:cloudwatch:us-east-1:" + ACCOUNT + ":alarm:passrole\",\"AlarmRoleArn\":\"" + role + "\"}]}"; + String createEnvironment = allow("appconfig:CreateEnvironment", applicationArn); + user.policy(createEnvironment); + denied(user.rest("appconfig").body(environment).post(environments).then()); + user.policy(createEnvironment + "," + passRole(role, "appconfig.amazonaws.com")); + String environmentId = user.rest("appconfig").body(environment).post(environments).then().statusCode(201) + .extract().path("Id"); + cleanup.register(() -> admin("appconfig").delete(environments + "/" + environmentId)); + } + @Test void apiGatewayNeedsPassRoleOnTheRolesAnIntegrationAnUpdateOrAnImportNames() { // API Gateway is authorized by HTTP method, and its roles are checked for the operation its route resolves: diff --git a/tools/aws/regen_iam_passed_roles.py b/tools/aws/regen_iam_passed_roles.py index 34513311f6..260a63fac4 100644 --- a/tools/aws/regen_iam_passed_roles.py +++ b/tools/aws/regen_iam_passed_roles.py @@ -25,8 +25,10 @@ That leaves out `RoleSessionName` and `AmbiguousRoleResolution`, which name no r own documentation says it takes a role by name as well as by ARN is marked `byName`, and Floci resolves the name in the request's account, as the services do. A REST-XML request's members are read from its XML body by the elements botocore serializes them as (S3's `PutBucketReplication`, the -`Role` of its `ReplicationConfiguration`), and one reached through a map or a flattened list, which -`PassedRoles` does not read there, fails generation. What the rule gets wrong for an +`Role` of its `ReplicationConfiguration`), and one reached through a map, a flattened list or a list +of lists, which `PassedRoles` does not read there, fails generation. In a JSON body a member path steps +into a list or map one container after another (AppConfig's `Actions{}[].RoleArn`, the role of each +action under each action point). What the rule gets wrong for an operation is corrected here, each with its reason: a role member it does not see (`EXTRA_MEMBERS`), a member it sees that passes no role (`EXCLUDED_MEMBERS`), and which service a member's role goes to when the reference names several (`MEMBER_SERVICES`). Where a namespace's documentation says it, which @@ -101,8 +103,9 @@ SERVICE_SUFFIX = ".amazonaws.com" # The IAM namespaces whose operations this file reads: those Floci serves over the JSON and Query # protocols and Smithy RPC v2 CBOR, and the REST ones whose routes Floci authorizes by operation. NAMESPACES = ( - "access-analyzer", "airflow", "apigateway", "application-autoscaling", "aps", "appsync", "athena", "autoscaling", - "backup", "batch", "bedrock", "bedrock-agentcore", "budgets", "cloudformation", "cloudfront", "cloudtrail", + "access-analyzer", "airflow", "apigateway", "appconfig", "application-autoscaling", "aps", "appsync", "athena", + "autoscaling", "backup", "batch", "bedrock", "bedrock-agentcore", "budgets", "cloudformation", "cloudfront", + "cloudtrail", "cloudwatch", "codebuild", "codedeploy", "codepipeline", "cognito-identity", "cognito-idp", "comprehend", "config", "datasync", "dlm", "dms", "dsql", "ec2", "ecr", "ecs", "eks", "elasticfilesystem", "elasticloadbalancing", "elasticmapreduce", @@ -117,8 +120,6 @@ NAMESPACES = ( # Namespaces Floci serves whose operations list iam:PassRole but are not read here yet, each with # why. `PassedRolesCoverageTest` fails for a namespace Floci serves that is in neither list. NOT_COVERED = { - "appconfig": "CreateExtension and UpdateExtension pass a role in Actions{}[].RoleArn, a map of lists, which this file " - "does not read yet", "aws-marketplace": "REST routes no rule maps yet", "es": "AssociatePackage passes a role in the opensearch client's AssociationConfiguration.KeyStoreAccessOption." "KeyAccessRoleArn, while the Service Reference lists only the es client for it, and this file reads an " @@ -142,11 +143,12 @@ BY_NAME_DOC_RE = re.compile(r"\bname or (the |its )?(full )?(ARN|Amazon Resource # The protocols whose requests PassedRoles reads: form parameters, or a JSON, CBOR or XML body. READ_PROTOCOLS = {"json", "query", "rest-json", "rest-xml", "smithy-rpc-v2-cbor"} # How a vendored member path is written: dotted segments, a list step as `[]` or `[Name]` when its -# shape names its members, a map step as `{}` for every value or `{KEY}` for one key's. +# shape names its members, a map step as `{}` for every value or `{KEY}` for one key's, one step after another +# where a list or map holds lists or maps (`Actions{}[]`, each element of each value). MEMBER_PATH_RE = re.compile(r"^[A-Za-z][A-Za-z0-9_]*(\[[A-Za-z0-9_]*\]|\[[A-Za-z0-9_]+=/[A-Za-z0-9_]+\]" - r"|\{[A-Za-z0-9_]*\})?" + r"|\{[A-Za-z0-9_]*\})*" r"(\.[A-Za-z][A-Za-z0-9_]*(\[[A-Za-z0-9_]*\]|\[[A-Za-z0-9_]+=/[A-Za-z0-9_]+\]" - r"|\{[A-Za-z0-9_]*\})?)*$") + r"|\{[A-Za-z0-9_]*\})*)*$") NAMESPACE_RE = re.compile(r"^[a-z0-9][a-z0-9-]{0,63}$") OPERATION_RE = re.compile(r"^[a-z0-9-]+:[A-Za-z][A-Za-z0-9]{0,127}$") SERVICE_RE = re.compile(r"^[a-z0-9][a-z0-9.-]*$") @@ -558,8 +560,8 @@ def readable(model: dict) -> bool: def role_members(model: dict, operation: str, named: frozenset[str] = frozenset()) -> dict[str, bool]: """The members of the operation's request the rule reads, as vendored paths, each with whether it takes a role by name. An XML body is read by the elements botocore names, a list's elements by - the name of its member or as `member`, so a role member reached through a map or a flattened list, - which do not nest as these paths do, fails rather than being read wrong.""" + the name of its member or as `member`, so a role member reached through a map, a flattened list or a list of + lists, which do not nest as these paths do, fails rather than being read wrong.""" spec = model["operations"].get(operation) if spec is None or "input" not in spec or not readable(model): return {} @@ -584,7 +586,7 @@ def role_members(model: dict, operation: str, named: frozenset[str] = frozenset( if shape["type"] in ("list", "map"): nested = shape["member" if shape["type"] == "list" else "value"]["shape"] walk(nested, tuple(prefix + _step(shape) for prefix in prefixes), False, seen, - through or unnested(shape)) + through or unnested(shape) or xml and model["shapes"][nested]["type"] == "list") elif shape["type"] == "structure": for name, member in shape.get("members", {}).items(): if top and member.get("location") not in BODY_LOCATIONS: @@ -596,8 +598,8 @@ def role_members(model: dict, operation: str, named: frozenset[str] = frozenset( if _is_role_member(name, model, member["shape"]) or ( serialized in named and _leaf(model, member["shape"]) is not None): if through or unnested(model["shapes"][member["shape"]]): - raise ValueError(f"{operation}'s {paths[0]} reaches the elements of a map or a flattened " - "list, which PassedRoles does not read in an XML body") + raise ValueError(f"{operation}'s {paths[0]} reaches the elements of a map, a flattened list " + "or a list of lists, which PassedRoles does not read in an XML body") by_name = _takes_name(name, member, model) for path in paths: leaf = path + _step(model["shapes"][member["shape"]]) @@ -613,7 +615,9 @@ def role_members(model: dict, operation: str, named: frozenset[str] = frozenset( return found -PATH_STEP_RE = re.compile(r"^(?P[A-Za-z][A-Za-z0-9_]*)(?:\[(?P[A-Za-z0-9_]*)\]|\{(?P[A-Za-z0-9_]*)\})?$") +PATH_STEP_RE = re.compile(r"^(?P[A-Za-z][A-Za-z0-9_]*)(?P(?:\[[A-Za-z0-9_]*\]|\{[A-Za-z0-9_]*\})*)$") +# One step into a list's elements or a map's values, of those `PATH_STEP_RE` matches after a member's name. +INTO_RE = re.compile(r"\[(?P[A-Za-z0-9_]*)\]|\{(?P[A-Za-z0-9_]*)\}") def _walk(model: dict, operation: str, path: str) -> tuple[str, str, dict] | None: @@ -638,18 +642,19 @@ def _walk(model: dict, operation: str, path: str) -> tuple[str, str, dict] | Non walked = (owner, name) owner = member["shape"] shape = model["shapes"][owner] - if match["list"] is not None: - if shape["type"] != "list": - return None - owner = shape["member"]["shape"] - elif match["key"] is not None: - if shape["type"] != "map": - return None - keys = model["shapes"][shape["key"]["shape"]].get("enum") - if match["key"] and keys is not None and match["key"] not in keys: - return None - owner = shape["value"]["shape"] - shape = model["shapes"][owner] + for into in INTO_RE.finditer(match["into"]): + if into["list"] is not None: + if shape["type"] != "list": + return None + owner = shape["member"]["shape"] + else: + if shape["type"] != "map": + return None + keys = model["shapes"][shape["key"]["shape"]].get("enum") + if into["key"] and keys is not None and into["key"] not in keys: + return None + owner = shape["value"]["shape"] + shape = model["shapes"][owner] return None if walked is None else (*walked, shape) diff --git a/tools/aws/test_regen_iam_passed_roles.py b/tools/aws/test_regen_iam_passed_roles.py index cf54ba98b3..171022f352 100644 --- a/tools/aws/test_regen_iam_passed_roles.py +++ b/tools/aws/test_regen_iam_passed_roles.py @@ -171,12 +171,36 @@ def test_an_xml_body_is_read_below_its_payload_by_the_names_its_members_are_seri {"type": "map", "key": {"shape": "String"}, "value": {"shape": "Target"}}]) def test_an_xml_role_member_reached_through_a_map_or_a_flattened_list_fails(nesting): shapes = {"In": structure(Targets="Targets"), "Targets": nesting, "Target": structure(RoleArn="String")} - with pytest.raises(ValueError, match="map or a flattened list"): + with pytest.raises(ValueError, match="which PassedRoles does not read in an XML body"): r.role_members(model({"Op": "In"}, shapes, protocol="rest-xml"), "Op") # A JSON body nests them as the paths do. assert len(r.role_members(model({"Op": "In"}, shapes), "Op")) == 1 +def test_a_map_of_lists_is_written_one_step_after_another_and_read_back(): + # AppConfig's CreateExtension: the RoleArn of each action of each action point. + shapes = {"In": structure(Actions="ActionsMap"), + "ActionsMap": {"type": "map", "key": {"shape": "Point"}, "value": {"shape": "ActionList"}}, + "Point": {"type": "string", "enum": ["ON_DEPLOYMENT_START"]}, + "ActionList": {"type": "list", "member": {"shape": "Action"}}, + "Action": structure(Name="String", RoleArn="String")} + m = model({"Op": "In"}, shapes) + assert r.role_members(m, "Op") == {"Actions{}[].RoleArn": False} + assert r.member_exists(m, "Op", "Actions{}[].RoleArn") + assert r.member_exists(m, "Op", "Actions{ON_DEPLOYMENT_START}[].RoleArn") + assert not r.member_exists(m, "Op", "Actions{OTHER}[].RoleArn") + assert not r.member_exists(m, "Op", "Actions[]{}.RoleArn") + assert not r.member_exists(m, "Op", "Actions{}[][].RoleArn") + + +def test_an_xml_role_member_reached_through_a_list_of_lists_fails(): + shapes = {"In": structure(Grid="Grid"), "Grid": {"type": "list", "member": {"shape": "Row"}}, + "Row": {"type": "list", "member": {"shape": "Target"}}, "Target": structure(RoleArn="String")} + with pytest.raises(ValueError, match="a list of lists"): + r.role_members(model({"Op": "In"}, shapes, protocol="rest-xml"), "Op") + assert r.role_members(model({"Op": "In"}, shapes), "Op") == {"Grid[][].RoleArn": False} + + def test_a_member_path_with_a_map_key_exists_only_for_a_key_the_enum_lists(): m = model({"Op": "In"}, {"In": structure(Definition="Definition"), "Definition": {"type": "map", "key": {"shape": "Key"}, "value": {"shape": "String"}},