|
95 | 95 | # https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateRole.html
|
96 | 96 | MIN_ROLE_TIMEOUT_SECONDS = 3600 # 1 hour
|
97 | 97 | MAX_ROLE_TIMEOUT_SECONDS = 43200 # 12 hours
|
| 98 | +MAX_RPDK_CONFIG_LENGTH = 10 * 1024 # 10 KiB |
| 99 | +MAX_CONFIGURATION_SCHEMA_LENGTH = 60 * 1024 # 60 KiB |
| 100 | + |
| 101 | +PROTOCOL_VERSION_VALUES = frozenset({"1.0.0", "2.0.0"}) |
98 | 102 |
|
99 | 103 | CFN_METADATA_FILENAME = ".cfn_metadata.json"
|
100 | 104 |
|
@@ -282,6 +286,31 @@ def load_settings(self):
|
282 | 286 | f"Project file '{self.settings_path}' is invalid", e
|
283 | 287 | )
|
284 | 288 |
|
| 289 | + # check size of RPDK config |
| 290 | + if len(json.dumps(raw_settings).encode("utf-8")) > MAX_RPDK_CONFIG_LENGTH: |
| 291 | + raise InvalidProjectError( |
| 292 | + f"Project file '{self.settings_path}' exceeds maximum length of 10 KiB." |
| 293 | + ) |
| 294 | + # validate protocol version, if specified |
| 295 | + try: |
| 296 | + settings = raw_settings["settings"] |
| 297 | + if "protocolVersion" in settings: |
| 298 | + protocol_version = settings["protocolVersion"] |
| 299 | + if protocol_version not in PROTOCOL_VERSION_VALUES: |
| 300 | + raise InvalidProjectError( |
| 301 | + f"Invalid 'protocolVersion' settings in '{self.settings_path}" |
| 302 | + ) |
| 303 | + else: |
| 304 | + LOG.warning( |
| 305 | + "No protovolVersion found: this will default to version 1.0.0 during registration. " |
| 306 | + "Please consider upgrading to CFN-CLI 2.0 following the guide: " |
| 307 | + "https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html" |
| 308 | + ) |
| 309 | + except KeyError: |
| 310 | + raise InvalidProjectError( |
| 311 | + f"Error extracting protocol version from '{self.settings_path}'" |
| 312 | + ) |
| 313 | + |
285 | 314 | # backward compatible
|
286 | 315 | if "artifact_type" not in raw_settings:
|
287 | 316 | raw_settings["artifact_type"] = ARTIFACT_TYPE_RESOURCE
|
|
0 commit comments