cfn-nag 0.8.3 → 0.8.4
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 -2
- data/lib/cfn-nag/custom_rules/base.rb +3 -2
- data/lib/cfn-nag/result_view/colored_stdout_results.rb +11 -2
- data/lib/cfn-nag/result_view/simple_stdout_results.rb +11 -2
- data/lib/cfn-nag/result_view/stdout_results.rb +2 -1
- data/lib/cfn-nag/version.rb +1 -1
- data/lib/cfn-nag/violation.rb +6 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bcd7a2b51e44dcad5d3d5f0514cd1f670913c0ce8074f6af6dfe9b9c5c28c4e
|
4
|
+
data.tar.gz: 5bc5eba04f176db1d734aa7d32806f53d9f55402e128b56c5a50e6367974ef4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '028736d712ade96898ea014e859955bd94d68012e2cdca469b5dbf1b38cd86b42ec316710f06353e5ff5d82895a75df330830a149a3e9ecfc750a4f2bf108c88'
|
7
|
+
data.tar.gz: f02924cf126fc681df943225f2d2231628d6309feed5dbf7db67aab0ae53ef466d6e4e6236a820bfe677946b75cc47b9e1f087c8ad3dda2fb97bcc4c6cab60ce
|
data/lib/cfn-nag/cfn_nag.rb
CHANGED
@@ -95,7 +95,7 @@ class CfnNag
|
|
95
95
|
)
|
96
96
|
|
97
97
|
violations = filter_violations_by_deny_list_and_profile(violations)
|
98
|
-
violations =
|
98
|
+
violations = mark_line_numbers_and_element_types(violations, cfn_model)
|
99
99
|
rescue RuleRepoException, Psych::SyntaxError, ParserError => fatal_error
|
100
100
|
violations << Violation.fatal_violation(fatal_error.to_s)
|
101
101
|
rescue JSON::ParserError => json_parameters_error
|
@@ -118,10 +118,11 @@ class CfnNag
|
|
118
118
|
|
119
119
|
private
|
120
120
|
|
121
|
-
def
|
121
|
+
def mark_line_numbers_and_element_types(violations, cfn_model)
|
122
122
|
violations.each do |violation|
|
123
123
|
violation.logical_resource_ids.each do |logical_resource_id|
|
124
124
|
violation.line_numbers << cfn_model.line_numbers[logical_resource_id]
|
125
|
+
violation.element_types << cfn_model.element_types[logical_resource_id]
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
@@ -22,12 +22,13 @@ class BaseRule
|
|
22
22
|
violation(logical_resource_ids)
|
23
23
|
end
|
24
24
|
|
25
|
-
def violation(logical_resource_ids, line_numbers = [])
|
25
|
+
def violation(logical_resource_ids, line_numbers = [], element_types = [])
|
26
26
|
Violation.new(id: rule_id,
|
27
27
|
name: self.class.name,
|
28
28
|
type: rule_type,
|
29
29
|
message: rule_text,
|
30
30
|
logical_resource_ids: logical_resource_ids,
|
31
|
-
line_numbers: line_numbers
|
31
|
+
line_numbers: line_numbers,
|
32
|
+
element_types: element_types)
|
32
33
|
end
|
33
34
|
end
|
@@ -10,7 +10,8 @@ class ColoredStdoutResults < StdoutResults
|
|
10
10
|
color:,
|
11
11
|
message:,
|
12
12
|
logical_resource_ids: nil,
|
13
|
-
line_numbers: []
|
13
|
+
line_numbers: [],
|
14
|
+
element_types: [])
|
14
15
|
|
15
16
|
logical_resource_ids = nil if logical_resource_ids == []
|
16
17
|
|
@@ -18,7 +19,7 @@ class ColoredStdoutResults < StdoutResults
|
|
18
19
|
puts
|
19
20
|
puts colorize(color, "| #{message_type.upcase}")
|
20
21
|
puts colorize(color, '|')
|
21
|
-
puts colorize(color, "|
|
22
|
+
puts colorize(color, "| #{element_type(element_types)}: #{logical_resource_ids}") unless logical_resource_ids.nil?
|
22
23
|
puts colorize(color, "| Line Numbers: #{line_numbers}") unless line_numbers.empty?
|
23
24
|
puts colorize(color, '|') unless line_numbers.empty? && logical_resource_ids.nil?
|
24
25
|
puts colorize(color, "| #{message}")
|
@@ -38,4 +39,12 @@ class ColoredStdoutResults < StdoutResults
|
|
38
39
|
def colorize(color_symbol, str)
|
39
40
|
"\e[#{color_code(color_symbol)}m#{str}\e[0m"
|
40
41
|
end
|
42
|
+
|
43
|
+
def element_type(element_types)
|
44
|
+
if element_types == [] || element_types.first.nil?
|
45
|
+
'Element'
|
46
|
+
elsif !element_types.first.nil?
|
47
|
+
element_types.first.capitalize
|
48
|
+
end
|
49
|
+
end
|
41
50
|
end
|
@@ -11,7 +11,8 @@ class SimpleStdoutResults < StdoutResults
|
|
11
11
|
message:,
|
12
12
|
color:,
|
13
13
|
logical_resource_ids: nil,
|
14
|
-
line_numbers: []
|
14
|
+
line_numbers: [],
|
15
|
+
element_types: [])
|
15
16
|
|
16
17
|
logical_resource_ids = nil if logical_resource_ids == []
|
17
18
|
|
@@ -19,10 +20,18 @@ class SimpleStdoutResults < StdoutResults
|
|
19
20
|
puts
|
20
21
|
puts "| #{message_type.upcase}"
|
21
22
|
puts '|'
|
22
|
-
puts "|
|
23
|
+
puts "| #{element_type(element_types)}: #{logical_resource_ids}" unless logical_resource_ids.nil?
|
23
24
|
puts "| Line Numbers: #{line_numbers}" unless line_numbers.empty?
|
24
25
|
puts '|' unless line_numbers.empty? && logical_resource_ids.nil?
|
25
26
|
puts "| #{message}"
|
26
27
|
end
|
27
28
|
# rubocop:enable Lint/UnusedMethodArgument
|
29
|
+
|
30
|
+
def element_type(element_types)
|
31
|
+
if element_types == [] || element_types.first.nil?
|
32
|
+
'Element'
|
33
|
+
elsif !element_types.first.nil?
|
34
|
+
element_types.first.capitalize
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
@@ -12,7 +12,8 @@ class StdoutResults
|
|
12
12
|
color: color,
|
13
13
|
message: violation.message,
|
14
14
|
logical_resource_ids: violation.logical_resource_ids,
|
15
|
-
line_numbers: violation.line_numbers
|
15
|
+
line_numbers: violation.line_numbers,
|
16
|
+
element_types: violation.element_types
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
data/lib/cfn-nag/version.rb
CHANGED
data/lib/cfn-nag/violation.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'rule_definition'
|
|
4
4
|
|
5
5
|
# Rule definition for violations
|
6
6
|
class Violation < RuleDefinition
|
7
|
-
attr_reader :logical_resource_ids, :line_numbers
|
7
|
+
attr_reader :logical_resource_ids, :line_numbers, :element_types
|
8
8
|
|
9
9
|
# rubocop:disable Metrics/ParameterLists
|
10
10
|
def initialize(id:,
|
@@ -12,7 +12,8 @@ class Violation < RuleDefinition
|
|
12
12
|
type:,
|
13
13
|
message:,
|
14
14
|
logical_resource_ids: [],
|
15
|
-
line_numbers: []
|
15
|
+
line_numbers: [],
|
16
|
+
element_types: [])
|
16
17
|
super id: id,
|
17
18
|
name: name,
|
18
19
|
type: type,
|
@@ -20,6 +21,7 @@ class Violation < RuleDefinition
|
|
20
21
|
|
21
22
|
@logical_resource_ids = logical_resource_ids
|
22
23
|
@line_numbers = line_numbers
|
24
|
+
@element_types = element_types
|
23
25
|
end
|
24
26
|
# rubocop:enable Metrics/ParameterLists
|
25
27
|
|
@@ -30,7 +32,8 @@ class Violation < RuleDefinition
|
|
30
32
|
def to_h
|
31
33
|
super.to_h.merge(
|
32
34
|
logical_resource_ids: @logical_resource_ids,
|
33
|
-
line_numbers: @line_numbers
|
35
|
+
line_numbers: @line_numbers,
|
36
|
+
element_types: @element_types
|
34
37
|
)
|
35
38
|
end
|
36
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-nag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.6.
|
75
|
+
version: 0.6.6
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.6.
|
82
|
+
version: 0.6.6
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: logging
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|