cfn-nag 0.3.98 → 0.4.1
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 +13 -1
- data/lib/cfn-nag/result_view/simple_stdout_results.rb +6 -3
- 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: 4c22e9a701323d4590b6540a493979c119236e2731581b155ebf60d5d64444a1
|
4
|
+
data.tar.gz: 0d193a6821cb0376b2a6924dd19d002943ee844310d9f9aad18905f3037dac02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4813009aaeaee81ba6d1cc78a65ee903f52034cbf07eb19326e4ede15ab2a372ef5b885e15304475cb4e080cadde235fa21a244b4dc0092388b332d41e743306
|
7
|
+
data.tar.gz: 9b007f901ead4856020d534f2b5a47420670923249e194a0608ae3f0939f848f31706d517dabd6c4e4783f1810e701ec8f0622ea84f3780e53dd7902d6487121
|
data/lib/cfn-nag/cfn_nag.rb
CHANGED
@@ -85,10 +85,12 @@ class CfnNag
|
|
85
85
|
|
86
86
|
begin
|
87
87
|
cfn_model = CfnParser.new.parse cloudformation_string,
|
88
|
-
parameter_values_string
|
88
|
+
parameter_values_string,
|
89
|
+
true
|
89
90
|
violations += @custom_rule_loader.execute_custom_rules(cfn_model)
|
90
91
|
|
91
92
|
violations = filter_violations_by_blacklist_and_profile(violations)
|
93
|
+
violations = mark_line_numbers(violations, cfn_model)
|
92
94
|
rescue Psych::SyntaxError, ParserError => parser_error
|
93
95
|
violations << fatal_violation(parser_error.to_s)
|
94
96
|
rescue JSON::ParserError => json_parameters_error
|
@@ -101,6 +103,16 @@ class CfnNag
|
|
101
103
|
|
102
104
|
private
|
103
105
|
|
106
|
+
def mark_line_numbers(violations, cfn_model)
|
107
|
+
violations.each do |violation|
|
108
|
+
violation.logical_resource_ids.each do |logical_resource_id|
|
109
|
+
violation.line_numbers << cfn_model.line_numbers[logical_resource_id]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
violations
|
114
|
+
end
|
115
|
+
|
104
116
|
def filter_violations_by_blacklist_and_profile(violations)
|
105
117
|
violations = filter_violations_by_profile(
|
106
118
|
profile_definition: @profile_definition,
|
@@ -8,7 +8,8 @@ class SimpleStdoutResults
|
|
8
8
|
violations.each do |violation|
|
9
9
|
message message_type: "#{violation.type} #{violation.id}",
|
10
10
|
message: violation.message,
|
11
|
-
logical_resource_ids: violation.logical_resource_ids
|
11
|
+
logical_resource_ids: violation.logical_resource_ids,
|
12
|
+
line_numbers: violation.line_numbers
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -38,7 +39,8 @@ class SimpleStdoutResults
|
|
38
39
|
|
39
40
|
def message(message_type:,
|
40
41
|
message:,
|
41
|
-
logical_resource_ids: nil
|
42
|
+
logical_resource_ids: nil,
|
43
|
+
line_numbers: [])
|
42
44
|
|
43
45
|
logical_resource_ids = nil if logical_resource_ids == []
|
44
46
|
|
@@ -47,7 +49,8 @@ class SimpleStdoutResults
|
|
47
49
|
puts "| #{message_type.upcase}"
|
48
50
|
puts '|'
|
49
51
|
puts "| Resources: #{logical_resource_ids}" unless logical_resource_ids.nil?
|
50
|
-
puts
|
52
|
+
puts "| Line Numbers: #{line_numbers}" unless line_numbers.empty?
|
53
|
+
puts '|' unless line_numbers.empty? && logical_resource_ids.nil?
|
51
54
|
puts "| #{message}"
|
52
55
|
end
|
53
56
|
|
data/lib/cfn-nag/violation.rb
CHANGED
@@ -4,17 +4,19 @@ require_relative 'rule_definition'
|
|
4
4
|
|
5
5
|
# Rule definition for violations
|
6
6
|
class Violation < RuleDefinition
|
7
|
-
attr_reader :logical_resource_ids
|
7
|
+
attr_reader :logical_resource_ids, :line_numbers
|
8
8
|
|
9
9
|
def initialize(id:,
|
10
10
|
type:,
|
11
11
|
message:,
|
12
|
-
logical_resource_ids: nil
|
12
|
+
logical_resource_ids: nil,
|
13
|
+
line_numbers: [])
|
13
14
|
super id: id,
|
14
15
|
type: type,
|
15
16
|
message: message
|
16
17
|
|
17
18
|
@logical_resource_ids = logical_resource_ids
|
19
|
+
@line_numbers = line_numbers
|
18
20
|
end
|
19
21
|
|
20
22
|
def to_s
|
@@ -23,7 +25,8 @@ class Violation < RuleDefinition
|
|
23
25
|
|
24
26
|
def to_h
|
25
27
|
super.to_h.merge(
|
26
|
-
logical_resource_ids: @logical_resource_ids
|
28
|
+
logical_resource_ids: @logical_resource_ids,
|
29
|
+
line_numbers: @line_numbers
|
27
30
|
)
|
28
31
|
end
|
29
32
|
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.4.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jmespath
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|