cfn-model 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0cbaafa5aae88b900b524e178ee2e5bec99731b
4
- data.tar.gz: a1164ab6d3ae88048d64947cbb93525ca91428b2
3
+ metadata.gz: cdec50eea8f3b51b3fc47b7f368d9d7e565c24e0
4
+ data.tar.gz: 13b9c905e65a89ecbc42e25045405aef019d2da1
5
5
  SHA512:
6
- metadata.gz: 2ba1540435edacfb4fbce29732dba05a906f54748cb34b4ee447869555039435218dcab4c90358104c0570343796d4b0769b8893888885b91c8a1a2f79dcb209
7
- data.tar.gz: 6a74580eea614d32f70c43c17a0dbcf0a1595185540da305bf91622ec29990c2d1050f06f1996d081b9373cae8d9efac874c22ef12d94d9b351fd3a8519c290b
6
+ metadata.gz: 9915d60450bf8b009d175be74e042a3f221bff28d8cf8666cde8b22996cd5249d39f7c453ff2c7acd2ebdb835c087b1969c37418c669307e9d5c6b0b40590bb2
7
+ data.tar.gz: 842de4725ae80c7f49c3d463fd2d37e6f52ebcc6c5b8e5db7c121fcffe63c0fd0c017125ac39c4be59c8ab843424a8f295a6b6be820158af0cfaed6b8a02b23f
@@ -7,11 +7,13 @@ class IamGroupParser
7
7
  iam_group = resource
8
8
 
9
9
  iam_group.policy_objects = iam_group.policies.map do |policy|
10
+ next unless policy.has_key? 'PolicyName'
11
+
10
12
  new_policy = Policy.new
11
13
  new_policy.policy_name = policy['PolicyName']
12
14
  new_policy.policy_document = PolicyDocumentParser.new.parse(policy['PolicyDocument'])
13
15
  new_policy
14
- end
16
+ end.reject { |policy| policy.nil? }
15
17
  iam_group
16
18
  end
17
19
  end
@@ -9,11 +9,13 @@ class IamRoleParser
9
9
  iam_role.assume_role_policy_document = PolicyDocumentParser.new.parse(iam_role.assumeRolePolicyDocument)
10
10
 
11
11
  iam_role.policy_objects = iam_role.policies.map do |policy|
12
+ next unless policy.has_key? 'PolicyName'
13
+
12
14
  new_policy = Policy.new
13
15
  new_policy.policy_name = policy['PolicyName']
14
16
  new_policy.policy_document = PolicyDocumentParser.new.parse(policy['PolicyDocument'])
15
17
  new_policy
16
- end
18
+ end.reject { |policy| policy.nil? }
17
19
 
18
20
  iam_role
19
21
  end
@@ -7,11 +7,13 @@ class IamUserParser
7
7
  iam_user = resource
8
8
 
9
9
  iam_user.policy_objects = iam_user.policies.map do |policy|
10
+ next unless policy.has_key? 'PolicyName'
11
+
10
12
  new_policy = Policy.new
11
13
  new_policy.policy_name = policy['PolicyName']
12
14
  new_policy.policy_document = PolicyDocumentParser.new.parse(policy['PolicyDocument'])
13
15
  new_policy
14
- end
16
+ end.reject { |policy| policy.nil? }
15
17
 
16
18
  iam_user.groups.each { |group_name| iam_user.group_names << group_name }
17
19
 
@@ -19,19 +19,30 @@ class SecurityGroupParser
19
19
 
20
20
  private
21
21
 
22
+ def silently_fail
23
+ begin
24
+ yield
25
+ rescue
26
+ end
27
+ end
28
+
22
29
  def objectify_ingress(security_group)
23
30
  if security_group.securityGroupIngress.is_a? Hash
24
31
  security_group.securityGroupIngress = [security_group.securityGroupIngress]
25
32
  end
26
33
 
27
34
  security_group.ingresses = security_group.securityGroupIngress.map do |ingress|
35
+ mapped_at_least_one_attribute = false
28
36
  ingress_object = AWS::EC2::SecurityGroupIngress.new
29
37
  ingress.each do |k,v|
30
- ingress_object.send("#{initialLower(k)}=", v)
38
+ silently_fail do
39
+ ingress_object.send("#{initialLower(k)}=", v)
40
+ mapped_at_least_one_attribute = true
41
+ end
31
42
  end
32
43
  #ingress_object.valid?
33
- ingress_object
34
- end
44
+ mapped_at_least_one_attribute ? ingress_object : nil
45
+ end.reject { |ingress| ingress.nil? }
35
46
  end
36
47
 
37
48
  def objectify_egress(security_group)
@@ -40,12 +51,20 @@ class SecurityGroupParser
40
51
  end
41
52
 
42
53
  security_group.egresses = security_group.securityGroupEgress.map do |egress|
54
+ mapped_at_least_one_attribute = false
55
+
43
56
  egress_object = AWS::EC2::SecurityGroupEgress.new
44
57
  egress.each do |k,v|
45
- egress_object.send("#{initialLower(k)}=", v)
46
- end
58
+ next if k.match /::/
59
+ silently_fail do
60
+ egress_object.send("#{initialLower(k)}=", v)
61
+ mapped_at_least_one_attribute = true
62
+ end
63
+
64
+ end.reject { |ingress| ingress.nil? }
47
65
  #egress_object.valid?
48
66
  egress_object
67
+ mapped_at_least_one_attribute ? egress_object : nil
49
68
  end
50
69
  end
51
70
 
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.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kascic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-09 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kwalify