cfn-nag 0.3.52 → 0.3.53

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: dbe97b8bdff1c7ee84e33f5fbcd87412fe418d9b5299c4222065c35f8c85f2ba
4
- data.tar.gz: 53465649bd54c9890a6ff35210e8b482f7c24c126d885d81865397367bede71a
3
+ metadata.gz: 8eb6e2e2d4e1d36f7d8195e2bc7040bc431f8c0c6ebd8733aad45ada0b9e69d5
4
+ data.tar.gz: db0a2a5764a82493fdf37742c97f48d56e86751b376dfb31cda96a440f5a5ad6
5
5
  SHA512:
6
- metadata.gz: 9c7bf0417eae3f341f99c1e497c96a59334cca32199220c0450f75a6f081f986db2c46683cab46f8b1c15a175c6f86766de92042bc0aac620cdea96cf06a265f
7
- data.tar.gz: 110ca000377113199a0af17598a3bf8bfb891833f4e8658d27f872b5ae963de35fca8ab9c59a3d437a4d3220258dabf957db6e767c311fdc7c05bf90a0a206ab
6
+ metadata.gz: 0ac0f7fc98a5d972e1ae03996a2d721f095e6fac495c7c7228f7951e7674303c89ebdcb7f069ddf472a441a81c5c69288e67518a45bde1fe0e7a41d21045aa63
7
+ data.tar.gz: 4de40b96402bb854da7ce40a4423c3285903c552404611dac8a02f4f51da598c064cc4034d3f4486ff259a5c7a94b4b3e19685b697a5540881c7e66178abcd2f
@@ -9,7 +9,7 @@ opts = Trollop.options do
9
9
  version Gem::Specification.find_by_name('cfn-nag').version
10
10
 
11
11
  opt :input_path,
12
- 'CloudFormation template to nag on or directory of templates - all *.json, *.yaml, *.yml and *.template recursively',
12
+ 'CloudFormation template to nag on or directory of templates. Default is all *.json, *.yaml, *.yml and *.template recursively, but can be constrained by --template-pattern',
13
13
  type: :io,
14
14
  required: true
15
15
  opt :output_format,
@@ -51,6 +51,11 @@ opts = Trollop.options do
51
51
  type: :boolean,
52
52
  required: false,
53
53
  default: false
54
+ opt :template_pattern,
55
+ 'Within the --input-path, match files to scan against this regular expression',
56
+ type: :string,
57
+ required: false,
58
+ default: '..*\.json|..*\.yaml|..*\.yml|..*\.template'
54
59
  end
55
60
 
56
61
  unless %w[txt json].include?(opts[:output_format])
@@ -69,10 +74,10 @@ cfn_nag = CfnNag.new(profile_definition: profile_definition,
69
74
  rule_directory: opts[:rule_directory],
70
75
  allow_suppression: opts[:allow_suppression],
71
76
  print_suppression: opts[:print_suppression],
72
- isolate_custom_rule_exceptions:
73
- opts[:isolate_custom_rule_exceptions])
77
+ isolate_custom_rule_exceptions: opts[:isolate_custom_rule_exceptions])
74
78
 
75
79
  exit cfn_nag.audit_aggregate_across_files_and_render_results(
76
80
  input_path: opts[:input_path], output_format: opts[:output_format],
77
- parameter_values_path: opts[:parameter_values_path]
81
+ parameter_values_path: opts[:parameter_values_path],
82
+ template_pattern: opts[:template_pattern]
78
83
  )
@@ -28,11 +28,13 @@ class CfnNag
28
28
  #
29
29
  # Return an aggregate failure count (for exit code usage)
30
30
  #
31
- def audit_aggregate_across_files_and_render_results(
32
- input_path:, output_format: 'txt', parameter_values_path: nil
33
- )
31
+ def audit_aggregate_across_files_and_render_results(input_path:,
32
+ output_format: 'txt',
33
+ parameter_values_path: nil,
34
+ template_pattern: '..*\.json|..*\.yaml|..*\.yml|..*\.template')
34
35
  aggregate_results = audit_aggregate_across_files input_path: input_path,
35
- parameter_values_path: parameter_values_path
36
+ parameter_values_path: parameter_values_path,
37
+ template_pattern: template_pattern
36
38
 
37
39
  render_results(aggregate_results: aggregate_results,
38
40
  output_format: output_format)
@@ -47,9 +49,12 @@ class CfnNag
47
49
  ##
48
50
  # Given a file or directory path, return aggregate results
49
51
  #
50
- def audit_aggregate_across_files(input_path:, parameter_values_path: nil)
52
+ def audit_aggregate_across_files(input_path:,
53
+ parameter_values_path: nil,
54
+ template_pattern: '..*\.json|..*\.yaml|..*\.yml|..*\.template')
51
55
  parameter_values_string = parameter_values_path.nil? ? nil : IO.read(parameter_values_path)
52
- templates = TemplateDiscovery.new.discover_templates(input_path)
56
+ templates = TemplateDiscovery.new.discover_templates(input_json_path: input_path,
57
+ template_pattern: template_pattern)
53
58
  aggregate_results = []
54
59
  templates.each do |template|
55
60
  aggregate_results << {
@@ -1,9 +1,11 @@
1
1
  # Container for discovering templates
2
2
  class TemplateDiscovery
3
3
  # input_json_path can be a directory, filename, or File
4
- def discover_templates(input_json_path)
4
+ def discover_templates(input_json_path:,
5
+ template_pattern: '..*\.json|..*\.yaml|..*\.yml|..*\.template')
5
6
  if ::File.directory? input_json_path
6
- return find_templates_in_directory(directory: input_json_path)
7
+ return find_templates_in_directory(directory: input_json_path,
8
+ template_pattern: template_pattern)
7
9
  end
8
10
  return [render_path(input_json_path)] if ::File.file? input_json_path
9
11
  raise "#{input_json_path} is not a proper path"
@@ -17,11 +19,13 @@ class TemplateDiscovery
17
19
  end
18
20
 
19
21
  def find_templates_in_directory(directory:,
20
- cfn_extensions: %w[json yaml yml template])
22
+ template_pattern:)
21
23
 
22
24
  templates = []
23
- cfn_extensions.each do |cfn_extension|
24
- templates += Dir[File.join(directory, "**/*.#{cfn_extension}")]
25
+ Dir[File.join(directory, '**/**')].each do |file_name|
26
+ if file_name.match(template_pattern)
27
+ templates << file_name
28
+ end
25
29
  end
26
30
  templates
27
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfn-nag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.52
4
+ version: 0.3.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kascic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-27 00:00:00.000000000 Z
11
+ date: 2018-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec