Class: CfnNagRuleDumper

Inherits:
Object show all
Defined in:
lib/cfn-nag/rule_dumper.rb

Instance Method Summary collapse

Constructor Details

#initialize(profile_definition: nil, rule_directory: nil, output_format: nil, rule_repository_definitions: []) ⇒ CfnNagRuleDumper

Returns a new instance of CfnNagRuleDumper.


9
10
11
12
13
14
15
16
17
# File 'lib/cfn-nag/rule_dumper.rb', line 9

def initialize(profile_definition: nil,
               rule_directory: nil,
               output_format: nil,
               rule_repository_definitions: [])
  @rule_directory = rule_directory
  @profile_definition = profile_definition
  @output_format = output_format
  @rule_repository_definitions = rule_repository_definitions
end

Instance Method Details

#dump_rulesObject


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cfn-nag/rule_dumper.rb', line 19

def dump_rules
  rule_registry = FileBasedRuleRepo.new(@rule_directory).discover_rules
  rule_registry.merge! GemBasedRuleRepo.new.discover_rules
  rule_registry = RuleRepositoryLoader.new.merge(rule_registry, @rule_repository_definitions)

  profile = nil
  unless @profile_definition.nil?
    profile = ProfileLoader.new(rule_registry)
                           .load(profile_definition: @profile_definition)
  end

  RulesView.new.emit(rule_registry, profile, output_format: @output_format)
end