cfn-nag 0.8.3 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5802d950eab38e40f6073fa29cc4736a052885451e106ff8e6501128e877ad84
|
4
|
+
data.tar.gz: 36b602473c0e8586b360641825d44aa911a5511afafa614bd4c40c912bee1efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a10f0637676007bfd8c4498f579d71eea6e29e0ae01fe1ad9b82e51b77fc97bf9a2b9f69350b948a5b9794b2970e0e52191783ea50254aeccb5028db3a0b0a68
|
7
|
+
data.tar.gz: 9bade29b10f95b488c6be7711329c5ea11c21a32169badb0b9c1e83dcd930aac757601ba1ad722da34aaeb2d8c23bf46bdda458be5dcc0b17d2b32b519236ec7
|
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,14 +1,14 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -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
|