cfn-nag 0.0.11 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d2eb6f776c60b81f34b4a83def409388e57166b
4
- data.tar.gz: f17a7d7cf729d905c3e7e5cb9059b41e21504f3c
3
+ metadata.gz: 292f48533183f6f2b074d57757ec5771db23a597
4
+ data.tar.gz: c253df7e9188ef34a47f832b2b055eaf41649e55
5
5
  SHA512:
6
- metadata.gz: 9282462416eb211dda553aef5fea816a41ffc91a3a65847fa9062a77c0c791c3765f8b4c143328522895bc616f2a3f218e9ff46492f3ad9342b1fdf23787450a
7
- data.tar.gz: 5f0cab6ea6bd403bc30fdaa742d1f4f699ab9bd24fffae2e3fba45c62c880f7a8b95fcf1ce308ef082783147b320cc17f6eb013c23ac8ca1caae1472e1e305c4
6
+ metadata.gz: 840362bbf552584f4f080a572e15d73bdfb4013008c6eb5ae56008f96c78a28db6d30790e56a7484bbcd4d2e5c015594aa03d8f53ad77a39e0bdee9f53ca1203
7
+ data.tar.gz: a661ea828ffcb4ead2f2827d0b9c56cac24b08f0c025ef753a5b245f98e84a9ccdf62972b0b51b2b44fd84ce9307b16ddbffd6f0cb4c801877be1b0342b5b655
@@ -11,19 +11,29 @@ class CfnNag
11
11
  def audit(input_json_path:,
12
12
  output_format:'txt')
13
13
 
14
+ aggregate_results = audit_results input_json_path: input_json_path,
15
+ output_format: output_format
16
+
17
+ aggregate_results.inject(0) { |total_failure_count, results| total_failure_count + results[:file_results][:failure_count] }
18
+ end
19
+
20
+ def audit_results(input_json_path:,
21
+ output_format:'txt')
22
+
14
23
  templates = discover_templates(input_json_path)
15
24
 
16
25
  aggregate_results = []
17
26
  templates.each do |template|
18
27
  aggregate_results << {
19
- filename: template,
20
- file_results: audit_file(input_json_path: template)
28
+ filename: template,
29
+ file_results: audit_file(input_json_path: template)
21
30
  }
22
31
  end
23
32
 
24
- results_renderer(output_format).new.render(aggregate_results)
33
+ render_results(aggregate_results: aggregate_results,
34
+ output_format: output_format)
25
35
 
26
- aggregate_results.inject(0) { |total_failure_count, results| total_failure_count + results[:file_results][:failure_count] }
36
+ aggregate_results
27
37
  end
28
38
 
29
39
  def self.configure_logging(opts)
@@ -39,6 +49,10 @@ class CfnNag
39
49
 
40
50
  private
41
51
 
52
+ def render_results(aggregate_results:,output_format:)
53
+ results_renderer(output_format).new.render(aggregate_results)
54
+ end
55
+
42
56
  def audit_file(input_json_path:)
43
57
  @stop_processing = false
44
58
  @violations = []
@@ -0,0 +1,7 @@
1
+ warning jq: '[.Resources|with_entries(.value.LogicalResourceId = .key)[] | select(.Type == "AWS::ElasticLoadBalancing::LoadBalancer")|'\
2
+ 'select(.Properties.AccessLoggingPolicy == null)]|map(.LogicalResourceId) ',
3
+ message: 'Elastic Load Balancer should have access logging configured'
4
+
5
+ warning jq: '[.Resources|with_entries(.value.LogicalResourceId = .key)[] | select(.Type == "AWS::ElasticLoadBalancing::LoadBalancer")|'\
6
+ 'select(.Properties.AccessLoggingPolicy?.Enabled == false)]|map(.LogicalResourceId) ',
7
+ message: 'Elastic Load Balancer should have access logging enabled'
@@ -30,4 +30,8 @@ class Violation
30
30
  violating_code: @violating_code
31
31
  }
32
32
  end
33
+
34
+ def ==(other_violation)
35
+ other_violation.class == self.class && other_violation.to_h == to_h
36
+ end
33
37
  end
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.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - someguy
@@ -55,6 +55,7 @@ files:
55
55
  - lib/json_rules/ebs_rules.rb
56
56
  - lib/json_rules/iam_policy_rules.rb
57
57
  - lib/json_rules/iam_user_rules.rb
58
+ - lib/json_rules/loadbalancer_rules.rb
58
59
  - lib/json_rules/port_rules.rb
59
60
  - lib/model/cfn_model.rb
60
61
  - lib/model/iam_user_parser.rb