404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.119.100.196: ~ $
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from cfnlint.rules import CloudFormationLintRule, RuleMatch


class ImportValue(CloudFormationLintRule):
    """Check if ImportValue values are correct"""

    id = "E1016"
    shortdesc = "ImportValue validation of parameters"
    description = "Making sure the ImportValue function is properly configured"
    source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html"
    tags = ["functions", "importvalue"]

    def match(self, cfn):
        matches = []

        iv_objs = cfn.search_deep_keys("Fn::ImportValue")

        supported_functions = [
            "Fn::Base64",
            "Fn::FindInMap",
            "Fn::If",
            "Fn::Join",
            "Fn::Select",
            "Fn::Split",
            "Fn::Sub",
            "Ref",
        ]

        unsupported_locations = ["Conditions"]

        for iv_obj in iv_objs:
            iv_value = iv_obj[-1]
            tree = iv_obj[:-1]
            if iv_obj[0] in unsupported_locations:
                message = "ImportValue cannot be used inside {0} at {1}"
                matches.append(
                    RuleMatch(
                        tree, message.format(iv_obj[0], "/".join(map(str, tree[:-1])))
                    )
                )
            if isinstance(iv_value, dict):
                if len(iv_value) == 1:
                    for key, _ in iv_value.items():
                        if key not in supported_functions:
                            message = (
                                "ImportValue should be using supported function for {0}"
                            )
                            matches.append(
                                RuleMatch(
                                    tree, message.format("/".join(map(str, tree[:-1])))
                                )
                            )
                else:
                    message = "ImportValue should have one mapping for {0}"
                    matches.append(
                        RuleMatch(tree, message.format("/".join(map(str, tree[:-1]))))
                    )
            elif not isinstance(iv_value, str):
                message = "ImportValue should have supported function or string for {0}"
                matches.append(
                    RuleMatch(tree, message.format("/".join(map(str, tree))))
                )
        return matches

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
Base64.py File 1.72 KB 0644
Cidr.py File 11.94 KB 0644
DynamicReferenceSecureString.py File 5.72 KB 0644
FindInMap.py File 11.25 KB 0644
FindInMapKeys.py File 3.89 KB 0644
GetAtt.py File 6.05 KB 0644
GetAz.py File 2.76 KB 0644
If.py File 1.45 KB 0644
ImportValue.py File 2.45 KB 0644
Join.py File 8.63 KB 0644
Length.py File 3.31 KB 0644
Not.py File 978 B 0644
Ref.py File 1.02 KB 0644
RefExist.py File 1.26 KB 0644
RefInCondition.py File 1.36 KB 0644
RelationshipConditions.py File 5.35 KB 0644
Select.py File 4.41 KB 0644
Split.py File 3.11 KB 0644
Sub.py File 9.49 KB 0644
SubNeeded.py File 5.48 KB 0644
SubNotJoin.py File 2 KB 0644
SubParametersUsed.py File 1.4 KB 0644
SubUnneeded.py File 1.27 KB 0644
ToJsonString.py File 1.75 KB 0644
__init__.py File 106 B 0644