404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.141.167.59: ~ $
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
import regex as re

from cfnlint.helpers import LIMITS, REGEX_ALPHANUMERIC
from cfnlint.rules import RuleMatch


def approaching_name_limit(cfn, section):
    matches = []
    for name in cfn.template.get(section, {}):
        if (
            LIMITS["threshold"] * LIMITS[section]["name"]
            < len(name)
            <= LIMITS[section]["name"]
        ):
            message = (
                "The length of "
                + section[:-1]
                + " name ({0}) is approaching the limit ({1})"
            )
            matches.append(
                RuleMatch(
                    [section, name], message.format(len(name), LIMITS[section]["name"])
                )
            )
    return matches


def approaching_number_limit(cfn, section):
    matches = []
    number = (
        cfn.get_resources() if section == "Resources" else cfn.template.get(section, {})
    )
    if (
        LIMITS["threshold"] * LIMITS[section]["number"]
        < len(number)
        <= LIMITS[section]["number"]
    ):
        message = "The number of " + section + " ({0}) is approaching the limit ({1})"
        matches.append(
            RuleMatch([section], message.format(len(number), LIMITS[section]["number"]))
        )
    return matches


def name_limit(cfn, section):
    matches = []
    for name in cfn.template.get(section, {}):
        if len(name) > LIMITS[section]["name"]:
            message = (
                "The length of " + section[:-1] + " name ({0}) exceeds the limit ({1})"
            )
            matches.append(
                RuleMatch(
                    [section, name], message.format(len(name), LIMITS[section]["name"])
                )
            )
    return matches


def number_limit(cfn, section):
    matches = []
    number = (
        cfn.get_resources() if section == "Resources" else cfn.template.get(section, {})
    )
    if len(number) > LIMITS[section]["number"]:
        message = "The number of " + section + " ({0}) exceeds the limit ({1})"
        matches.append(
            RuleMatch([section], message.format(len(number), LIMITS[section]["number"]))
        )
    return matches


def alphanumeric_name(cfn, section):
    matches = []
    for name, _ in cfn.template.get(section, {}).items():
        if not re.match(REGEX_ALPHANUMERIC, name):
            message = (
                section[:-1] + " {0} has invalid name.  Name has to be alphanumeric."
            )
            matches.append(RuleMatch([section, name], message.format(name)))
    return matches

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
conditions Folder 0755
custom Folder 0755
functions Folder 0755
mappings Folder 0755
metadata Folder 0755
outputs Folder 0755
parameters Folder 0755
resources Folder 0755
templates Folder 0755
__init__.py File 27.17 KB 0644
common.py File 2.58 KB 0644