Skip to content

Commit 6918363

Browse files
authored
Fix an issue with graphs and not quoting attrs (#3177)
1 parent 5c4f1b1 commit 6918363

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/cfnlint/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GraphSettings:
4646
def subgraph_view(self, graph) -> networkx.MultiDiGraph:
4747
view = networkx.MultiDiGraph(name="template")
4848
resources: List[str] = [
49-
n for n, v in graph.nodes.items() if v["type"] in ["Resource"]
49+
n for n, v in graph.nodes.items() if v["type"] in ['"Resource"']
5050
]
5151
view.add_nodes_from((n, graph.nodes[n]) for n in resources)
5252
view.add_edges_from(
@@ -247,7 +247,7 @@ def _add_node(self, node_id, label, settings):
247247
label=label,
248248
color=settings.color,
249249
shape=settings.shape,
250-
type=settings.node_type,
250+
type=f'"{settings.node_type}"',
251251
)
252252

253253
def _add_edge(self, source_id, target_id, source_path, settings):

src/cfnlint/rules/resources/CircularDependency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def match(self, cfn):
2323
for cycle in cfn.graph.get_cycles(cfn):
2424
source, target = cycle[:2]
2525
if (
26-
cfn.graph.graph.nodes[source].get("type") == "Resource"
27-
and cfn.graph.graph.nodes[target].get("type") == "Resource"
26+
cfn.graph.graph.nodes[source].get("type") == '"Resource"'
27+
and cfn.graph.graph.nodes[target].get("type") == '"Resource"'
2828
):
2929
message = f"Circular Dependencies for resource {source}. Circular dependency with [{target}]"
3030
path = ["Resources", source]

test/unit/module/test_template.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ def test_build_graph(self):
4040
dot = "test/fixtures/templates/good/generic.yaml.dot"
4141

4242
expected_content = """digraph "template" {
43-
MyModule [color=black, label="MyModule\\n<My::Organization::Custom::MODULE>", shape=ellipse, type=Resource];
44-
RootRole [color=black, label="RootRole\\n<AWS::IAM::Role>", shape=ellipse, type=Resource];
45-
RolePolicies [color=black, label="RolePolicies\\n<AWS::IAM::Policy>", shape=ellipse, type=Resource];
46-
RootInstanceProfile [color=black, label="RootInstanceProfile\\n<AWS::IAM::InstanceProfile>", shape=ellipse, type=Resource];
47-
MyEC2Instance [color=black, label="MyEC2Instance\\n<AWS::EC2::Instance>", shape=ellipse, type=Resource];
48-
mySnsTopic [color=black, label="mySnsTopic\\n<AWS::SNS::Topic>", shape=ellipse, type=Resource];
49-
MyEC2Instance1 [color=black, label="MyEC2Instance1\\n<AWS::EC2::Instance>", shape=ellipse, type=Resource];
50-
ElasticIP [color=black, label="ElasticIP\\n<AWS::EC2::EIP>", shape=ellipse, type=Resource];
51-
ElasticLoadBalancer [color=black, label="ElasticLoadBalancer\\n<AWS::ElasticLoadBalancing::LoadBalancer>", shape=ellipse, type=Resource];
52-
IamPipeline [color=black, label="IamPipeline\\n<AWS::CloudFormation::Stack>", shape=ellipse, type=Resource];
53-
CustomResource [color=black, label="CustomResource\\n<Custom::Function>", shape=ellipse, type=Resource];
54-
WaitCondition [color=black, label="WaitCondition\\n<AWS::CloudFormation::WaitCondition>", shape=ellipse, type=Resource];
55-
LambdaFunction [color=black, label="LambdaFunction\\n<AWS::Lambda::Function>", shape=ellipse, type=Resource];
43+
MyModule [color=black, label="MyModule\\n<My::Organization::Custom::MODULE>", shape=ellipse, type="Resource"];
44+
RootRole [color=black, label="RootRole\\n<AWS::IAM::Role>", shape=ellipse, type="Resource"];
45+
RolePolicies [color=black, label="RolePolicies\\n<AWS::IAM::Policy>", shape=ellipse, type="Resource"];
46+
RootInstanceProfile [color=black, label="RootInstanceProfile\\n<AWS::IAM::InstanceProfile>", shape=ellipse, type="Resource"];
47+
MyEC2Instance [color=black, label="MyEC2Instance\\n<AWS::EC2::Instance>", shape=ellipse, type="Resource"];
48+
mySnsTopic [color=black, label="mySnsTopic\\n<AWS::SNS::Topic>", shape=ellipse, type="Resource"];
49+
MyEC2Instance1 [color=black, label="MyEC2Instance1\\n<AWS::EC2::Instance>", shape=ellipse, type="Resource"];
50+
ElasticIP [color=black, label="ElasticIP\\n<AWS::EC2::EIP>", shape=ellipse, type="Resource"];
51+
ElasticLoadBalancer [color=black, label="ElasticLoadBalancer\\n<AWS::ElasticLoadBalancing::LoadBalancer>", shape=ellipse, type="Resource"];
52+
IamPipeline [color=black, label="IamPipeline\\n<AWS::CloudFormation::Stack>", shape=ellipse, type="Resource"];
53+
CustomResource [color=black, label="CustomResource\\n<Custom::Function>", shape=ellipse, type="Resource"];
54+
WaitCondition [color=black, label="WaitCondition\\n<AWS::CloudFormation::WaitCondition>", shape=ellipse, type="Resource"];
55+
LambdaFunction [color=black, label="LambdaFunction\\n<AWS::Lambda::Function>", shape=ellipse, type="Resource"];
5656
RolePolicies -> RootRole [color=black, key=0, label=Ref, source_paths="['Properties', 'Roles', 0]"];
5757
RootInstanceProfile -> RootRole [color=black, key=0, label=Ref, source_paths="['Properties', 'Roles', 0]"];
5858
MyEC2Instance -> RootInstanceProfile [color=black, key=0, label=Ref, source_paths="['Properties', 'IamInstanceProfile']"];

0 commit comments

Comments
 (0)