Class: Mihari::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mihari/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



30
31
32
# File 'lib/mihari/config.rb', line 30

def initialize
  load_from_env
end

Instance Attribute Details

#binaryedge_api_keyObject

Returns the value of attribute binaryedge_api_key.



7
8
9
# File 'lib/mihari/config.rb', line 7

def binaryedge_api_key
  @binaryedge_api_key
end

#censys_idObject

Returns the value of attribute censys_id.



8
9
10
# File 'lib/mihari/config.rb', line 8

def censys_id
  @censys_id
end

#censys_secretObject

Returns the value of attribute censys_secret.



9
10
11
# File 'lib/mihari/config.rb', line 9

def censys_secret
  @censys_secret
end

#circl_passive_passwordObject

Returns the value of attribute circl_passive_password.



10
11
12
# File 'lib/mihari/config.rb', line 10

def circl_passive_password
  @circl_passive_password
end

#circl_passive_usernameObject

Returns the value of attribute circl_passive_username.



11
12
13
# File 'lib/mihari/config.rb', line 11

def circl_passive_username
  @circl_passive_username
end

#databaseObject

Returns the value of attribute database.



28
29
30
# File 'lib/mihari/config.rb', line 28

def database
  @database
end

#misp_api_endpointObject

Returns the value of attribute misp_api_endpoint.



12
13
14
# File 'lib/mihari/config.rb', line 12

def misp_api_endpoint
  @misp_api_endpoint
end

#misp_api_keyObject

Returns the value of attribute misp_api_key.



13
14
15
# File 'lib/mihari/config.rb', line 13

def misp_api_key
  @misp_api_key
end

#onyphe_api_keyObject

Returns the value of attribute onyphe_api_key.



14
15
16
# File 'lib/mihari/config.rb', line 14

def onyphe_api_key
  @onyphe_api_key
end

#passivetotal_api_keyObject

Returns the value of attribute passivetotal_api_key.



15
16
17
# File 'lib/mihari/config.rb', line 15

def passivetotal_api_key
  @passivetotal_api_key
end

#passivetotal_usernameObject

Returns the value of attribute passivetotal_username.



16
17
18
# File 'lib/mihari/config.rb', line 16

def passivetotal_username
  @passivetotal_username
end

#pulsedive_api_keyObject

Returns the value of attribute pulsedive_api_key.



17
18
19
# File 'lib/mihari/config.rb', line 17

def pulsedive_api_key
  @pulsedive_api_key
end

#securitytrails_api_keyObject

Returns the value of attribute securitytrails_api_key.



18
19
20
# File 'lib/mihari/config.rb', line 18

def securitytrails_api_key
  @securitytrails_api_key
end

#shodan_api_keyObject

Returns the value of attribute shodan_api_key.



19
20
21
# File 'lib/mihari/config.rb', line 19

def shodan_api_key
  @shodan_api_key
end

#slack_channelObject

Returns the value of attribute slack_channel.



20
21
22
# File 'lib/mihari/config.rb', line 20

def slack_channel
  @slack_channel
end

#slack_webhook_urlObject

Returns the value of attribute slack_webhook_url.



21
22
23
# File 'lib/mihari/config.rb', line 21

def slack_webhook_url
  @slack_webhook_url
end

#thehive_api_endpointObject

Returns the value of attribute thehive_api_endpoint.



22
23
24
# File 'lib/mihari/config.rb', line 22

def thehive_api_endpoint
  @thehive_api_endpoint
end

#thehive_api_keyObject

Returns the value of attribute thehive_api_key.



23
24
25
# File 'lib/mihari/config.rb', line 23

def thehive_api_key
  @thehive_api_key
end

#virustotal_api_keyObject

Returns the value of attribute virustotal_api_key.



24
25
26
# File 'lib/mihari/config.rb', line 24

def virustotal_api_key
  @virustotal_api_key
end

#zoomeye_passwordObject

Returns the value of attribute zoomeye_password.



25
26
27
# File 'lib/mihari/config.rb', line 25

def zoomeye_password
  @zoomeye_password
end

#zoomeye_usernameObject

Returns the value of attribute zoomeye_username.



26
27
28
# File 'lib/mihari/config.rb', line 26

def zoomeye_username
  @zoomeye_username
end

Class Method Details

.load_from_yaml(path) ⇒ Object

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/mihari/config.rb', line 60

def load_from_yaml(path)
  raise ArgumentError, "#{path} does not exist." unless File.exist?(path)

  data = File.read(path)
  begin
    yaml = YAML.safe_load(data)
  rescue TypeError => _e
    return
  end

  Mihari.configure do |config|
    yaml.each do |key, value|
      config.send("#{key.downcase}=".to_sym, value)
    end
  end
end

Instance Method Details

#load_from_envObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mihari/config.rb', line 34

def load_from_env
  @binaryedge_api_key = ENV["BINARYEDGE_API_KEY"]
  @censys_id = ENV["CENSYS_ID"]
  @censys_secret = ENV["CENSYS_SECRET"]
  @circl_passive_password = ENV["CIRCL_PASSIVE_PASSWORD"]
  @circl_passive_username = ENV["CIRCL_PASSIVE_USERNAME"]
  @misp_api_endpoint = ENV["MISP_API_ENDPOINT"]
  @misp_api_key = ENV["MISP_API_KEY"]
  @onyphe_api_key = ENV["ONYPHE_API_KEY"]
  @passivetotal_api_key = ENV["PASSIVETOTAL_API_KEY"]
  @passivetotal_username = ENV["PASSIVETOTAL_USERNAME"]
  @pulsedive_api_key = ENV["PULSEDIVE_API_KEY"]
  @securitytrails_api_key = ENV["SECURITYTRAILS_API_KEY"]
  @shodan_api_key = ENV["SHODAN_API_KEY"]
  @slack_channel = ENV["SLACK_CHANNEL"]
  @slack_webhook_url = ENV["SLACK_WEBHOOK_URL"]
  @thehive_api_endpoint = ENV["THEHIVE_API_ENDPOINT"]
  @thehive_api_key = ENV["THEHIVE_API_KEY"]
  @virustotal_api_key = ENV["VIRUSTOTAL_API_KEY"]
  @zoomeye_password = ENV["ZOOMEYE_PASSWORD"]
  @zoomeye_username = ENV["ZOOMEYE_USERNAME"]

  @database = ENV["DATABASE"] || "mihari.db"
end