3 D\(D@sddZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z mZejeZdZddgZdZdgZd d d d d dddddddddddddddgZejdZejdZejdZejd ejejBZejd!Zejd"Zejd#Z d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWd>d?d@dMdXdYdZd[d\d]d^d_d`dadbdcgDZ!dddedfdgdhdidjdkdddldmdng Z"dZ#doZ$dpZ%dqZ&drZ'dsdtdudvdwdxdydzgZ(d{d|d}d~dd}dddd}dddd}dddddZ)dddZ*iZ+ddZ,ddZ-ddZ.ddZ/ddZ0e0ddZ1dddZ2ddZ3dS)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) dict_node list_nodestr_nodeztag:yaml.org,2002:mapZRef ConditionzFn::zFn::Ifz us-east-1z us-east-2z us-west-1z us-west-2z ca-central-1z eu-central-1z eu-west-1z eu-west-2zap-northeast-1zap-northeast-2zap-southeast-1zap-southeast-2z ap-south-1z sa-east-1z eu-west-3zap-northeast-3z us-gov-west-1z us-gov-east-1z eu-north-1z ap-east-1z^[a-zA-Z0-9]*$z^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$zU^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$z^(((?=.*(::))(?!.*\3.+\3))\3?|[\dA-F]{1,4}:)([\dA-F]{1,4}(\3|:\b)|\2){5}(([\dA-F]{1,4}(\3|:\b|$)|\2){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\Zz^.*{{resolve:.+}}.*$z,^.*{{resolve:ssm:[a-zA-Z0-9_\.\-/]+:\d+}}.*$z3^.*{{resolve:ssm-secure:[a-zA-Z0-9_\.\-/]+:\d+}}.*$z us-east-1az us-east-1bz us-east-1cz us-east-1dz us-east-1ez us-east-1fz us-east-2az us-east-2bz us-east-2cz us-west-1az us-west-1bz us-west-1cz us-west-2az us-west-2bz us-west-2cz ca-central-1az ca-central-1bz sa-east-1az sa-east-1bz sa-east-1cz eu-west-1az eu-west-1bz eu-west-1cz eu-west-2az eu-west-2bz eu-west-2cz eu-west-3az eu-west-3bz eu-west-3cz eu-central-1az eu-central-1bz eu-central-1cz eu-central-2az eu-central-2bz eu-central-2czap-northeast-1azap-northeast-1bzap-northeast-1czap-northeast-1dzap-northeast-2azap-northeast-2bzap-northeast-3azap-southeast-1azap-southeast-1bzap-southeast-1czap-southeast-2azap-southeast-2bzap-southeast-2cz ap-south-1az ap-south-1bz cn-north-1az cn-north-1bzus-gov-west-1azus-gov-west-1bzus-gov-west-1czus-gov-east-1azus-gov-east-1bzus-gov-east-1cz eu-north-1az eu-north-1bz eu-north-1cz ap-east-1az ap-east-1bz ap-east-1cz Fn::Base64z Fn::GetAttz Fn::GetAZszFn::ImportValuezFn::Joinz Fn::Splitz Fn::FindInMapz Fn::Selectz Fn::ContainszFn::SubzFn::CidrzFn::AndzFn::OrzFn::Notz Fn::EqualszAWS::AccountIdzAWS::NotificationARNsz AWS::NoValuezAWS::Partitionz AWS::Regionz AWS::StackIdzAWS::StackNamezAWS::URLSuffixd@)number attributesname<i)r r descriptioni)r r value)r r i)bodyr )Zmappingsoutputs parameters resourcestemplatedata/CloudSpecs/us-east-1.jsonc Cs*tjt|}t| }tj|SQRXdS)zLoad resourcesN) pkg_resourcesresource_filename__name__openjsonload)filenamefpri/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/helpers.pyload_resources~s  r cCsDx>|jD]2\}}t|tr4|j|i}t||q |||<q W|S)z Recursive merge spec dict )items isinstancedict setdefault merge_spec)sourceZ destinationkeyrnoderrrr%s     r%c sLg}g}d|kr|jd}d|kr,|jd}xtjD] \}}|rTt||t|<tt|djdd}g}|rxL|D]6}tj|jdddfdd |D}|j |q~Wn |dd}|rxN|D]F} tj| jdddfd d |D}x|D]} |j | qWqWx&|D]} | |kr"t|d| =q"Wq8WdS) z Override Resource Specs ZExcludeResourceTypesZIncludeResourceTypesZ ResourceTypesN*z(.*)$csg|]}tj|r|qSr)rematch).0string)regexrr szset_specs..csg|]}tj|r|qSr)r+r,)r-r.)r/rrr0s) popRESOURCE_SPECSr!r%listkeysr+compilereplaceextendremove) Zoverride_spec_dataZexcludesZincludesZregionspecZ all_resourcesrincludematchesexcluder,resourcer)r/r set_specss4        r>cCs|o|dkp|jdS)z3 Return True if resource_type is a custom resource z#AWS::CloudFormation::CustomResourcezCustom::) startswith)Z resource_typerrris_custom_resourcesr@cCs@t|tjrt|jdk}t|tjr8t|jdk}||kS)z# Compare strings to boolean values trueTrue)rArB)rArB)r"six string_typesboollower)firstsecondrrr bool_compares   rIcCs$xtD]}td|dt|<qWdS)z Reload Resource Specs zdata/CloudSpecs/%s.json)rN)REGIONSr r2)regrrrinitialize_specss rLc Csg}d}dd}xtj||dD]\}}}xtj|dD]}|jdd}zttj||g\}}} tj|||| } xJtj | tj D]8\}} tj | } dd | d dDr~| } |j | q~WWd|r|j Xq8Wq W|S) z Load pluginsNcSs|dS)zRaise an errorNr)Zos_errorrrronerrorszload_plugins..onerror)rMz [A-Za-z]*.pyz.pycSs$g|]}|jdkr|jdkr|qS)ZcfnlintZCloudFormationLintRule) __module__r)r-Zclzrrrr0sz load_plugins..)oswalkfnmatchfilterr6imp find_module load_moduleinspect getmembersisclassgetmroappendclose) directoryresultfhrMroot_ filenamesrZ pluginnamedescmodZclazzZmethod_resolutionobjrrr load_pluginss"  rgc Cst|tr|t|ts t|||}x|jjD]H\}}|}|}t|trT|j}|j}t|||}||=t|||||<q.WnFt|t rt|t st |||}x$t |D]\}}t|||||<qW|S)zConvert dict to template) r"r#rcopyr!r start_markend_mark convert_dictr3r enumerate) rrirjkvZ k_start_markZ k_end_markZnew_kirrrrks$        rkcCsy.|}t|}tj|}WdQRXt|Wntk r}zj|jdkrbtjd|tj dnB|jdkrtjd|tj dn |jdkrtjd|tj dWYdd}~Xn:t k r}ztjd ||tj dWYdd}~XnXdS) zOverride specs fileNz Override spec file not found: %srPz9Override spec file references a directory, not a file: %s z7Permission denied when accessing override spec file: %sz&Override spec file %s is malformed: %s) rrrr>IOErrorerrnoLOGGERerrorsysexit ValueError)Zoverride_spec_filerrZcustom_spec_dataeerrrrroverride_specss$          r|)rrrrr)r}r~)4__doc__rwrSrrQrUloggingr+rXrrCZcfnlint.decode.noderrr getLoggerrruZTAG_MAPZUNCONVERTED_SUFFIXESZ FN_PREFIXZCONDITION_FUNCTIONSrJr5ZREGEX_ALPHANUMERICZ REGEX_CIDRZ REGEX_IPV4ISZ REGEX_IPV6Z REGEX_DYN_REFZREGEX_DYN_REF_SSMZREGEX_DYN_REF_SSM_SECUREZAVAILABILITY_ZONESZ FUNCTIONSZ FUNCTION_IFZ FUNCTION_ANDZ FUNCTION_ORZ FUNCTION_NOTZFUNCTION_EQUALSZ PSEUDOPARAMSZLIMITSr r2r%r>r@rIrLrgrkr|rrrrs                0