Module: Threatinator::Amqp::Rcvr::Settings
Constant Summary collapse
- @@registered_settings =
[]
Class Method Summary collapse
-
.list ⇒ Object
list available settings.
- .print ⇒ Object
-
.reset! ⇒ Object
Threatinator uses “threatinator.” + event.type.to_s VALID_TYPES = [:c2, :attacker, :malware_host, :spamming, :scanning, :phishing] amqp_routing_key :routing_key=>“threatinator.malware_host” ‘*’ (star) can substitute for exactly one word.
- .to_h ⇒ Object
Instance Method Summary collapse
-
#config(&block) ⇒ Object
And we define a wrapper for the configuration block, that we’ll use to set up our set of options.
-
#parameter(*names) ⇒ Object
SaganCrafter provides a basic single-method DSL with .parameter method being used to define a set of available settings.
Class Method Details
.list ⇒ Object
list available settings
42 43 44 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 42 def self.list @@registered_settings end |
.print ⇒ Object
71 72 73 74 75 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 71 def self.print Threatinator::Amqp::Rcvr::Settings.list.each do |toggle| puts "#{toggle} => #{Threatinator::Amqp::Rcvr::Settings.send(toggle)}" end end |
.reset! ⇒ Object
Threatinator uses “threatinator.” + event.type.to_s VALID_TYPES = [:c2, :attacker, :malware_host, :spamming, :scanning, :phishing] amqp_routing_key :routing_key=>“threatinator.malware_host” ‘*’ (star) can substitute for exactly one word. ‘#’ (hash) can substitute for zero or more words.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 52 def self.reset! self.config do verbose false amqp_hostname "127.0.0.1" amqp_binding_topic "threats" amqp_routing_key "threatinator.#" sql_table_name "fqdns" sql_file_location "/tmp/threat.db" end end |
.to_h ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 63 def self.to_h c = {} Threatinator::Amqp::Rcvr::Settings.list.each do |toggle| c[toggle.to_sym] = Threatinator::Amqp::Rcvr::Settings.send(toggle) end return c end |
Instance Method Details
#config(&block) ⇒ Object
And we define a wrapper for the configuration block, that we’ll use to set up our set of options
37 38 39 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 37 def config &block instance_eval(&block) end |
#parameter(*names) ⇒ Object
SaganCrafter provides a basic single-method DSL with .parameter method being used to define a set of available settings. This method takes one or more symbols, with each one being a name of the configuration option.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/threatinator/amqp/rcvr/settings.rb', line 13 def parameter(*names) names.each do |name| attr_accessor name @@registered_settings.push(name) # For each given symbol we generate accessor method that sets option's # value being called with an argument, or returns option's current value # when called without arguments undef_method name if method_defined? name define_method name do |*values| value = values.first if value send("#{name}=", value) else instance_variable_defined?("@#{name}") ? instance_variable_get("@#{name}") : nil end end end end |