mihari 5.6.1 → 5.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/frontend/package-lock.json +173 -176
  3. data/frontend/package.json +9 -9
  4. data/lib/mihari/{base.rb → actor.rb} +16 -2
  5. data/lib/mihari/analyzers/base.rb +5 -10
  6. data/lib/mihari/analyzers/censys.rb +1 -1
  7. data/lib/mihari/analyzers/hunterhow.rb +1 -1
  8. data/lib/mihari/analyzers/passivetotal.rb +1 -1
  9. data/lib/mihari/analyzers/pulsedive.rb +1 -1
  10. data/lib/mihari/analyzers/securitytrails.rb +1 -1
  11. data/lib/mihari/analyzers/urlscan.rb +1 -1
  12. data/lib/mihari/analyzers/virustotal.rb +5 -5
  13. data/lib/mihari/analyzers/zoomeye.rb +3 -3
  14. data/lib/mihari/clients/crtsh.rb +2 -2
  15. data/lib/mihari/clients/passivetotal.rb +4 -4
  16. data/lib/mihari/clients/securitytrails.rb +3 -3
  17. data/lib/mihari/commands/rule.rb +2 -11
  18. data/lib/mihari/commands/search.rb +1 -1
  19. data/lib/mihari/emitters/base.rb +13 -24
  20. data/lib/mihari/emitters/database.rb +7 -9
  21. data/lib/mihari/emitters/misp.rb +14 -38
  22. data/lib/mihari/emitters/slack.rb +14 -11
  23. data/lib/mihari/emitters/the_hive.rb +16 -44
  24. data/lib/mihari/emitters/webhook.rb +31 -21
  25. data/lib/mihari/enrichers/base.rb +1 -6
  26. data/lib/mihari/enrichers/whois.rb +1 -1
  27. data/lib/mihari/models/alert.rb +75 -73
  28. data/lib/mihari/models/artifact.rb +182 -180
  29. data/lib/mihari/models/autonomous_system.rb +22 -20
  30. data/lib/mihari/models/cpe.rb +21 -19
  31. data/lib/mihari/models/dns.rb +24 -22
  32. data/lib/mihari/models/geolocation.rb +22 -20
  33. data/lib/mihari/models/port.rb +21 -19
  34. data/lib/mihari/models/reverse_dns.rb +21 -19
  35. data/lib/mihari/models/rule.rb +67 -65
  36. data/lib/mihari/models/tag.rb +5 -3
  37. data/lib/mihari/models/tagging.rb +5 -3
  38. data/lib/mihari/models/whois.rb +18 -16
  39. data/lib/mihari/rule.rb +352 -0
  40. data/lib/mihari/schemas/analyzer.rb +94 -87
  41. data/lib/mihari/schemas/emitter.rb +9 -5
  42. data/lib/mihari/schemas/enricher.rb +8 -4
  43. data/lib/mihari/schemas/mixins.rb +15 -0
  44. data/lib/mihari/schemas/rule.rb +3 -10
  45. data/lib/mihari/services/alert_builder.rb +1 -1
  46. data/lib/mihari/services/alert_proxy.rb +10 -6
  47. data/lib/mihari/services/alert_runner.rb +4 -4
  48. data/lib/mihari/services/rule_builder.rb +3 -3
  49. data/lib/mihari/services/rule_runner.rb +5 -5
  50. data/lib/mihari/structs/binaryedge.rb +1 -1
  51. data/lib/mihari/structs/censys.rb +6 -6
  52. data/lib/mihari/structs/config.rb +1 -1
  53. data/lib/mihari/structs/greynoise.rb +5 -5
  54. data/lib/mihari/structs/hunterhow.rb +3 -3
  55. data/lib/mihari/structs/onyphe.rb +5 -5
  56. data/lib/mihari/structs/shodan.rb +6 -6
  57. data/lib/mihari/structs/urlscan.rb +3 -3
  58. data/lib/mihari/structs/virustotal_intelligence.rb +3 -3
  59. data/lib/mihari/version.rb +1 -1
  60. data/lib/mihari/web/endpoints/alerts.rb +4 -4
  61. data/lib/mihari/web/endpoints/artifacts.rb +6 -6
  62. data/lib/mihari/web/endpoints/rules.rb +10 -17
  63. data/lib/mihari/web/endpoints/tags.rb +2 -2
  64. data/lib/mihari/web/public/assets/{index-9cc489e6.js → index-28d4c79d.js} +48 -48
  65. data/lib/mihari/web/public/index.html +1 -1
  66. data/lib/mihari.rb +6 -8
  67. data/mihari.gemspec +1 -2
  68. data/requirements.txt +1 -1
  69. metadata +8 -22
  70. data/lib/mihari/analyzers/rule.rb +0 -232
  71. data/lib/mihari/services/rule_proxy.rb +0 -182
@@ -2,102 +2,109 @@
2
2
 
3
3
  module Mihari
4
4
  module Schemas
5
- AnalyzerAPIKeyPagination = Dry::Schema.Params do
6
- required(:analyzer).value(
7
- Types::String.enum(
8
- "binaryedge",
9
- "greynoise",
10
- "onyphe",
11
- "shodan",
12
- "urlscan",
13
- "virustotal_intelligence",
14
- "vt_intel"
15
- )
16
- )
17
- required(:query).value(:string)
18
- optional(:api_key).value(:string)
19
- optional(:options).hash(AnalyzerPaginationOptions)
20
- end
5
+ module Analyzers
6
+ extend Schemas::Mixins
21
7
 
22
- AnalyzerAPIKey = Dry::Schema.Params do
23
- required(:analyzer).value(
24
- Types::String.enum(
25
- "otx",
26
- "pulsedive",
27
- "securitytrails",
28
- "st",
29
- "virustotal",
30
- "vt"
31
- )
32
- )
33
- required(:query).value(:string)
34
- optional(:api_key).value(:string)
35
- optional(:options).hash(AnalyzerOptions)
36
- end
8
+ # Analyzer with API key and pagination
9
+ [
10
+ Mihari::Analyzers::BinaryEdge.class_keys,
11
+ Mihari::Analyzers::GreyNoise.class_keys,
12
+ Mihari::Analyzers::Onyphe.class_keys,
13
+ Mihari::Analyzers::Shodan.class_keys,
14
+ Mihari::Analyzers::Urlscan.class_keys,
15
+ Mihari::Analyzers::VirusTotalIntelligence.class_keys
16
+ ].each do |keys|
17
+ key = keys.first
18
+ const_set(key.upcase, Dry::Schema.Params do
19
+ required(:analyzer).value(Types::String.enum(*keys))
20
+ required(:query).value(:string)
21
+ optional(:api_key).value(:string)
22
+ optional(:options).hash(AnalyzerPaginationOptions)
23
+ end)
24
+ end
37
25
 
38
- DNSTwister = Dry::Schema.Params do
39
- required(:analyzer).value(Types::String.enum("dnstwister"))
40
- required(:query).value(:string)
41
- optional(:options).hash(AnalyzerOptions)
42
- end
26
+ # Analyzer with API key
27
+ [
28
+ Mihari::Analyzers::OTX.class_keys,
29
+ Mihari::Analyzers::Pulsedive.class_keys,
30
+ Mihari::Analyzers::VirusTotal.class_keys,
31
+ Mihari::Analyzers::SecurityTrails.class_keys
32
+ ].each do |keys|
33
+ key = keys.first
34
+ const_set(key.upcase, Dry::Schema.Params do
35
+ required(:analyzer).value(Types::String.enum(*keys))
36
+ required(:query).value(:string)
37
+ optional(:api_key).value(:string)
38
+ optional(:options).hash(AnalyzerOptions)
39
+ end)
40
+ end
43
41
 
44
- Censys = Dry::Schema.Params do
45
- required(:analyzer).value(Types::String.enum("censys"))
46
- required(:query).value(:string)
47
- optional(:id).value(:string)
48
- optional(:secret).value(:string)
49
- optional(:options).hash(AnalyzerPaginationOptions)
50
- end
42
+ DNSTwister = Dry::Schema.Params do
43
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::DNSTwister.class_keys))
44
+ required(:query).value(:string)
45
+ optional(:options).hash(AnalyzerOptions)
46
+ end
51
47
 
52
- CIRCL = Dry::Schema.Params do
53
- required(:analyzer).value(Types::String.enum("circl"))
54
- required(:query).value(:string)
55
- optional(:username).value(:string)
56
- optional(:password).value(:string)
57
- optional(:options).hash(AnalyzerOptions)
58
- end
48
+ Censys = Dry::Schema.Params do
49
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::Censys.class_keys))
50
+ required(:query).value(:string)
51
+ optional(:id).value(:string)
52
+ optional(:secret).value(:string)
53
+ optional(:options).hash(AnalyzerPaginationOptions)
54
+ end
59
55
 
60
- PassiveTotal = Dry::Schema.Params do
61
- required(:analyzer).value(Types::String.enum("passivetotal", "pt"))
62
- required(:query).value(:string)
63
- optional(:username).value(:string)
64
- optional(:api_key).value(:string)
65
- optional(:options).hash(AnalyzerOptions)
66
- end
56
+ CIRCL = Dry::Schema.Params do
57
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::CIRCL.class_keys))
58
+ required(:query).value(:string)
59
+ optional(:username).value(:string)
60
+ optional(:password).value(:string)
61
+ optional(:options).hash(AnalyzerOptions)
62
+ end
67
63
 
68
- ZoomEye = Dry::Schema.Params do
69
- required(:analyzer).value(Types::String.enum("zoomeye"))
70
- required(:query).value(:string)
71
- required(:type).value(Types::String.enum("host", "web"))
72
- optional(:options).hash(AnalyzerPaginationOptions)
73
- end
64
+ PassiveTotal = Dry::Schema.Params do
65
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::PassiveTotal.class_keys))
66
+ required(:query).value(:string)
67
+ optional(:username).value(:string)
68
+ optional(:api_key).value(:string)
69
+ optional(:options).hash(AnalyzerOptions)
70
+ end
74
71
 
75
- Crtsh = Dry::Schema.Params do
76
- required(:analyzer).value(Types::String.enum("crtsh"))
77
- required(:query).value(:string)
78
- optional(:exclude_expired).value(:bool).default(true)
79
- optional(:options).hash(AnalyzerOptions)
80
- end
72
+ ZoomEye = Dry::Schema.Params do
73
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::ZoomEye.class_keys))
74
+ required(:query).value(:string)
75
+ required(:type).value(Types::String.enum("host", "web"))
76
+ optional(:options).hash(AnalyzerPaginationOptions)
77
+ end
81
78
 
82
- HunterHow = Dry::Schema.Params do
83
- required(:analyzer).value(Types::String.enum("hunterhow"))
84
- required(:query).value(:string)
85
- required(:start_time).value(:date)
86
- required(:end_time).value(:date)
87
- optional(:api_key).value(:string)
88
- optional(:options).hash(AnalyzerPaginationOptions)
89
- end
79
+ Crtsh = Dry::Schema.Params do
80
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::Crtsh.class_keys))
81
+ required(:query).value(:string)
82
+ optional(:exclude_expired).value(:bool).default(true)
83
+ optional(:options).hash(AnalyzerOptions)
84
+ end
90
85
 
91
- Feed = Dry::Schema.Params do
92
- required(:analyzer).value(Types::String.enum("feed"))
93
- required(:query).value(:string)
94
- required(:selector).value(:string)
95
- optional(:method).value(Types::HTTPRequestMethods).default("GET")
96
- optional(:headers).value(:hash).default({})
97
- optional(:params).value(:hash)
98
- optional(:data).value(:hash)
99
- optional(:json).value(:hash)
100
- optional(:options).hash(AnalyzerOptions)
86
+ HunterHow = Dry::Schema.Params do
87
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::HunterHow.class_keys))
88
+ required(:query).value(:string)
89
+ required(:start_time).value(:date)
90
+ required(:end_time).value(:date)
91
+ optional(:api_key).value(:string)
92
+ optional(:options).hash(AnalyzerPaginationOptions)
93
+ end
94
+
95
+ Feed = Dry::Schema.Params do
96
+ required(:analyzer).value(Types::String.enum(*Mihari::Analyzers::Feed.class_keys))
97
+ required(:query).value(:string)
98
+ required(:selector).value(:string)
99
+ optional(:method).value(Types::HTTPRequestMethods).default("GET")
100
+ optional(:headers).value(:hash).default({})
101
+ optional(:params).value(:hash)
102
+ optional(:data).value(:hash)
103
+ optional(:json).value(:hash)
104
+ optional(:options).hash(AnalyzerOptions)
105
+ end
101
106
  end
107
+
108
+ Analyzer = Schemas::Analyzers.get_or_composition
102
109
  end
103
110
  end
@@ -3,20 +3,22 @@
3
3
  module Mihari
4
4
  module Schemas
5
5
  module Emitters
6
+ extend Schemas::Mixins
7
+
6
8
  Database = Dry::Schema.Params do
7
- required(:emitter).value(Types::String.enum("database"))
9
+ required(:emitter).value(Types::String.enum(*Mihari::Emitters::Database.class_keys))
8
10
  optional(:options).hash(Options)
9
11
  end
10
12
 
11
13
  MISP = Dry::Schema.Params do
12
- required(:emitter).value(Types::String.enum("misp"))
14
+ required(:emitter).value(Types::String.enum(*Mihari::Emitters::MISP.class_keys))
13
15
  optional(:url).value(:string)
14
16
  optional(:api_key).value(:string)
15
17
  optional(:options).hash(Options)
16
18
  end
17
19
 
18
20
  TheHive = Dry::Schema.Params do
19
- required(:emitter).value(Types::String.enum("thehive"))
21
+ required(:emitter).value(Types::String.enum(*Mihari::Emitters::TheHive.class_keys))
20
22
  optional(:url).value(:string)
21
23
  optional(:api_key).value(:string)
22
24
  optional(:api_version).value(Types::String.enum("v4", "v5")).default("v4")
@@ -24,14 +26,14 @@ module Mihari
24
26
  end
25
27
 
26
28
  Slack = Dry::Schema.Params do
27
- required(:emitter).value(Types::String.enum("slack"))
29
+ required(:emitter).value(Types::String.enum(*Mihari::Emitters::Slack.class_keys))
28
30
  optional(:webhook_url).value(:string)
29
31
  optional(:channel).value(:string)
30
32
  optional(:options).hash(Options)
31
33
  end
32
34
 
33
35
  Webhook = Dry::Schema.Params do
34
- required(:emitter).value(Types::String.enum("webhook"))
36
+ required(:emitter).value(Types::String.enum(*Mihari::Emitters::Webhook.class_keys))
35
37
  required(:url).value(:string)
36
38
  optional(:method).value(Types::HTTPRequestMethods).default("POST")
37
39
  optional(:headers).value(:hash).default({})
@@ -39,5 +41,7 @@ module Mihari
39
41
  optional(:options).hash(Options)
40
42
  end
41
43
  end
44
+
45
+ Emitter = Schemas::Emitters.get_or_composition
42
46
  end
43
47
  end
@@ -3,26 +3,30 @@
3
3
  module Mihari
4
4
  module Schemas
5
5
  module Enrichers
6
+ extend Schemas::Mixins
7
+
6
8
  IPInfo = Dry::Schema.Params do
7
- required(:enricher).value(Types::String.enum("ipinfo"))
9
+ required(:enricher).value(Types::String.enum(*Mihari::Enrichers::IPInfo.class_keys))
8
10
  optional(:api_key).value(:string)
9
11
  optional(:options).hash(Options)
10
12
  end
11
13
 
12
14
  Whois = Dry::Schema.Params do
13
- required(:enricher).value(Types::String.enum("whois"))
15
+ required(:enricher).value(Types::String.enum(*Mihari::Enrichers::Whois.class_keys))
14
16
  optional(:options).hash(Options)
15
17
  end
16
18
 
17
19
  Shodan = Dry::Schema.Params do
18
- required(:enricher).value(Types::String.enum("shodan"))
20
+ required(:enricher).value(Types::String.enum(*Mihari::Enrichers::Shodan.class_keys))
19
21
  optional(:options).hash(Options)
20
22
  end
21
23
 
22
24
  GooglePublicDNS = Dry::Schema.Params do
23
- required(:enricher).value(Types::String.enum("google_public_dns"))
25
+ required(:enricher).value(Types::String.enum(*Mihari::Enrichers::GooglePublicDNS.class_keys))
24
26
  optional(:options).hash(Options)
25
27
  end
26
28
  end
29
+
30
+ Enricher = Schemas::Enrichers.get_or_composition
27
31
  end
28
32
  end
@@ -0,0 +1,15 @@
1
+ module Mihari
2
+ module Schemas
3
+ module Mixins
4
+ def get_or_composition
5
+ schemas = constants.map { |sym| const_get sym }
6
+ return schemas.first if schemas.length <= 1
7
+
8
+ base, *others = schemas
9
+ others.each { |other| base = base.or(other) }
10
+
11
+ base
12
+ end
13
+ end
14
+ end
15
+ end
@@ -21,17 +21,10 @@ module Mihari
21
21
  optional(:created_on).value(:date)
22
22
  optional(:updated_on).value(:date)
23
23
 
24
- required(:queries).value(:array).each do
25
- AnalyzerAPIKey | AnalyzerAPIKeyPagination | Censys | CIRCL | PassiveTotal | ZoomEye | Crtsh | Feed | HunterHow | DNSTwister
26
- end
27
-
28
- optional(:emitters).value(:array).each do
29
- Emitters::Database | Emitters::MISP | Emitters::TheHive | Emitters::Slack | Emitters::Webhook
30
- end.default(DEFAULT_EMITTERS)
24
+ required(:queries).value(:array).each { Analyzer } # rubocop:disable Lint/Void
31
25
 
32
- optional(:enrichers).value(:array).each do
33
- Enrichers::Whois | Enrichers::IPInfo | Enrichers::Shodan | Enrichers::GooglePublicDNS
34
- end.default(DEFAULT_ENRICHERS)
26
+ optional(:emitters).value(:array).each { Emitter }.default(DEFAULT_EMITTERS) # rubocop:disable Lint/Void
27
+ optional(:enrichers).value(:array).each { Enricher }.default(DEFAULT_ENRICHERS) # rubocop:disable Lint/Void
35
28
 
36
29
  optional(:data_types).value(array[Types::DataTypes]).default(Mihari::Types::DataTypes.values)
37
30
  optional(:falsepositives).value(array[:string]).default([])
@@ -36,7 +36,7 @@ module Mihari
36
36
  end
37
37
 
38
38
  def result
39
- Try[StandardError] { AlertProxy.new(data) }.to_result
39
+ Try[StandardError] { AlertProxy.new(**data) }.to_result
40
40
  end
41
41
  end
42
42
  end
@@ -16,7 +16,7 @@ module Mihari
16
16
  #
17
17
  # @param [Hash] data
18
18
  #
19
- def initialize(data)
19
+ def initialize(**data)
20
20
  @data = data.deep_symbolize_keys
21
21
  @errors = nil
22
22
 
@@ -54,21 +54,24 @@ module Mihari
54
54
  end
55
55
 
56
56
  #
57
- # @return [Array<Mihari::Artifact>]
57
+ # @return [Array<Mihari::Models::Artifact>]
58
58
  #
59
59
  def artifacts
60
60
  @artifacts ||= data[:artifacts].map do |data|
61
- artifact = Artifact.new(data: data)
61
+ artifact = Models::Artifact.new(data: data)
62
62
  artifact.rule_id = rule_id
63
63
  artifact
64
64
  end.uniq(&:data).select(&:valid?)
65
65
  end
66
66
 
67
67
  #
68
- # @return [Mihari::Services::RuleProxy]
68
+ # @return [Mihari::Rule]
69
69
  #
70
70
  def rule
71
- @rule ||= Services::RuleProxy.new(Mihari::Rule.find(rule_id).data)
71
+ @rule ||= [].tap do |out|
72
+ data = Mihari::Models::Rule.find(rule_id).data
73
+ out << Rule.new(**data)
74
+ end.first
72
75
  end
73
76
 
74
77
  class << self
@@ -80,7 +83,8 @@ module Mihari
80
83
  # @return [Mihari::Services::Alert]
81
84
  #
82
85
  def from_yaml(yaml)
83
- new YAML.safe_load(yaml, permitted_classes: [Date, Symbol])
86
+ data = YAML.safe_load(yaml, permitted_classes: [Date, Symbol])
87
+ new(**data)
84
88
  end
85
89
  end
86
90
  end
@@ -13,15 +13,15 @@ module Mihari
13
13
  end
14
14
 
15
15
  #
16
- # @return [Mihari::Alert]
16
+ # @return [Mihari::Models::Alert]
17
17
  #
18
18
  def run
19
- emitter = Emitters::Database.new(artifacts: alert.artifacts, rule: alert.rule)
20
- emitter.emit
19
+ emitter = Emitters::Database.new(rule: alert.rule)
20
+ emitter.emit alert.artifacts
21
21
  end
22
22
 
23
23
  #
24
- # @return [Dry::Monads::Result::Success<Mihari::Alert, nil>, Dry::Monads::Result::Failure]
24
+ # @return [Dry::Monads::Result::Success<Mihari::Models::Alert, nil>, Dry::Monads::Result::Failure]
25
25
  #
26
26
  def result
27
27
  Try[StandardError] { run }.to_result
@@ -26,8 +26,8 @@ module Mihari
26
26
  # @return [Hash]
27
27
  #
28
28
  def data
29
- if Mihari::Rule.exists?(path_or_id)
30
- rule = Mihari::Rule.find(path_or_id)
29
+ if Mihari::Models::Rule.exists?(path_or_id)
30
+ rule = Mihari::Models::Rule.find(path_or_id)
31
31
  return rule.data
32
32
  end
33
33
 
@@ -40,7 +40,7 @@ module Mihari
40
40
  end
41
41
 
42
42
  def result
43
- Try[StandardError] { RuleProxy.new(data) }.to_result
43
+ Try[StandardError] { Rule.new(**data) }.to_result
44
44
  end
45
45
  end
46
46
  end
@@ -5,7 +5,7 @@ module Mihari
5
5
  class RuleRunner
6
6
  include Dry::Monads[:result, :try]
7
7
 
8
- # @return [Mihari::Services::RuleProxy]
8
+ # @return [Mihari::Rule]
9
9
  attr_reader :rule
10
10
 
11
11
  def initialize(rule)
@@ -16,7 +16,7 @@ module Mihari
16
16
  # @return [Boolean]
17
17
  #
18
18
  def diff?
19
- model = Mihari::Rule.find(rule.id)
19
+ model = Mihari::Models::Rule.find(rule.id)
20
20
  model.data != rule.data.deep_stringify_keys
21
21
  rescue ActiveRecord::RecordNotFound
22
22
  false
@@ -27,14 +27,14 @@ module Mihari
27
27
  end
28
28
 
29
29
  #
30
- # @return [Mihari::Alert, nil]
30
+ # @return [Mihari::Models::Alert, nil]
31
31
  #
32
32
  def run
33
- rule.analyzer.run
33
+ rule.run
34
34
  end
35
35
 
36
36
  #
37
- # @return [Dry::Monads::Result::Success<Mihari::Alert, nil>, Dry::Monads::Result::Failure]
37
+ # @return [Dry::Monads::Result::Success<Mihari::Models::Alert, nil>, Dry::Monads::Result::Failure]
38
38
  #
39
39
  def result
40
40
  Try[StandardError] { run }.to_result
@@ -69,7 +69,7 @@ module Mihari
69
69
  # @return [Array<Artifact>]
70
70
  #
71
71
  def artifacts
72
- events.map { |event| Artifact.new(data: event.target.ip) }
72
+ events.map { |event| Models::Artifact.new(data: event.target.ip) }
73
73
  end
74
74
 
75
75
  class << self
@@ -19,7 +19,7 @@ module Mihari
19
19
  # @return [Mihari::AutonomousSystem]
20
20
  #
21
21
  def as
22
- Mihari::AutonomousSystem.new(asn: normalize_asn(asn))
22
+ Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn))
23
23
  end
24
24
 
25
25
  class << self
@@ -63,7 +63,7 @@ module Mihari
63
63
  # then set geolocation as nil
64
64
  return nil if country.nil?
65
65
 
66
- Mihari::Geolocation.new(
66
+ Mihari::Models::Geolocation.new(
67
67
  country: country,
68
68
  country_code: country_code
69
69
  )
@@ -99,7 +99,7 @@ module Mihari
99
99
  # @return [Mihari::Port]
100
100
  #
101
101
  def _port
102
- Port.new(port: port)
102
+ Models::Port.new(port: port)
103
103
  end
104
104
 
105
105
  class << self
@@ -167,10 +167,10 @@ module Mihari
167
167
  end
168
168
 
169
169
  #
170
- # @return [Mihari::Artifact]
170
+ # @return [Mihari::Models::Artifact]
171
171
  #
172
172
  def artifact
173
- Artifact.new(
173
+ Models::Artifact.new(
174
174
  data: ip,
175
175
  metadata: metadata,
176
176
  autonomous_system: autonomous_system.as,
@@ -267,7 +267,7 @@ module Mihari
267
267
  end
268
268
 
269
269
  #
270
- # @return [Array<Mihari::Artifact>]
270
+ # @return [Array<Mihari::Models::Artifact>]
271
271
  #
272
272
  def artifacts
273
273
  hits.map(&:artifact)
@@ -71,7 +71,7 @@ module Mihari
71
71
  # @return [Mihari::Structs::Config, nil] config
72
72
  #
73
73
  def from_class(klass)
74
- return nil if klass == Mihari::Analyzers::Rule
74
+ return nil if klass == Mihari::Rule
75
75
 
76
76
  type = get_type(klass)
77
77
  return nil if type.nil?
@@ -35,14 +35,14 @@ module Mihari
35
35
  # @return [Mihari::AutonomousSystem]
36
36
  #
37
37
  def as
38
- Mihari::AutonomousSystem.new(asn: normalize_asn(asn))
38
+ Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn))
39
39
  end
40
40
 
41
41
  #
42
42
  # @return [Mihari::Geolocation]
43
43
  #
44
44
  def geolocation
45
- Mihari::Geolocation.new(
45
+ Mihari::Models::Geolocation.new(
46
46
  country: country,
47
47
  country_code: country_code
48
48
  )
@@ -92,10 +92,10 @@ module Mihari
92
92
  end
93
93
 
94
94
  #
95
- # @return [Mihari::Artifact]
95
+ # @return [Mihari::Models::Artifact]
96
96
  #
97
97
  def artifact
98
- Mihari::Artifact.new(
98
+ Mihari::Models::Artifact.new(
99
99
  data: ip,
100
100
  metadata: metadata_,
101
101
  autonomous_system: metadata.as,
@@ -171,7 +171,7 @@ module Mihari
171
171
  end
172
172
 
173
173
  #
174
- # @return [Array<Mihari::Artifact>]
174
+ # @return [Array<Mihari::Models::Artifact>]
175
175
  #
176
176
  def artifacts
177
177
  data.map(&:artifact)
@@ -14,10 +14,10 @@ module Mihari
14
14
  end
15
15
 
16
16
  #
17
- # @return [Mihari::Artifact]
17
+ # @return [Mihari::Models::Artifact]
18
18
  #
19
19
  def artifact
20
- Artifact.new(data: ip)
20
+ Models::Artifact.new(data: ip)
21
21
  end
22
22
 
23
23
  class << self
@@ -49,7 +49,7 @@ module Mihari
49
49
  end
50
50
 
51
51
  #
52
- # @return [Array<Mihari::Artifact>]
52
+ # @return [Array<Mihari::Models::Artifact>]
53
53
  #
54
54
  def artifacts
55
55
  list.map(&:artifact)
@@ -40,10 +40,10 @@ module Mihari
40
40
  end
41
41
 
42
42
  #
43
- # @return [Mihari::Artifact]
43
+ # @return [Mihari::Models::Artifact]
44
44
  #
45
45
  def artifact
46
- Mihari::Artifact.new(
46
+ Mihari::Models::Artifact.new(
47
47
  data: ip,
48
48
  metadata: metadata,
49
49
  autonomous_system: as,
@@ -57,7 +57,7 @@ module Mihari
57
57
  def geolocation
58
58
  return nil if country_code.nil?
59
59
 
60
- Mihari::Geolocation.new(
60
+ Mihari::Models::Geolocation.new(
61
61
  country: NormalizeCountry(country_code, to: :short),
62
62
  country_code: country_code
63
63
  )
@@ -67,7 +67,7 @@ module Mihari
67
67
  # @return [Mihari::AutonomousSystem]
68
68
  #
69
69
  def as
70
- Mihari::AutonomousSystem.new(asn: normalize_asn(asn))
70
+ Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn))
71
71
  end
72
72
 
73
73
  class << self
@@ -148,7 +148,7 @@ module Mihari
148
148
  end
149
149
 
150
150
  #
151
- # @return [Array<Mihari::Artifact>]
151
+ # @return [Array<Mihari::Models::Artifact>]
152
152
  #
153
153
  def artifacts
154
154
  results.map(&:artifact)
@@ -27,7 +27,7 @@ module Mihari
27
27
  def geolocation
28
28
  return nil if country_name.nil? && country_code.nil?
29
29
 
30
- Mihari::Geolocation.new(
30
+ Mihari::Models::Geolocation.new(
31
31
  country: country_name,
32
32
  country_code: country_code
33
33
  )
@@ -108,7 +108,7 @@ module Mihari
108
108
  def _asn
109
109
  return nil if asn.nil?
110
110
 
111
- Mihari::AutonomousSystem.new(asn: normalize_asn(asn))
111
+ Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn))
112
112
  end
113
113
 
114
114
  class << self
@@ -192,20 +192,20 @@ module Mihari
192
192
  end
193
193
 
194
194
  #
195
- # @return [Array<Mihari::Artifact>]
195
+ # @return [Array<Mihari::Models::Artifact>]
196
196
  #
197
197
  def artifacts
198
198
  matches.map do |match|
199
199
  metadata = collect_metadata_by_ip(match.ip_str)
200
200
 
201
201
  ports = collect_ports_by_ip(match.ip_str).map do |port|
202
- Mihari::Port.new(port: port)
202
+ Mihari::Models::Port.new(port: port)
203
203
  end
204
204
  reverse_dns_names = collect_hostnames_by_ip(match.ip_str).map do |name|
205
- Mihari::ReverseDnsName.new(name: name)
205
+ Mihari::Models::ReverseDnsName.new(name: name)
206
206
  end
207
207
 
208
- Mihari::Artifact.new(
208
+ Mihari::Models::Artifact.new(
209
209
  data: match.ip_str,
210
210
  metadata: metadata,
211
211
  autonomous_system: match._asn,