Skip to content

Commit

Permalink
no wildcards in handler permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
PatMyron committed Jan 17, 2021
1 parent 32c9c0a commit 893bd03
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/rpdk/core/data_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_file_base_uri(file):
return path.resolve().as_uri()


def load_resource_spec(resource_spec_file): # noqa: C901
def load_resource_spec(resource_spec_file): # pylint: disable=R0912 # noqa: C901
"""Load a resource provider definition from a file, and validate it."""
try:
resource_spec = json.load(resource_spec_file)
Expand Down Expand Up @@ -164,6 +164,14 @@ def load_resource_spec(resource_spec_file): # noqa: C901
"readOnlyProperties cannot be specified by customers and should not overlap with writeOnlyProperties or createOnlyProperties"
)

for handler in resource_spec.get("handlers", []):
for permission in resource_spec.get("handlers", [])[handler]["permissions"]:
if "*" in permission:
LOG.warning(
"Use specific handler permissions instead of using wildcards: %s",
permission,
)

try:
additional_properties_validator.validate(resource_spec)
except ValidationError as e:
Expand Down
21 changes: 21 additions & 0 deletions tests/data/schema/valid/invalid_wildcard_handler_permissions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"typeName" : "AWS::Service::Type",
"description" : "",
"additionalProperties" : false,
"properties" : {
"Property" : {
"type" : "string"
}
},
"readOnlyProperties": [
"/properties/Property"
],
"primaryIdentifier" : [ "/properties/Property" ],
"handlers": {
"create": {
"permissions": [
"service:create*"
]
}
}
}

0 comments on commit 893bd03

Please sign in to comment.