cfn-model 0.4.1 → 0.4.3

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
  SHA256:
3
- metadata.gz: fdcd8f5945e95c1176ca1f7287dcaedde6871834fd1eca97a0f472b471ed721d
4
- data.tar.gz: a772da89e6547542d4b591fcd56b6cd7773d9af142cbbcb75d1533e47045fc44
3
+ metadata.gz: ee88579d79a7de2a38cfd40032eeca6eabd4c6a20461b7bd07b846c1b8505e84
4
+ data.tar.gz: da93cbfd56b231d5ee4852a6fbecacc7b15432cdceca731c4865f734049b8565
5
5
  SHA512:
6
- metadata.gz: 8e2f370d108e5135c6ec8afa6b88df4692a94b0d07a7a0ee080dd364a499c8157090ae49215eef77a3194301d0c9dc5b898aedad732c9a8fce65417e7112bbd8
7
- data.tar.gz: f8f656c8fcfcfe91db50766e3d7ab56474d1991c5eab6ab5e2c882554c61abf7d9956681b0425d8691ba68199d262ea967f615e4f4c3d3f703658913e5430dcd
6
+ metadata.gz: b8eee9d1a663f1518ae0b50b8b57456214d3c0a03fce1946bf4adbaed2cf35bf3ae26d206617096f2748af509b31330a6c91b5746769ae6743a99aad5b51ef50
7
+ data.tar.gz: 60b05b4b60c9b72f8a6ae9eefbdbaae71559a7dc224c08c4a2c9ba7150572e1a1ababe384a3fde7e35771ff408d248f9e486bdf3446e27b47d8922d4906a0e71
@@ -14,7 +14,7 @@ class Statement
14
14
  end
15
15
 
16
16
  def wildcard_actions
17
- @actions.select { |action| action.to_s =~ /\*/ }
17
+ @actions.select { |action| action.to_s == '*' }
18
18
  end
19
19
 
20
20
  def wildcard_principal?
@@ -22,7 +22,7 @@ class Statement
22
22
  end
23
23
 
24
24
  def wildcard_resources
25
- @resources.select { |action| action.to_s =~ /\*/ }
25
+ @resources.select { |resource| resource.to_s == '*' }
26
26
  end
27
27
 
28
28
  def ==(another_statement)
@@ -1,30 +1,12 @@
1
1
  require_relative 'schema_generator'
2
2
  require 'kwalify'
3
- require 'json'
4
3
 
5
4
  class CloudFormationValidator
6
5
  def validate(cloudformation_string)
7
- if json_text?(cloudformation_string)
8
- raise ParserError.new('Invalid JSON!') unless valid_json?(cloudformation_string)
9
- end
10
-
11
6
  schema = SchemaGenerator.new.generate cloudformation_string
12
- validator = Kwalify::Validator.new(schema)
13
- validator.validate(YAML.load(cloudformation_string))
14
- end
15
7
 
16
- private
17
-
18
- def json_text?(cloudformation_string)
19
- first_character = cloudformation_string.gsub(/\s/, '').split('').first
20
- matches = cloudformation_string.scan(/\{[^}]*\}/)
21
- first_character == '{' && !matches.empty?
22
- end
8
+ validator = Kwalify::Validator.new(schema)
23
9
 
24
- def valid_json?(cloudformation_string)
25
- JSON.parse(cloudformation_string)
26
- return true
27
- rescue JSON::ParserError => error
28
- return false
10
+ validator.validate(YAML.load(cloudformation_string))
29
11
  end
30
12
  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.1
4
+ version: 0.4.3
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-06-22 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop