cfn-model 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfn-model.rb +2 -0
- data/lib/cfn-model/model/bucket_policy.rb +1 -0
- data/lib/cfn-model/model/cfn_model.rb +2 -0
- data/lib/cfn-model/model/ec2_instance.rb +2 -0
- data/lib/cfn-model/model/ec2_network_interface.rb +2 -0
- data/lib/cfn-model/model/iam_group.rb +2 -0
- data/lib/cfn-model/model/iam_managed_policy.rb +2 -0
- data/lib/cfn-model/model/iam_policy.rb +2 -0
- data/lib/cfn-model/model/iam_role.rb +2 -0
- data/lib/cfn-model/model/iam_user.rb +2 -0
- data/lib/cfn-model/model/lambda_principal.rb +2 -0
- data/lib/cfn-model/model/load_balancer.rb +2 -0
- data/lib/cfn-model/model/model_element.rb +2 -0
- data/lib/cfn-model/model/parameter.rb +2 -0
- data/lib/cfn-model/model/policy.rb +2 -0
- data/lib/cfn-model/model/policy_document.rb +2 -0
- data/lib/cfn-model/model/principal.rb +2 -0
- data/lib/cfn-model/model/queue_policy.rb +2 -0
- data/lib/cfn-model/model/references.rb +1 -0
- data/lib/cfn-model/model/security_group.rb +2 -0
- data/lib/cfn-model/model/security_group_egress.rb +2 -0
- data/lib/cfn-model/model/security_group_ingress.rb +2 -0
- data/lib/cfn-model/model/statement.rb +2 -0
- data/lib/cfn-model/model/topic_policy.rb +2 -0
- data/lib/cfn-model/monkey_patches/psych/nodes/node.rb +2 -0
- data/lib/cfn-model/parser/cfn_parser.rb +4 -1
- data/lib/cfn-model/parser/ec2_instance_parser.rb +2 -0
- data/lib/cfn-model/parser/ec2_network_interface_parser.rb +2 -0
- data/lib/cfn-model/parser/iam_group_parser.rb +2 -0
- data/lib/cfn-model/parser/iam_role_parser.rb +2 -0
- data/lib/cfn-model/parser/iam_user_parser.rb +2 -0
- data/lib/cfn-model/parser/load_balancer_parser.rb +2 -0
- data/lib/cfn-model/parser/load_balancer_v2_parser.rb +2 -0
- data/lib/cfn-model/parser/parameter_substitution.rb +2 -0
- data/lib/cfn-model/parser/parser_error.rb +2 -0
- data/lib/cfn-model/parser/parser_registry.rb +2 -0
- data/lib/cfn-model/parser/policy_document_parser.rb +2 -0
- data/lib/cfn-model/parser/security_group_parser.rb +4 -2
- data/lib/cfn-model/parser/transform_registry.rb +2 -0
- data/lib/cfn-model/parser/with_policy_document_parser.rb +2 -0
- data/lib/cfn-model/psych/handlers/line_number_handler.rb +2 -0
- data/lib/cfn-model/psych/visitors/to_ruby_with_line_numbers.rb +3 -1
- data/lib/cfn-model/transforms/serverless.rb +2 -0
- data/lib/cfn-model/validator/cloudformation_validator.rb +5 -3
- data/lib/cfn-model/validator/reference_validator.rb +2 -0
- data/lib/cfn-model/validator/resource_type_validator.rb +4 -2
- data/lib/cfn-model/validator/schema_generator.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e39e1e4457d48accfce980b48675a4c4621e2a4c53361ed04585ce3daa552d7e
|
4
|
+
data.tar.gz: 67b896b4f06c5098b35967a0b4ec08d0561f7e9c9fd8ac42cf6cc5b93db6f4e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8acf757dd507bd6e02e029975b1eabc2f24d1bd9cc78754d3e8dc823cb159fdb6a76d795b1db935aa6ceccee71955abbda11727936c6c4a9f820de7131627a28
|
7
|
+
data.tar.gz: 44d4ae7825f11a8e1bb09d37c340f7d8a29bdd5ee85729356dd912b847b6118a2d7c7e56a81f2baa72e1816b1ad71a79bf453e8456750d2c96828b96e082a501
|
data/lib/cfn-model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'psych'
|
3
5
|
require 'json'
|
@@ -142,7 +144,7 @@ class CfnParser
|
|
142
144
|
end
|
143
145
|
|
144
146
|
def transform_hash_into_parameters(cfn_hash, cfn_model)
|
145
|
-
return cfn_model unless cfn_hash.
|
147
|
+
return cfn_model unless cfn_hash.key?('Parameters')
|
146
148
|
|
147
149
|
cfn_hash['Parameters'].each do |parameter_name, parameter_hash|
|
148
150
|
parameter = Parameter.new
|
@@ -176,6 +178,7 @@ class CfnParser
|
|
176
178
|
def assign_fields_based_upon_properties(resource_object, resource)
|
177
179
|
unless resource['Properties'].nil?
|
178
180
|
resource['Properties'].each do |property_name, property_value|
|
181
|
+
next if %w(Fn::Transform).include? property_name
|
179
182
|
resource_object.send("#{map_property_name_to_attribute(property_name)}=", property_value)
|
180
183
|
end
|
181
184
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'parser_error'
|
2
4
|
require 'cfn-model/model/security_group_egress'
|
3
5
|
require 'cfn-model/model/security_group_ingress'
|
@@ -34,7 +36,7 @@ class SecurityGroupParser
|
|
34
36
|
security_group.ingresses = security_group.securityGroupIngress.map do |ingress|
|
35
37
|
mapped_at_least_one_attribute = false
|
36
38
|
ingress_object = AWS::EC2::SecurityGroupIngress.new cfn_model
|
37
|
-
ingress.each do |k,v|
|
39
|
+
ingress.each do |k, v|
|
38
40
|
silently_fail do
|
39
41
|
ingress_object.send("#{initialLower(k)}=", v)
|
40
42
|
mapped_at_least_one_attribute = true
|
@@ -54,7 +56,7 @@ class SecurityGroupParser
|
|
54
56
|
mapped_at_least_one_attribute = false
|
55
57
|
|
56
58
|
egress_object = AWS::EC2::SecurityGroupEgress.new cfn_model
|
57
|
-
egress.each do |k,v|
|
59
|
+
egress.each do |k, v|
|
58
60
|
next if k.match /::/
|
59
61
|
silently_fail do
|
60
62
|
egress_object.send("#{initialLower(k)}=", v)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class ToRubyWithLineNumbers < Psych::Visitors::ToRuby
|
2
4
|
def revive_hash hash, o
|
3
5
|
o.children.each_slice(2) { |k,v|
|
@@ -10,7 +12,7 @@ class ToRubyWithLineNumbers < Psych::Visitors::ToRuby
|
|
10
12
|
# This is the important bit. If the value is a scalar,
|
11
13
|
# we replace it with the desired hash.
|
12
14
|
if v.is_a?(::Psych::Nodes::Scalar) && key == 'Type'
|
13
|
-
val = { "value" => val, "line" => line}
|
15
|
+
val = { "value" => val, "line" => line }
|
14
16
|
end
|
15
17
|
|
16
18
|
hash[key] = val
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'schema_generator'
|
2
4
|
require 'kwalify'
|
3
5
|
require 'json'
|
@@ -10,7 +12,7 @@ class CloudFormationValidator
|
|
10
12
|
|
11
13
|
schema = SchemaGenerator.new.generate cloudformation_string
|
12
14
|
validator = Kwalify::Validator.new(schema)
|
13
|
-
validator.validate(YAML.
|
15
|
+
validator.validate(YAML.safe_load(cloudformation_string))
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
@@ -23,8 +25,8 @@ class CloudFormationValidator
|
|
23
25
|
|
24
26
|
def valid_json?(cloudformation_string)
|
25
27
|
JSON.parse(cloudformation_string)
|
26
|
-
|
28
|
+
true
|
27
29
|
rescue JSON::ParserError => error
|
28
|
-
|
30
|
+
false
|
29
31
|
end
|
30
32
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cfn-model/parser/parser_error'
|
2
4
|
|
3
5
|
class ResourceTypeValidator
|
4
6
|
|
5
7
|
def self.validate(cloudformation_yml)
|
6
|
-
hash = YAML.
|
8
|
+
hash = YAML.safe_load cloudformation_yml
|
7
9
|
if hash == false || hash.nil?
|
8
10
|
raise ParserError.new 'yml empty'
|
9
11
|
end
|
@@ -31,4 +33,4 @@ class ResourceTypeValidator
|
|
31
33
|
|
32
34
|
hash
|
33
35
|
end
|
34
|
-
end
|
36
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'resource_type_validator'
|
2
4
|
require 'yaml'
|
3
5
|
|
@@ -17,7 +19,7 @@ class SchemaGenerator
|
|
17
19
|
parameters_schema = generate_schema_for_parameter_keys cloudformation_hash
|
18
20
|
resources_schema = generate_schema_for_resource_keys cloudformation_hash
|
19
21
|
|
20
|
-
main_schema = YAML.
|
22
|
+
main_schema = YAML.safe_load IO.read(schema_file('schema.yml.erb'))
|
21
23
|
if parameters_schema.empty?
|
22
24
|
main_schema['mapping'].delete 'Parameters'
|
23
25
|
else
|
@@ -37,10 +39,10 @@ class SchemaGenerator
|
|
37
39
|
return {} if cloudformation_hash['Parameters'].nil?
|
38
40
|
|
39
41
|
parameters_schema = {
|
40
|
-
'=' => { 'type' => 'any'}
|
42
|
+
'=' => { 'type' => 'any' }
|
41
43
|
}
|
42
44
|
|
43
|
-
cloudformation_hash['Parameters'].each do |parameter_key,
|
45
|
+
cloudformation_hash['Parameters'].each do |parameter_key, _|
|
44
46
|
parameters_schema[parameter_key] = {
|
45
47
|
'type' => 'map',
|
46
48
|
'mapping' => {
|
@@ -58,7 +60,7 @@ class SchemaGenerator
|
|
58
60
|
|
59
61
|
def generate_schema_for_resource_keys(cloudformation_hash)
|
60
62
|
resources_schema = {
|
61
|
-
'=' => { 'type' => 'any'}
|
63
|
+
'=' => { 'type' => 'any' }
|
62
64
|
}
|
63
65
|
|
64
66
|
cloudformation_hash['Resources'].each do |resource_id, resource|
|
@@ -80,7 +82,7 @@ class SchemaGenerator
|
|
80
82
|
if !File.exist? schema_file_path
|
81
83
|
nil
|
82
84
|
else
|
83
|
-
YAML.
|
85
|
+
YAML.safe_load IO.read(schema_file_path)
|
84
86
|
end
|
85
87
|
end
|
86
|
-
end
|
88
|
+
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|