3 D\x@sDdZddlZddlmZddlmZddlmZGdddeZdS)a Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. N)CloudFormationLintRule) RuleMatch)LIMITSc@s0eZdZdZdZdZdZdZddgZdd Z d S) LimitValuez7Check if maximum Parameter value size limit is exceededZE2012z"Parameter value limit not exceededzRCheck if the size of Parameter values in the template is less than the upper limitzYhttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html parametersZlimitsc Csjg}tdd}xR|jjD]@\}}|jd}t|tjtjfr|t||kr|d|dg}d}|j t ||j t|||jdd} t| tjtjfry t | } Wnt k rd} YnXt| tjr| |krd|dg}d}|j t ||j | ||jd g} xZ| D]R} t| tjtjfr t| |kr d|d g}d }|j t ||j t| |q Wq W|S) zCheck CloudFormation ParametersrvalueZDefaultZ ParameterszCThe length of parameter default value ({0}) exceeds the limit ({1})Z MaxLengthrz8The MaxLength of parameter ({0}) exceeds the limit ({1})Z AllowedValueszCThe length of parameter allowed value ({0}) exceeds the limit ({1}))rZget_parametersitemsget isinstancesix text_type string_typeslenappendrformatint ValueError integer_types) selfZcfnmatchesZ value_limitZ paramnameZ paramvalue default_valuepathmessage max_lengthZallowed_valuesZ allowed_valuer}/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/parameters/LimitValue.pymatchs8            &zLimitValue.matchN) __name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrrrrrrsr)r r ZcfnlintrrZcfnlint.helpersrrrrrrs