Module: Gauntlt::Support::AttackAliasHelper

Defined in:
lib/gauntlt/attack_adapters/support/attack_step_helper.rb

Instance Method Summary collapse

Instance Method Details

#gauntlt_attack_aliasesObject


7
8
9
# File 'lib/gauntlt/attack_adapters/support/attack_step_helper.rb', line 7

def gauntlt_attack_aliases
  @gauntlt_attack_aliases ||= {}
end

#import_attack_aliasesObject


31
32
33
34
35
36
37
38
# File 'lib/gauntlt/attack_adapters/support/attack_step_helper.rb', line 31

def import_attack_aliases
   @imported_attack_aliases = Hash.new
   attack_aliases_json = Dir.glob(ATTACK_ALIASES_GLOB_PATTERN)
   attack_aliases_json.each do |file|
   @imported_attack_aliases.merge!(JSON.load(File.open(file)))
   end
   @imported_attack_aliases
end

#load_attack_alias(alias_name, *version) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gauntlt/attack_adapters/support/attack_step_helper.rb', line 11

def load_attack_alias(alias_name, *version)
  @attack_steps = import_attack_aliases
  @alias_versioned = ""
	@alias_versioned << alias_name
  if version.length > 0
      @alias_versioned << "-"
      @alias_versioned << version[0]
  end

	print "Checking #{@alias_versioned} and #{alias_name}"

  if @attack_steps.has_key?(@alias_versioned)
      @attack_steps[@alias_versioned]
  elsif @attack_steps.has_key?(alias_name)
      @attack_steps[alias_name]
  else
      raise("Unknown attack alias #{alias_name}, try gauntlt --list_attack_aliases")
  end
end