fix(iam): check AppConfig's deployment reads on the deployment their path numbers (#10262)

This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-12-05 18:22:54 -04:00
1 parent 78830d629a
commit eae8ccb53e
5 files changed
+122 -8

No files matched your search

+6
View File
@@ -68,6 +68,12 @@ those `TagResource` and `UntagResource` change, are returned by `ListTagsForReso
`aws:ResourceTag` conditions, not by the resource's own reads. `Tags` that are not a map of strings return
`BadRequestException`. `TagResource` on a configuration profile, deployment strategy, extension or extension
association ARN is accepted and not stored, and `ListTagsForResource` returns no tags for it.
With [IAM enforcement](iam.md#iam-enforcement-mode) on, `GetDeployment` and `StopDeployment` are checked on the
deployment's ARN, `application/<application id>/environment/<environment id>/deployment/<number>`, beside its
application and environment, as the Service Reference gives it; a number written with leading zeroes names the same
deployment.
`StartDeployment` and `GetDeployment` return the deployed profile's name and location URI as
`ConfigurationName` and `ConfigurationLocationUri`. Deployments stored by earlier Floci versions did not
record them, so on those neither is set.
@@ -13,7 +13,7 @@
"unqualified": {"ssm": ["parameter"], "states": ["statemachine"]},
"mintedIds": {"events": ["api-destination", "connection"]},
"mintedSuffixes": {"secretsmanager": {"Secret": "-??????"}},
"integerVariables": {"connect": {"customer-managed-view-version": ["ViewVersion"]}, "lambda": {"layerVersion": ["LayerVersion"]}},
"integerVariables": {"appconfig": {"deployment": ["DeploymentNumber"]}, "connect": {"customer-managed-view-version": ["ViewVersion"]}, "lambda": {"layerVersion": ["LayerVersion"]}},
"alternateFormats": {"backup": {"recoveryPoint": ["arn:${Partition}:dynamodb:${Region}:${Account}:table/${Resource}/backup/${RecoveryPointId}", "arn:${Partition}:ec2:${Region}::image/ami-${RecoveryPointId}", "arn:${Partition}:ec2:${Region}::snapshot/${RecoveryPointId}", "arn:${Partition}:fsx:${Region}:${Account}:backup/backup-${RecoveryPointId}"]}},
"narrowerFormats": {"access-analyzer": {"Analyzer": ["ArchiveRule"]}, "acm": {"acme-endpoint": ["acme-domain-validation", "acme-external-account-binding"]}, "apigateway": {"/usageplans/{usageplanId}/usage (resource-path-specifier)": ["/usageplans/{usageplanId}/keys/{keyId}/usage (resource-path-specifier)"], "Api": ["AccessLogSettings", "Authorizer", "Authorizers", "AuthorizersCache", "Cors", "Deployment", "Deployments", "ExportedAPI", "Integration", "IntegrationResponse", "IntegrationResponses", "Integrations", "Model", "ModelTemplate", "Models", "Route", "RouteRequestParameter", "RouteResponse", "RouteResponses", "RouteSettings", "Routes", "Stage", "Stages"], "Authorizers": ["AuthorizersCache"], "Authorizers (REST API resources)": ["/restapis/{restapi_id}/stages/{stage_name}/cache/authorizers (resource-path-specifier)"], "BasePathMapping": ["PrivateBasePathMapping"], "BasePathMappings": ["PrivateBasePathMappings"], "DomainName": ["ApiMapping", "ApiMappings", "BasePathMapping", "BasePathMappings", "PrivateBasePathMapping", "PrivateBasePathMappings"], "Integration": ["IntegrationResponse", "IntegrationResponses"], "Method": ["Integration (REST API resources)", "IntegrationResponse (REST API resources)", "MethodResponse"], "MethodResponse": ["IntegrationResponse (REST API resources)"], "Model": ["ModelTemplate"], "Model (REST API resources)": ["/restapis/{restapi_id}/models/{model_name}/default_template (resource-path-specifier)"], "PortalProduct": ["ProductPage", "ProductRestEndpointPage"], "PrivateDomainName": ["PrivateBasePathMapping", "PrivateBasePathMappings"], "Resource": ["Integration (REST API resources)", "IntegrationResponse (REST API resources)", "Method", "MethodResponse"], "RestApi": ["/restapis/{restapi_id}/models/{model_name}/default_template (resource-path-specifier)", "/restapis/{restapi_id}/stages/{stage_name}/cache/authorizers (resource-path-specifier)", "/restapis/{restapi_id}/stages/{stage_name}/cache/data (resource-path-specifier)", "/restapis/{restapi_id}/stages/{stage_name}/exports/{export_type} (resource-path-specifier)", "Authorizer (REST API resources)", "Authorizers (REST API resources)", "Deployment (REST API resources)", "Deployments (REST API resources)", "DocumentationPart", "DocumentationParts", "DocumentationVersion", "DocumentationVersions", "GatewayResponse", "GatewayResponses", "Integration (REST API resources)", "IntegrationResponse (REST API resources)", "Method", "MethodResponse", "Model (REST API resources)", "Models (REST API resources)", "RequestValidator", "RequestValidators", "Resource", "Resources", "Sdk", "Stage (REST API resources)", "Stages (REST API resources)", "Template"], "Route": ["RouteRequestParameter", "RouteResponse", "RouteResponses"], "Stage": ["AccessLogSettings", "AuthorizersCache", "RouteSettings"], "Stage (REST API resources)": ["/restapis/{restapi_id}/stages/{stage_name}/cache/authorizers (resource-path-specifier)", "/restapis/{restapi_id}/stages/{stage_name}/cache/data (resource-path-specifier)", "/restapis/{restapi_id}/stages/{stage_name}/exports/{export_type} (resource-path-specifier)", "Sdk"], "UsagePlan": ["/usageplans/{usageplanId}/keys/{keyId}/usage (resource-path-specifier)", "/usageplans/{usageplanId}/usage (resource-path-specifier)", "UsagePlanKey", "UsagePlanKeys"], "UsagePlanKey": ["/usageplans/{usageplanId}/keys/{keyId}/usage (resource-path-specifier)"]}, "appconfig": {"application": ["configuration", "configurationprofile", "deployment", "environment", "experimentdefinition", "experimentrun", "hostedconfigurationversion"], "environment": ["configuration", "deployment"], "experimentdefinition": ["experimentrun"]}, "appsync": {"api": ["channelNamespace", "datasource", "field", "function", "mergedApiAssociation", "sourceApiAssociation", "type"], "graphqlapi": ["channelNamespace", "datasource", "field", "function", "mergedApiAssociation", "sourceApiAssociation", "type"], "type": ["field"]}, "athena": {"workgroup": ["session"]}, "backup": {"recoveryPoint": ["backupPlan", "backupVault", "framework", "legalHold", "reportPlan", "restoreTestingPlan", "tieringConfiguration"]}, "batch": {"job-definition": ["job-definition-revision"], "job-queue": ["quota-share"]}, "bedrock": {"automated-reasoning-policy": ["automated-reasoning-policy-version"], "flow": ["flow-alias", "flow-execution"], "flow-alias": ["flow-execution"], "project": ["anthropic-agent", "anthropic-encryption-configuration", "anthropic-memory-store", "anthropic-self-hosted", "anthropic-session"], "prompt": ["prompt-version"]}, "bedrock-agentcore": {"harness": ["harness-endpoint"], "policy-engine": ["policy", "policy-generation"], "registry": ["registry-record"], "runtime": ["runtime-endpoint"], "token-vault": ["apikeycredentialprovider", "oauth2credentialprovider", "paymentcredentialprovider"], "workload-identity-directory": ["workload-identity"]}, "budgets": {"budget": ["budgetAction"]}, "codeguru-reviewer": {"association": ["codereview"]}, "codepipeline": {"action": ["actiontLine truncated
"tagParents": {"apigateway": {"/restapis/{restapi_id}/models/{model_name}/default_template (resource-path-specifier)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestapiId}"}, "/restapis/{restapi_id}/stages/{stage_name}/cache/authorizers (resource-path-specifier)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestapiId}"}, "/restapis/{restapi_id}/stages/{stage_name}/cache/data (resource-path-specifier)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestapiId}"}, "/restapis/{restapi_id}/stages/{stage_name}/exports/{export_type} (resource-path-specifier)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestapiId}"}, "/usageplans/{usageplanId}/keys/{keyId}/usage (resource-path-specifier)": {"type": "UsagePlan", "arn": "arn:${Partition}:apigateway:${Region}::/usageplans/${UsageplanId}"}, "/usageplans/{usageplanId}/usage (resource-path-specifier)": {"type": "UsagePlan", "arn": "arn:${Partition}:apigateway:${Region}::/usageplans/${UsageplanId}"}, "ApiMapping": {"type": "DomainName", "arn": "arn:${Partition}:apigateway:${Region}::/domainnames/${DomainName}"}, "ApiMappings": {"type": "DomainName", "arn": "arn:${Partition}:apigateway:${Region}::/domainnames/${DomainName}"}, "Authorizer (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "Authorizers (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "BasePathMapping": {"type": "DomainName", "arn": "arn:${Partition}:apigateway:${Region}::/domainnames/${DomainName}"}, "BasePathMappings": {"type": "DomainName", "arn": "arn:${Partition}:apigateway:${Region}::/domainnames/${DomainName}"}, "Deployment (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "Deployments (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "DocumentationPart": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "DocumentationParts": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "DocumentationVersion": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "DocumentationVersions": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "GatewayResponse": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "GatewayResponses": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "Integration (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "IntegrationResponse (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "Method": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "MethodResponse": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "Model (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "Models (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "RequestValidator": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "RequestValidators": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "Resource": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "Resources": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "RoutingRule": {"type": "DomainName", "arn": "arn:${Partition}:apigateway:${Region}::/domainnames/${DomainName}"}, "Sdk": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${RestApiId}"}, "Stage (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "Stages (REST API resources)": {"type": "RestApi", "arn": "arn:${Partition}:apigateway:${Region}::/restapis/${ApiId}"}, "UsagePlanKey": {"type": "UsagePlan", "arn": "arn:${Partition}:apigateway:${Region}::/usageplans/${UsagePlanId}"}, "UsagePlanKeys": {"type": "UsagePlan", "arn": "arn:${Partition}:apigateway:${Region}::/usageplans/${UsagePlanId}"}}, "s3": {"object": {"type": "bucket", "arn": "arn:${Partition}:s3:::${BucketName}"}}},
@@ -375,7 +375,7 @@
"appconfig:GetApplication": {"action": "appconfig:GetApplication", "types": ["application"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}"}},
"appconfig:GetConfiguration": {"action": "appconfig:GetConfiguration", "types": ["application", "configurationprofile", "environment"], "resources": [{"type": "application", "fill": {"ApplicationId": "Application"}, "endpoint": "appconfig", "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "Application", "EnvironmentId": "Environment"}, "endpoint": "appconfig", "apis": ["rest-json/2019-10-09"]}, {"type": "application", "fill": {"ApplicationId": "application"}, "endpoint": "appconfigcloudextension", "apis": ["json/2024-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "application", "EnvironmentId": "environment"}, "endpoint": "appconfigcloudextension", "apis": ["json/2024-10-09"]}], "located": {"Application": "{Application}", "Environment": "{Environment}"}},
"appconfig:GetConfigurationProfile": {"action": "appconfig:GetConfigurationProfile", "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:GetDeployment": {"action": "appconfig:GetDeployment", "types": ["application", "deployment", "environment"], "resources": [{"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:GetDeployment": {"action": "appconfig:GetDeployment", "types": ["application", "deployment", "environment"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "deployment", "fill": {"ApplicationId": "ApplicationId", "DeploymentNumber": "DeploymentNumber", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "DeploymentNumber": "{DeploymentNumber}", "EnvironmentId": "{EnvironmentId}"}},
"appconfig:GetDeploymentStrategy": {"action": "appconfig:GetDeploymentStrategy", "types": ["deploymentstrategy"], "resources": [{"type": "deploymentstrategy", "fill": {"DeploymentStrategyId": "DeploymentStrategyId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"DeploymentStrategyId": "{DeploymentStrategyId}"}},
"appconfig:GetEnvironment": {"action": "appconfig:GetEnvironment", "types": ["application", "environment"], "resources": [{"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:GetExperimentDefinition": {"action": "appconfig:GetExperimentDefinition", "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}"}},
@@ -400,7 +400,7 @@
"appconfig:StartConfigurationSession": {"action": "appconfig:StartConfigurationSession", "types": ["configuration"], "resources": [{"type": "application", "fill": {}, "find": ["ApplicationIdentifier"], "apis": ["rest-json/2021-11-11"]}]},
"appconfig:StartDeployment": {"action": "appconfig:StartDeployment", "types": ["application", "configurationprofile", "deploymentstrategy", "environment"], "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"]}, {"type": "deploymentstrategy", "fill": {"DeploymentStrategyId": "DeploymentStrategyId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}], "makes": [{"type": "deployment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}}], "located": {"ApplicationId": "{ApplicationId}", "EnvironmentId": "{EnvironmentId}"}},
"appconfig:StartExperimentRun": {"action": "appconfig:StartExperimentRun", "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:StopDeployment": {"action": "appconfig:StopDeployment", "types": ["application", "deployment", "environment"], "resources": [{"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:StopDeployment": {"action": "appconfig:StopDeployment", "types": ["application", "deployment", "environment"], "resources": [{"type": "application", "fill": {"ApplicationId": "ApplicationId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "deployment", "fill": {"ApplicationId": "ApplicationId", "DeploymentNumber": "DeploymentNumber", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}, {"type": "environment", "fill": {"ApplicationId": "ApplicationId", "EnvironmentId": "EnvironmentId"}, "apis": ["rest-json/2019-10-09"]}], "located": {"ApplicationId": "{ApplicationId}", "DeploymentNumber": "{DeploymentNumber}", "EnvironmentId": "{EnvironmentId}"}},
"appconfig:StopExperimentRun": {"action": "appconfig:StopExperimentRun", "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:TagResource": {"action": "appconfig:TagResource", "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: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}"}},
@@ -25,6 +25,7 @@ import software.amazon.awssdk.services.eks.model.ResourceNotFoundException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
@@ -1065,6 +1066,50 @@ class IamRestRouteEnforcementIntegrationTest {
.post("/configurationsessions").then(), "appconfig:StartConfigurationSession");
}
/**
* AppConfig's {@code GetDeployment} and {@code StopDeployment} are checked on the deployment their path names by
* number, besides its application and environment, as the Service Reference gives the deployment's ARN
* ({@code deployment/${DeploymentNumber}}). A grant on deployment 1 lets a request for it through, written with
* leading zeroes too, which name the same number, and refuses one for deployment 2; a deny on deployment 1 under a
* grant on everything refuses a request for it either way and lets one for deployment 2 through.
*/
@Test
void deploymentCallsAreCheckedOnTheDeploymentTheirPathNumbers() {
String application = adminOf("appconfig").body("{\"Name\":\"route-deployment-" + suffix() + "\"}")
.post("/applications").then().statusCode(201).extract().path("Id");
cleanup.register(() -> adminOf("appconfig").delete("/applications/" + application));
String environment = adminOf("appconfig").body("{\"Name\":\"route-deployment-env\"}")
.post("/applications/" + application + "/environments").then().statusCode(201).extract().path("Id");
String applicationArn = "arn:aws:appconfig:us-east-1:" + ACCOUNT + ":application/" + application;
String environmentArn = applicationArn + "/environment/" + environment;
String deployments = "/applications/" + application + "/environments/" + environment + "/deployments/";
String granted = user("route-deployment-granted");
String denied = user("route-deployment-denied");
List<String> grants = new ArrayList<>();
List<String> denies = new ArrayList<>();
for (String action : new String[] {"appconfig:GetDeployment", "appconfig:StopDeployment"}) {
grants.add(allow(action, applicationArn));
grants.add(allow(action, environmentArn));
grants.add(allow(action, environmentArn + "/deployment/1"));
denies.add("{\"Effect\":\"Deny\",\"Action\":\"" + action + "\",\"Resource\":\"" + environmentArn
+ "/deployment/1\"}");
}
policy(granted, String.join(",", grants));
policy(denied, allow("appconfig:*", "*") + "," + String.join(",", denies));
// Past the check, AppConfig answers that the environment has no such deployment.
for (String number : new String[] {"1", "01"}) {
as(granted, "appconfig").get(deployments + number).then().statusCode(404);
as(granted, "appconfig").delete(deployments + number).then().statusCode(404);
refused(as(denied, "appconfig").get(deployments + number).then(), "appconfig:GetDeployment");
refused(as(denied, "appconfig").delete(deployments + number).then(), "appconfig:StopDeployment");
}
refused(as(granted, "appconfig").get(deployments + "2").then(), "appconfig:GetDeployment");
refused(as(granted, "appconfig").delete(deployments + "2").then(), "appconfig:StopDeployment");
as(denied, "appconfig").get(deployments + "2").then().statusCode(404);
as(denied, "appconfig").delete(deployments + "2").then().statusCode(404);
}
private String createFileSystem() {
String id = adminOf("elasticfilesystem").contentType("application/json")
.body("{\"CreationToken\":\"route-efs-" + suffix() + "\"}")
+27 -4
View File
@@ -201,7 +201,9 @@ Beyond the members' names, botocore's shapes and documentation say what a member
specify a cluster, the default cluster is assumed") names that default then (`defaults`), when it fills the one
variable of that type's format, rather than naming nothing.
A URI or query member can carry the same name-or-ARN alternative as a body member. An integer shape
whose name matches an otherwise unfilled ARN variable (optionally ending in `Number`) supplies that variable.
whose name matches an otherwise unfilled ARN variable (optionally ending in `Number`) supplies that variable, and a
label of a REST path holding an integer fills a variable as a string member does, whatever its shape is named
(AppConfig's `DeploymentNumber`, an `Integer` in `.../deployments/{DeploymentNumber}`, fills `${DeploymentNumber}`).
`integerVariables` records these numeric identifiers so the reader canonicalizes leading zeroes even when the
request gives the whole ARN; string identifiers retain their spelling.
What a request names, this file alone says. A service only looks up what it holds where an entry asks it to
@@ -2159,8 +2161,9 @@ def _reading(model: dict) -> str | None:
def request_members(models: dict[str, dict], operation: str) -> dict[str, str]:
"""The top-level members of the operation's request that hold a string (`Name`) or a list of
strings (`Name[]`), by name, and the ARN members one level inside one (`Name.FieldArn`,
`Name[].FieldArn`), or two inside a structure (`Name.Field.FieldArn`, Glue's
strings (`Name[]`), by name, a label of its path holding an integer, which names what the path names as a string
label does (AppConfig's `DeploymentNumber` in `.../deployments/{DeploymentNumber}`), and the ARN members one level
inside one (`Name.FieldArn`, `Name[].FieldArn`), or two inside a structure (`Name.Field.FieldArn`, Glue's
`CatalogInput.TargetRedshiftCatalog.CatalogArn`), by that path, as the vendored path reads them;
empty for a request this file does not read."""
found: dict[str, str] = {}
@@ -2178,6 +2181,8 @@ def request_members(models: dict[str, dict], operation: str) -> dict[str, str]:
shape = model["shapes"][member["shape"]]
if _strings(model, shape) is not None:
found.setdefault(name, name + _strings(model, shape))
elif _integer_label(model, member):
found.setdefault(name, name)
for path in _nested_arns(model, name, shape):
found.setdefault(path.removesuffix("[]"), path)
return found
@@ -5377,6 +5382,23 @@ def integer_members(models: dict[str, dict], operation: str) -> dict[str, str]:
return {variable: next(iter(names)) for variable, names in candidates.items() if len(names) == 1}
def _integer_label(model: dict, member: dict) -> bool:
"""Whether a request member is a label of its path holding an integer."""
return member.get("location") == "uri" and model["shapes"][member["shape"]]["type"] in ("integer", "long")
def integer_labels(models: dict[str, dict], operation: str) -> set[str]:
"""The labels of the operation's request path that hold an integer, which `request_members` gives as members."""
found: set[str] = set()
for model in models.values():
spec = model["operations"].get(operation, {})
if "input" not in spec or _reading(model) is None:
continue
found |= {name for name, member in model["shapes"][spec["input"]["shape"]].get("members", {}).items()
if _integer_label(model, member)}
return found
def with_integer_members(resources: list[dict], formats: dict[str, str], models: dict[str, dict],
operation: str) -> list[dict]:
"""Fill an otherwise unnamed ARN variable from the integer shape bearing its name."""
@@ -6165,9 +6187,10 @@ def integer_variables(operations: dict[str, dict], namespaces: dict[str, list[st
if namespace not in loaded:
loaded[namespace] = load_models(data, set(namespaces[namespace]))
members = integer_members(loaded[namespace], name)
labels = integer_labels(loaded[namespace], name)
for resource in entry["resources"]:
for variable, member in resource.get("fill", {}).items():
if members.get(variable) == member:
if members.get(variable) == member or member in labels:
types = found.setdefault(namespace, {})
types.setdefault(resource["type"], set()).add(variable)
result = {}
+41 -1
View File
@@ -641,6 +641,45 @@ def test_rest_arn_alternatives_and_integer_shapes_fill_versioned_resources(isola
assert r.validate(document) == ["integerVariables names no ARN variables for svc:productVersion"]
def test_an_integer_path_label_fills_the_variable_it_is_named_as_whatever_its_shape(isolated, tmp_path):
formats = {
"environment": "arn:${Partition}:svc:${Region}:${Account}:application/${ApplicationId}/environment/"
"${EnvironmentId}",
"deployment": "arn:${Partition}:svc:${Region}:${Account}:application/${ApplicationId}/environment/"
"${EnvironmentId}/deployment/${DeploymentNumber}",
}
# AppConfig's GetDeployment: the deployment's number is a label of the path, in botocore's generic `Integer`.
api = model({"GetDeployment": {"ApplicationId": "Id", "EnvironmentId": "Id", "DeploymentNumber": "Integer"},
"PutDeployment": {"ApplicationId": "Id", "EnvironmentId": "Id", "DeploymentNumber": "Integer"}},
"rest-json")
api["shapes"]["Integer"] = {"type": "integer"}
api["shapes"]["Id"] = {"type": "string"}
api["operations"]["GetDeployment"]["http"] = {
"method": "GET", "requestUri": "/applications/{ApplicationId}/environments/{EnvironmentId}/deployments/"
"{DeploymentNumber}"}
for name, member in api["shapes"]["GetDeploymentIn"]["members"].items():
member.update(location="uri", locationName=name)
# The same number in a body names nothing: only a label of the path names what the path names.
api["operations"]["PutDeployment"]["http"] = {
"method": "PUT", "requestUri": "/applications/{ApplicationId}/environments/{EnvironmentId}"}
for name in ("ApplicationId", "EnvironmentId"):
api["shapes"]["PutDeploymentIn"]["members"][name].update(location="uri", locationName=name)
write_models(tmp_path, {"svc": api})
documents = [reference("svc", {"GetDeployment": ["deployment", "environment"],
"PutDeployment": ["deployment", "environment"]}, formats)]
document = r.build(documents, "test", tmp_path, "botocore test")
deployment = {"ApplicationId": "ApplicationId", "DeploymentNumber": "DeploymentNumber",
"EnvironmentId": "EnvironmentId"}
assert [resource["fill"] for resource in document["operations"]["svc:GetDeployment"]["resources"]
if resource.get("type") == "deployment"] == [deployment]
assert document["operations"]["svc:GetDeployment"]["located"]["DeploymentNumber"] == "{DeploymentNumber}"
assert [resource for resource in document["operations"]["svc:PutDeployment"]["resources"]
if resource.get("type") == "deployment"] == []
# The reader canonicalizes the number's leading zeroes, as it does for an integer shape named as the variable.
assert document["integerVariables"] == {"svc": {"deployment": ["DeploymentNumber"]}}
assert r.derive(document, tmp_path) == []
def test_numeric_shapes_do_not_guess_between_members_or_accept_floats():
api = model({"UpdateThing": {"MinCapacity": "Capacity", "MaxCapacity": "Capacity",
"Weight": "WeightNumber"}})
@@ -1576,7 +1615,8 @@ def test_the_vendored_file_is_well_formed():
and "endpoint" in json.dumps(entry) for resource in entry["resources"])
# A state machine's version or alias is checked on the state machine; a Lambda function's is checked qualified.
assert document["unqualified"] == {"ssm": ["parameter"], "states": ["statemachine"]}
assert document["integerVariables"] == {"connect": {"customer-managed-view-version": ["ViewVersion"]},
assert document["integerVariables"] == {"appconfig": {"deployment": ["DeploymentNumber"]},
"connect": {"customer-managed-view-version": ["ViewVersion"]},
"lambda": {"layerVersion": ["LayerVersion"]}}
# Lambda is read whole: a partial ARN names a function, a provisioned concurrency config acts on the version or
# alias its Qualifier names, the action the reference gives it, and AddPermission's SourceAccount is its source's.