cfn-nag 0.4.29 → 0.4.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfn-nag/cfn_nag.rb +3 -0
- data/lib/cfn-nag/cfn_nag_executor.rb +2 -2
- data/lib/cfn-nag/cli_options.rb +4 -4
- data/lib/cfn-nag/result_view/colored_stdout_results.rb +29 -0
- data/lib/cfn-nag/result_view/simple_stdout_results.rb +10 -49
- data/lib/cfn-nag/result_view/stdout_results.rb +51 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f82f950358452ac63aa12bde592b60ec9c45e07ab2b21e6c90afa744dc8b372a
|
4
|
+
data.tar.gz: cd9c81ca1dbda0f07f426dc11364b2325bfcdbaf699623551d5badaf34784bfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9895244d3c78061c3e8547870675eeb1327d3080bb384da07a05feae3819c04475226c7b889594bafdf80981719e8c3a89802966bfba6827098b5a5798c68296
|
7
|
+
data.tar.gz: eb4fcda99303bdea8ea44f3e7e54889eed6a4f1e0a9c20a8e7d2f08006e01812452c37662c193838aceda3784729f2bf98db559277e9fa2eda3290eeb4db0a9d
|
data/lib/cfn-nag/cfn_nag.rb
CHANGED
@@ -4,7 +4,9 @@ require_relative 'custom_rule_loader'
|
|
4
4
|
require_relative 'rule_registry'
|
5
5
|
require_relative 'violation_filtering'
|
6
6
|
require_relative 'template_discovery'
|
7
|
+
require_relative 'result_view/stdout_results'
|
7
8
|
require_relative 'result_view/simple_stdout_results'
|
9
|
+
require_relative 'result_view/colored_stdout_results'
|
8
10
|
require_relative 'result_view/json_results'
|
9
11
|
require 'cfn-model'
|
10
12
|
|
@@ -142,6 +144,7 @@ class CfnNag
|
|
142
144
|
|
143
145
|
def results_renderer(output_format)
|
144
146
|
registry = {
|
147
|
+
'colortxt' => ColoredStdoutResults,
|
145
148
|
'txt' => SimpleStdoutResults,
|
146
149
|
'json' => JsonResults
|
147
150
|
}
|
@@ -69,9 +69,9 @@ class CfnNagExecutor
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def validate_options(opts)
|
72
|
-
unless opts[:output_format].nil? || %w[txt json].include?(opts[:output_format])
|
72
|
+
unless opts[:output_format].nil? || %w[colortxt txt json].include?(opts[:output_format])
|
73
73
|
Trollop.die(:output_format,
|
74
|
-
'Must be txt or json')
|
74
|
+
'Must be colortxt, txt, or json')
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
data/lib/cfn-nag/cli_options.rb
CHANGED
@@ -79,9 +79,9 @@ class Options
|
|
79
79
|
required: false,
|
80
80
|
default: false
|
81
81
|
opt :output_format,
|
82
|
-
'Format of results: [txt, json]',
|
82
|
+
'Format of results: [txt, json, colortxt]',
|
83
83
|
type: :string,
|
84
|
-
default: '
|
84
|
+
default: 'colortxt'
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -104,9 +104,9 @@ class Options
|
|
104
104
|
type: :string,
|
105
105
|
required: true
|
106
106
|
opt :output_format,
|
107
|
-
'Format of results: [txt, json]',
|
107
|
+
'Format of results: [txt, json, colortxt]',
|
108
108
|
type: :string,
|
109
|
-
default: '
|
109
|
+
default: 'colortxt'
|
110
110
|
opt :debug,
|
111
111
|
'Enable debug output',
|
112
112
|
type: :boolean,
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
# Print results to STDOUT with ANSI color codes
|
7
|
+
class ColoredStdoutResults < StdoutResults
|
8
|
+
private
|
9
|
+
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
11
|
+
def message(message_type:,
|
12
|
+
color:,
|
13
|
+
message:,
|
14
|
+
logical_resource_ids: nil,
|
15
|
+
line_numbers: [])
|
16
|
+
|
17
|
+
logical_resource_ids = nil if logical_resource_ids == []
|
18
|
+
|
19
|
+
60.times { print '-' }
|
20
|
+
puts
|
21
|
+
puts "| #{message_type.upcase}".send(color)
|
22
|
+
puts '|'.send(color)
|
23
|
+
puts "| Resources: #{logical_resource_ids}".send(color) unless logical_resource_ids.nil?
|
24
|
+
puts "| Line Numbers: #{line_numbers}".send(color) unless line_numbers.empty?
|
25
|
+
puts '|'.send(color) unless line_numbers.empty? && logical_resource_ids.nil?
|
26
|
+
puts "| #{message}".send(color)
|
27
|
+
end
|
28
|
+
# rubocop:enable Metrics/AbcSize
|
29
|
+
end
|
@@ -1,50 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'cfn-nag/violation'
|
4
|
-
require 'colorize'
|
5
4
|
|
6
5
|
# Print results to STDOUT
|
7
|
-
class SimpleStdoutResults
|
8
|
-
def message_violations(violations)
|
9
|
-
violations.each do |violation|
|
10
|
-
color = violation.type == 'FAIL' ? :red : :yellow
|
11
|
-
|
12
|
-
message message_type: "#{violation.type} #{violation.id}",
|
13
|
-
color: color,
|
14
|
-
message: violation.message,
|
15
|
-
logical_resource_ids: violation.logical_resource_ids,
|
16
|
-
line_numbers: violation.line_numbers
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def print_failures(violations)
|
21
|
-
puts "\nFailures count: #{Violation.count_failures(violations)}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def print_warnings(violations)
|
25
|
-
puts "Warnings count: #{Violation.count_warnings(violations)}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def render(results)
|
29
|
-
results.each do |result|
|
30
|
-
60.times { print '-' }
|
31
|
-
puts "\n" + result[:filename]
|
32
|
-
60.times { print '-' }
|
33
|
-
|
34
|
-
violations = result[:file_results][:violations]
|
35
|
-
|
36
|
-
message_violations violations
|
37
|
-
print_failures violations
|
38
|
-
print_warnings violations
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
6
|
+
class SimpleStdoutResults < StdoutResults
|
42
7
|
private
|
43
8
|
|
44
|
-
# rubocop:disable
|
9
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
45
10
|
def message(message_type:,
|
46
|
-
color:,
|
47
11
|
message:,
|
12
|
+
color:,
|
48
13
|
logical_resource_ids: nil,
|
49
14
|
line_numbers: [])
|
50
15
|
|
@@ -52,16 +17,12 @@ class SimpleStdoutResults
|
|
52
17
|
|
53
18
|
60.times { print '-' }
|
54
19
|
puts
|
55
|
-
puts "| #{message_type.upcase}"
|
56
|
-
puts '|'
|
57
|
-
puts "| Resources: #{logical_resource_ids}"
|
58
|
-
puts "| Line Numbers: #{line_numbers}"
|
59
|
-
puts '|'
|
60
|
-
puts "| #{message}"
|
61
|
-
end
|
62
|
-
# rubocop:enable Metrics/AbcSize
|
63
|
-
|
64
|
-
def indent_multiline_string_with_prefix(prefix, multiline_string)
|
65
|
-
prefix + ' ' + multiline_string.gsub(/\n/, "\n#{prefix} ")
|
20
|
+
puts "| #{message_type.upcase}"
|
21
|
+
puts '|'
|
22
|
+
puts "| Resources: #{logical_resource_ids}" unless logical_resource_ids.nil?
|
23
|
+
puts "| Line Numbers: #{line_numbers}" unless line_numbers.empty?
|
24
|
+
puts '|' unless line_numbers.empty? && logical_resource_ids.nil?
|
25
|
+
puts "| #{message}"
|
66
26
|
end
|
27
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
67
28
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
# Print results to STDOUT
|
7
|
+
class StdoutResults
|
8
|
+
def message_violations(violations)
|
9
|
+
violations.each do |violation|
|
10
|
+
color = violation.type == 'FAIL' ? :red : :yellow
|
11
|
+
|
12
|
+
message message_type: "#{violation.type} #{violation.id}",
|
13
|
+
color: color,
|
14
|
+
message: violation.message,
|
15
|
+
logical_resource_ids: violation.logical_resource_ids,
|
16
|
+
line_numbers: violation.line_numbers
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_failures(violations)
|
21
|
+
puts "\nFailures count: #{Violation.count_failures(violations)}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def print_warnings(violations)
|
25
|
+
puts "Warnings count: #{Violation.count_warnings(violations)}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def render(results)
|
29
|
+
results.each do |result|
|
30
|
+
60.times { print '-' }
|
31
|
+
puts "\n" + result[:filename]
|
32
|
+
60.times { print '-' }
|
33
|
+
|
34
|
+
violations = result[:file_results][:violations]
|
35
|
+
|
36
|
+
message_violations violations
|
37
|
+
print_failures violations
|
38
|
+
print_warnings violations
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def message
|
45
|
+
raise 'Must be implemented in subclass!'
|
46
|
+
end
|
47
|
+
|
48
|
+
def indent_multiline_string_with_prefix(prefix, multiline_string)
|
49
|
+
prefix + ' ' + multiline_string.gsub(/\n/, "\n#{prefix} ")
|
50
|
+
end
|
51
|
+
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.4.
|
4
|
+
version: 0.4.30
|
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-07-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -246,9 +246,11 @@ files:
|
|
246
246
|
- lib/cfn-nag/jmes_path_discovery.rb
|
247
247
|
- lib/cfn-nag/jmes_path_evaluator.rb
|
248
248
|
- lib/cfn-nag/profile_loader.rb
|
249
|
+
- lib/cfn-nag/result_view/colored_stdout_results.rb
|
249
250
|
- lib/cfn-nag/result_view/json_results.rb
|
250
251
|
- lib/cfn-nag/result_view/rules_view.rb
|
251
252
|
- lib/cfn-nag/result_view/simple_stdout_results.rb
|
253
|
+
- lib/cfn-nag/result_view/stdout_results.rb
|
252
254
|
- lib/cfn-nag/rule_definition.rb
|
253
255
|
- lib/cfn-nag/rule_dumper.rb
|
254
256
|
- lib/cfn-nag/rule_id_set.rb
|