cfn-model 0.4.26 → 0.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5feb1962cc34b035503b0359a30d5dbbfd55d23f2c6753c8a4ede574f49d32e
|
4
|
+
data.tar.gz: 33e6ffd7bd6c8b543f696176b02e1443ddac8924ddaac58bd24a49bdeb8d820a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e411bd196fbfcb2e372c1e46bb6be0dad34c94193e2fdd182092f090f63617e8df3f4942b5b076cfb272b82fe05a6a0515b408a873119b932f925f19d34b20d4
|
7
|
+
data.tar.gz: 40eeee5ae68f71008117469f9aa4639b40770c997657d28a4b048377d59e926d5c3c2128e65dbf4e06f4dc39c65a18043d581273b9bad0218f1223217a70825b
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'model_element'
|
4
|
+
|
5
|
+
class AWS::EC2::NetworkAcl < ModelElement
|
6
|
+
attr_accessor :network_acl_egress_entries
|
7
|
+
attr_accessor :network_acl_ingress_entries
|
8
|
+
|
9
|
+
def initialize(cfn_model)
|
10
|
+
super
|
11
|
+
@network_acl_egress_entries = []
|
12
|
+
@network_acl_ingress_entries = []
|
13
|
+
@resource_type = 'AWS::EC2::NetworkAcl'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'parser_error'
|
4
|
+
require 'cfn-model/model/ec2_network_acl'
|
5
|
+
require 'cfn-model/model/references'
|
6
|
+
require 'cfn-model/util/truthy'
|
7
|
+
|
8
|
+
class Ec2NetworkAclParser
|
9
|
+
def parse(cfn_model:, resource:)
|
10
|
+
network_acl = resource
|
11
|
+
|
12
|
+
attach_nacl_entries_to_nacl(cfn_model: cfn_model, network_acl: network_acl)
|
13
|
+
network_acl
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def egress_network_acl_entries(cfn_model)
|
19
|
+
network_acl_entries = cfn_model.resources_by_type 'AWS::EC2::NetworkAclEntry'
|
20
|
+
network_acl_entries.select(&:egress)
|
21
|
+
end
|
22
|
+
|
23
|
+
def ingress_network_acl_entries(cfn_model)
|
24
|
+
network_acl_entries = cfn_model.resources_by_type 'AWS::EC2::NetworkAclEntry'
|
25
|
+
network_acl_entries.select do |network_acl_entry|
|
26
|
+
not_truthy?(network_acl_entry.egress)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def egress_nacl_entries_for_nacl(cfn_model, logical_resource_id)
|
31
|
+
egress_nacl_entries = egress_network_acl_entries(cfn_model)
|
32
|
+
egress_nacl_entries.select do |egress_nacl_entry|
|
33
|
+
References.resolve_resource_id(egress_nacl_entry.networkAclId) == logical_resource_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def ingress_nacl_entries_for_nacl(cfn_model, logical_resource_id)
|
38
|
+
ingress_nacl_entries = ingress_network_acl_entries(cfn_model)
|
39
|
+
ingress_nacl_entries.select do |ingress_nacl_entry|
|
40
|
+
References.resolve_resource_id(ingress_nacl_entry.networkAclId) == logical_resource_id
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def attach_nacl_entries_for_nacl(cfn_model, network_acl)
|
45
|
+
egress_nacl_entries_for_nacl(cfn_model, network_acl.logical_resource_id).each do |egress_entry|
|
46
|
+
network_acl.network_acl_egress_entries << egress_entry.logical_resource_id
|
47
|
+
end
|
48
|
+
ingress_nacl_entries_for_nacl(cfn_model, network_acl.logical_resource_id).each do |ingress_entry|
|
49
|
+
network_acl.network_acl_ingress_entries << ingress_entry.logical_resource_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def attach_nacl_entries_to_nacl(cfn_model:, network_acl:)
|
54
|
+
attach_nacl_entries_for_nacl(cfn_model, network_acl)
|
55
|
+
end
|
56
|
+
end
|
@@ -23,7 +23,8 @@ class ParserRegistry
|
|
23
23
|
'AWS::SNS::TopicPolicy' => WithPolicyDocumentParser,
|
24
24
|
'AWS::SQS::QueuePolicy' => WithPolicyDocumentParser,
|
25
25
|
'AWS::ApiGateway::Stage' => ApiGatewayStageParser,
|
26
|
-
'AWS::ApiGateway::Deployment' => ApiGatewayDeploymentParser
|
26
|
+
'AWS::ApiGateway::Deployment' => ApiGatewayDeploymentParser,
|
27
|
+
'AWS::EC2::NetworkAcl' => Ec2NetworkAclParser
|
27
28
|
}
|
28
29
|
end
|
29
30
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Checks a string for truthiness. Any cased 'true' will evaluate to a true boolean.
|
4
|
+
# Any other string _at all_ results in false.
|
5
|
+
def truthy?(string)
|
6
|
+
string.to_s.casecmp('true').zero?
|
7
|
+
end
|
8
|
+
|
9
|
+
def not_truthy?(string)
|
10
|
+
string.nil? || string.to_s.casecmp('false').zero?
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/cfn-model/model/bucket_policy.rb
|
67
67
|
- lib/cfn-model/model/cfn_model.rb
|
68
68
|
- lib/cfn-model/model/ec2_instance.rb
|
69
|
+
- lib/cfn-model/model/ec2_network_acl.rb
|
69
70
|
- lib/cfn-model/model/ec2_network_interface.rb
|
70
71
|
- lib/cfn-model/model/iam_group.rb
|
71
72
|
- lib/cfn-model/model/iam_managed_policy.rb
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- lib/cfn-model/parser/api_gateway_stage_parser.rb
|
94
95
|
- lib/cfn-model/parser/cfn_parser.rb
|
95
96
|
- lib/cfn-model/parser/ec2_instance_parser.rb
|
97
|
+
- lib/cfn-model/parser/ec2_network_acl_parser.rb
|
96
98
|
- lib/cfn-model/parser/ec2_network_interface_parser.rb
|
97
99
|
- lib/cfn-model/parser/expression_evaluator.rb
|
98
100
|
- lib/cfn-model/parser/iam_group_parser.rb
|
@@ -134,6 +136,7 @@ files:
|
|
134
136
|
- lib/cfn-model/schema/AWS_SQS_QueuePolicy.yml
|
135
137
|
- lib/cfn-model/schema/schema.yml.erb
|
136
138
|
- lib/cfn-model/transforms/serverless.rb
|
139
|
+
- lib/cfn-model/util/truthy.rb
|
137
140
|
- lib/cfn-model/util/wildcard_patterns.rb
|
138
141
|
- lib/cfn-model/validator/cloudformation_validator.rb
|
139
142
|
- lib/cfn-model/validator/reference_validator.rb
|