mihari 5.7.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/config.ru +2 -0
  4. data/lib/mihari/actor.rb +1 -1
  5. data/lib/mihari/analyzers/base.rb +3 -0
  6. data/lib/mihari/analyzers/dnstwister.rb +2 -4
  7. data/lib/mihari/analyzers/hunterhow.rb +1 -1
  8. data/lib/mihari/analyzers/urlscan.rb +1 -4
  9. data/lib/mihari/cli/main.rb +2 -12
  10. data/lib/mihari/commands/database.rb +0 -1
  11. data/lib/mihari/config.rb +5 -1
  12. data/lib/mihari/database.rb +9 -5
  13. data/lib/mihari/emitters/misp.rb +2 -2
  14. data/lib/mihari/emitters/slack.rb +8 -11
  15. data/lib/mihari/emitters/the_hive.rb +5 -9
  16. data/lib/mihari/enrichers/base.rb +2 -0
  17. data/lib/mihari/enrichers/google_public_dns.rb +2 -7
  18. data/lib/mihari/enrichers/ipinfo.rb +2 -3
  19. data/lib/mihari/enrichers/shodan.rb +2 -3
  20. data/lib/mihari/enrichers/whois.rb +11 -20
  21. data/lib/mihari/entities/artifact.rb +1 -0
  22. data/lib/mihari/mixins/falsepositive.rb +2 -2
  23. data/lib/mihari/mixins/refang.rb +1 -4
  24. data/lib/mihari/mixins/unwrap_error.rb +27 -0
  25. data/lib/mihari/models/alert.rb +1 -3
  26. data/lib/mihari/models/artifact.rb +18 -12
  27. data/lib/mihari/models/rule.rb +1 -2
  28. data/lib/mihari/rule.rb +14 -10
  29. data/lib/mihari/service.rb +2 -0
  30. data/lib/mihari/services/rule_builder.rb +2 -4
  31. data/lib/mihari/structs/fofa.rb +2 -0
  32. data/lib/mihari/version.rb +1 -1
  33. data/lib/mihari/web/app.rb +5 -3
  34. data/lib/mihari/web/endpoints/alerts.rb +14 -18
  35. data/lib/mihari/web/endpoints/artifacts.rb +17 -22
  36. data/lib/mihari/web/endpoints/configs.rb +0 -1
  37. data/lib/mihari/web/endpoints/ip_addresses.rb +1 -1
  38. data/lib/mihari/web/endpoints/rules.rb +27 -32
  39. data/lib/mihari/web/endpoints/tags.rb +7 -9
  40. data/lib/mihari/web/middleware/connection_adapter.rb +3 -5
  41. data/lib/mihari/web/middleware/error_notification_adapter.rb +10 -6
  42. data/lib/mihari/web/public/assets/{index-ec641cb0.js → index-216d49d1.js} +42 -42
  43. data/lib/mihari/web/public/assets/{index-56fc2187.css → index-4c8509ee.css} +1 -1
  44. data/lib/mihari/web/public/index.html +2 -2
  45. data/lib/mihari/web/public/redoc-static.html +29 -49
  46. data/lib/mihari.rb +9 -10
  47. data/mihari.gemspec +11 -13
  48. data/mkdocs.yml +1 -0
  49. data/requirements.txt +1 -1
  50. metadata +76 -34
  51. data/lib/mihari/services/rule_runner.rb +0 -19
data/lib/mihari.rb CHANGED
@@ -32,7 +32,7 @@ require "grape-entity"
32
32
  require "addressable/uri"
33
33
  require "awrence"
34
34
  require "email_address"
35
- require "memist"
35
+ require "memo_wise"
36
36
  require "parallel"
37
37
  require "plissken"
38
38
  require "public_suffix"
@@ -55,13 +55,14 @@ require "mihari/mixins/configurable"
55
55
  require "mihari/mixins/falsepositive"
56
56
  require "mihari/mixins/refang"
57
57
  require "mihari/mixins/retriable"
58
+ require "mihari/mixins/unwrap_error"
58
59
 
59
60
  #
60
61
  # Mihari module
61
62
  #
62
63
  module Mihari
63
64
  class << self
64
- include Memist::Memoizable
65
+ prepend MemoWise
65
66
 
66
67
  #
67
68
  # @return [Array<Mihari::Emitters::Base>]
@@ -69,7 +70,7 @@ module Mihari
69
70
  def emitters
70
71
  []
71
72
  end
72
- memoize :emitters
73
+ memo_wise :emitters
73
74
 
74
75
  #
75
76
  # @return [Hash{String => Mihari::Enrichers::Base}]
@@ -86,7 +87,7 @@ module Mihari
86
87
  def analyzers
87
88
  []
88
89
  end
89
- memoize :analyzers
90
+ memo_wise :analyzers
90
91
 
91
92
  #
92
93
  # @return [Hash{String => Mihari::Analyzers::Base}]
@@ -103,7 +104,7 @@ module Mihari
103
104
  def enrichers
104
105
  []
105
106
  end
106
- memoize :enrichers
107
+ memo_wise :enrichers
107
108
 
108
109
  #
109
110
  # @return [Hash{String => Mihari::Enrichers::Base}]
@@ -126,7 +127,7 @@ module Mihari
126
127
  SemanticLogger.add_appender(io: $stderr, formatter: :color)
127
128
  SemanticLogger["Mihari"]
128
129
  end
129
- memoize :logger
130
+ memo_wise :logger
130
131
 
131
132
  def initialize_sentry
132
133
  return if Mihari.config.sentry_dsn.nil?
@@ -134,8 +135,7 @@ module Mihari
134
135
 
135
136
  Sentry.init do |config|
136
137
  config.dsn = Mihari.config.sentry_dsn
137
-
138
- config.traces_sample_rate = 0.5
138
+ config.traces_sample_rate = Mihari.config.sentry_trace_sample_rate
139
139
  end
140
140
  end
141
141
  end
@@ -260,7 +260,6 @@ require "mihari/schemas/rule"
260
260
 
261
261
  # Services
262
262
  require "mihari/services/rule_builder"
263
- require "mihari/services/rule_runner"
264
263
 
265
264
  require "mihari/services/alert_builder"
266
265
  require "mihari/services/alert_runner"
@@ -291,5 +290,5 @@ require "mihari/web/app"
291
290
  # CLIs
292
291
  require "mihari/cli/main"
293
292
 
294
- # initialize Sentry
293
+ # initialize Sentry (if it's possible)
295
294
  Mihari.initialize_sentry
data/mihari.gemspec CHANGED
@@ -10,10 +10,6 @@ def ci_env?
10
10
  ENV["CI"]
11
11
  end
12
12
 
13
- def is_ruby2?
14
- RUBY_VERSION.to_s.start_with?("2.")
15
- end
16
-
17
13
  Gem::Specification.new do |spec|
18
14
  spec.name = "mihari"
19
15
  spec.version = Mihari::VERSION
@@ -24,7 +20,7 @@ Gem::Specification.new do |spec|
24
20
  spec.homepage = "https://github.com/ninoseki/mihari"
25
21
  spec.license = "MIT"
26
22
 
27
- spec.required_ruby_version = ">= 2.7"
23
+ spec.required_ruby_version = ">= 3.1"
28
24
 
29
25
  spec.metadata["rubygems_mfa_required"] = "true"
30
26
 
@@ -40,6 +36,8 @@ Gem::Specification.new do |spec|
40
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
41
37
  spec.require_paths = ["lib"]
42
38
 
39
+ spec.add_development_dependency "better_errors", "~> 2.10"
40
+ spec.add_development_dependency "binding_of_caller", "~> 1.0"
43
41
  spec.add_development_dependency "bundler", "~> 2.4"
44
42
  spec.add_development_dependency "coveralls_reborn", "~> 0.28"
45
43
  spec.add_development_dependency "fakefs", "~> 2.5"
@@ -48,20 +46,20 @@ Gem::Specification.new do |spec|
48
46
  spec.add_development_dependency "mysql2", "~> 0.5"
49
47
  spec.add_development_dependency "pg", "~> 1.5"
50
48
  spec.add_development_dependency "rack-test", "~> 2.1"
51
- spec.add_development_dependency "rake", "~> 13.0"
49
+ spec.add_development_dependency "rake", "~> 13.1"
52
50
  spec.add_development_dependency "rb-fsevent", "~> 0.11"
53
51
  spec.add_development_dependency "rerun", "~> 0.14"
54
52
  spec.add_development_dependency "rspec", "~> 3.12"
53
+ spec.add_development_dependency "rspec-parameterized", "~> 1.0"
55
54
  spec.add_development_dependency "rubocop-rspec", "~> 2.25"
55
+ spec.add_development_dependency "rubocop-yard", "~> 0.8"
56
56
  spec.add_development_dependency "simplecov-lcov", "~> 0.8"
57
- spec.add_development_dependency "standard", "~> 1.31"
57
+ spec.add_development_dependency "standard", "~> 1.32"
58
58
  spec.add_development_dependency "test-prof", "~> 1.2"
59
59
  spec.add_development_dependency "timecop", "~> 0.9"
60
60
  spec.add_development_dependency "vcr", "~> 6.2"
61
61
  spec.add_development_dependency "webmock", "~> 3.19"
62
62
 
63
- spec.add_development_dependency "rubocop-yard", "~> 0.7" unless is_ruby2?
64
-
65
63
  unless ci_env?
66
64
  spec.add_development_dependency "lefthook", "~> 1.5"
67
65
  spec.add_development_dependency "solargraph", "~> 0.49"
@@ -79,18 +77,18 @@ Gem::Specification.new do |spec|
79
77
  spec.add_dependency "dry-struct", "1.6.0"
80
78
  spec.add_dependency "dry-validation", "1.10.0"
81
79
  spec.add_dependency "email_address", "0.2.4"
82
- spec.add_dependency "grape", "1.8.0"
80
+ spec.add_dependency "grape", "2.0.0"
83
81
  spec.add_dependency "grape-entity", "1.0.0"
84
- spec.add_dependency "grape-swagger", "1.6.1"
82
+ spec.add_dependency "grape-swagger", "2.0.0"
85
83
  spec.add_dependency "grape-swagger-entity", "0.5.2"
86
84
  spec.add_dependency "http", "5.1.1"
87
85
  spec.add_dependency "jr-cli", "0.6.0"
88
86
  spec.add_dependency "launchy", "2.5.2"
89
- spec.add_dependency "memist", "2.0.2"
87
+ spec.add_dependency "memo_wise", "1.8.0"
90
88
  spec.add_dependency "normalize_country", "0.3.2"
91
89
  spec.add_dependency "parallel", "1.23.0"
92
90
  spec.add_dependency "plissken", "2.0.1"
93
- spec.add_dependency "public_suffix", "5.0.3"
91
+ spec.add_dependency "public_suffix", "5.0.4"
94
92
  spec.add_dependency "puma", "6.4.0"
95
93
  spec.add_dependency "rack", "3.0.8"
96
94
  spec.add_dependency "rack-cors", "2.0.1"
data/mkdocs.yml CHANGED
@@ -19,6 +19,7 @@ nav:
19
19
  - Docker: tips/docker.md
20
20
  - GitHub Actions: tips/github_actions.md
21
21
  - Superset: tips/superset.md
22
+ - Sentry: tips/sentry.md
22
23
  - Alternatives: tips/alternatives.md
23
24
  - References:
24
25
  - Analyzers: analyzers/index.md
data/requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
1
  mkdocs==1.5.3
2
- mkdocs-material==9.4.7
2
+ mkdocs-material==9.4.10
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mihari
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.7.2
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2023-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: better_errors
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: binding_of_caller
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +156,14 @@ dependencies:
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: '13.0'
159
+ version: '13.1'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: '13.0'
166
+ version: '13.1'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: rb-fsevent
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +206,20 @@ dependencies:
178
206
  - - "~>"
179
207
  - !ruby/object:Gem::Version
180
208
  version: '3.12'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rspec-parameterized
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.0'
181
223
  - !ruby/object:Gem::Dependency
182
224
  name: rubocop-rspec
183
225
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +234,20 @@ dependencies:
192
234
  - - "~>"
193
235
  - !ruby/object:Gem::Version
194
236
  version: '2.25'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop-yard
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.8'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.8'
195
251
  - !ruby/object:Gem::Dependency
196
252
  name: simplecov-lcov
197
253
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +268,14 @@ dependencies:
212
268
  requirements:
213
269
  - - "~>"
214
270
  - !ruby/object:Gem::Version
215
- version: '1.31'
271
+ version: '1.32'
216
272
  type: :development
217
273
  prerelease: false
218
274
  version_requirements: !ruby/object:Gem::Requirement
219
275
  requirements:
220
276
  - - "~>"
221
277
  - !ruby/object:Gem::Version
222
- version: '1.31'
278
+ version: '1.32'
223
279
  - !ruby/object:Gem::Dependency
224
280
  name: test-prof
225
281
  requirement: !ruby/object:Gem::Requirement
@@ -276,20 +332,6 @@ dependencies:
276
332
  - - "~>"
277
333
  - !ruby/object:Gem::Version
278
334
  version: '3.19'
279
- - !ruby/object:Gem::Dependency
280
- name: rubocop-yard
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - "~>"
284
- - !ruby/object:Gem::Version
285
- version: '0.7'
286
- type: :development
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - "~>"
291
- - !ruby/object:Gem::Version
292
- version: '0.7'
293
335
  - !ruby/object:Gem::Dependency
294
336
  name: lefthook
295
337
  requirement: !ruby/object:Gem::Requirement
@@ -492,14 +534,14 @@ dependencies:
492
534
  requirements:
493
535
  - - '='
494
536
  - !ruby/object:Gem::Version
495
- version: 1.8.0
537
+ version: 2.0.0
496
538
  type: :runtime
497
539
  prerelease: false
498
540
  version_requirements: !ruby/object:Gem::Requirement
499
541
  requirements:
500
542
  - - '='
501
543
  - !ruby/object:Gem::Version
502
- version: 1.8.0
544
+ version: 2.0.0
503
545
  - !ruby/object:Gem::Dependency
504
546
  name: grape-entity
505
547
  requirement: !ruby/object:Gem::Requirement
@@ -520,14 +562,14 @@ dependencies:
520
562
  requirements:
521
563
  - - '='
522
564
  - !ruby/object:Gem::Version
523
- version: 1.6.1
565
+ version: 2.0.0
524
566
  type: :runtime
525
567
  prerelease: false
526
568
  version_requirements: !ruby/object:Gem::Requirement
527
569
  requirements:
528
570
  - - '='
529
571
  - !ruby/object:Gem::Version
530
- version: 1.6.1
572
+ version: 2.0.0
531
573
  - !ruby/object:Gem::Dependency
532
574
  name: grape-swagger-entity
533
575
  requirement: !ruby/object:Gem::Requirement
@@ -585,19 +627,19 @@ dependencies:
585
627
  - !ruby/object:Gem::Version
586
628
  version: 2.5.2
587
629
  - !ruby/object:Gem::Dependency
588
- name: memist
630
+ name: memo_wise
589
631
  requirement: !ruby/object:Gem::Requirement
590
632
  requirements:
591
633
  - - '='
592
634
  - !ruby/object:Gem::Version
593
- version: 2.0.2
635
+ version: 1.8.0
594
636
  type: :runtime
595
637
  prerelease: false
596
638
  version_requirements: !ruby/object:Gem::Requirement
597
639
  requirements:
598
640
  - - '='
599
641
  - !ruby/object:Gem::Version
600
- version: 2.0.2
642
+ version: 1.8.0
601
643
  - !ruby/object:Gem::Dependency
602
644
  name: normalize_country
603
645
  requirement: !ruby/object:Gem::Requirement
@@ -646,14 +688,14 @@ dependencies:
646
688
  requirements:
647
689
  - - '='
648
690
  - !ruby/object:Gem::Version
649
- version: 5.0.3
691
+ version: 5.0.4
650
692
  type: :runtime
651
693
  prerelease: false
652
694
  version_requirements: !ruby/object:Gem::Requirement
653
695
  requirements:
654
696
  - - '='
655
697
  - !ruby/object:Gem::Version
656
- version: 5.0.3
698
+ version: 5.0.4
657
699
  - !ruby/object:Gem::Dependency
658
700
  name: puma
659
701
  requirement: !ruby/object:Gem::Requirement
@@ -949,6 +991,7 @@ files:
949
991
  - lib/mihari/mixins/falsepositive.rb
950
992
  - lib/mihari/mixins/refang.rb
951
993
  - lib/mihari/mixins/retriable.rb
994
+ - lib/mihari/mixins/unwrap_error.rb
952
995
  - lib/mihari/models/alert.rb
953
996
  - lib/mihari/models/artifact.rb
954
997
  - lib/mihari/models/autonomous_system.rb
@@ -974,7 +1017,6 @@ files:
974
1017
  - lib/mihari/services/alert_builder.rb
975
1018
  - lib/mihari/services/alert_runner.rb
976
1019
  - lib/mihari/services/rule_builder.rb
977
- - lib/mihari/services/rule_runner.rb
978
1020
  - lib/mihari/structs/binaryedge.rb
979
1021
  - lib/mihari/structs/censys.rb
980
1022
  - lib/mihari/structs/config.rb
@@ -1001,8 +1043,8 @@ files:
1001
1043
  - lib/mihari/web/endpoints/tags.rb
1002
1044
  - lib/mihari/web/middleware/connection_adapter.rb
1003
1045
  - lib/mihari/web/middleware/error_notification_adapter.rb
1004
- - lib/mihari/web/public/assets/index-56fc2187.css
1005
- - lib/mihari/web/public/assets/index-ec641cb0.js
1046
+ - lib/mihari/web/public/assets/index-216d49d1.js
1047
+ - lib/mihari/web/public/assets/index-4c8509ee.css
1006
1048
  - lib/mihari/web/public/assets/mode-yaml-24faa242.js
1007
1049
  - lib/mihari/web/public/favicon.ico
1008
1050
  - lib/mihari/web/public/index.html
@@ -1024,14 +1066,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
1024
1066
  requirements:
1025
1067
  - - ">="
1026
1068
  - !ruby/object:Gem::Version
1027
- version: '2.7'
1069
+ version: '3.1'
1028
1070
  required_rubygems_version: !ruby/object:Gem::Requirement
1029
1071
  requirements:
1030
1072
  - - ">="
1031
1073
  - !ruby/object:Gem::Version
1032
1074
  version: '0'
1033
1075
  requirements: []
1034
- rubygems_version: 3.4.21
1076
+ rubygems_version: 3.4.10
1035
1077
  signing_key:
1036
1078
  specification_version: 4
1037
1079
  summary: A query aggregator for OSINT based threat hunting
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module Services
5
- #
6
- # Rule runner
7
- #
8
- class RuleRunner < Service
9
- #
10
- # @params [Mihari::Rule]
11
- #
12
- # @return [Mihari::Models::Alert, nil]
13
- #
14
- def call(rule)
15
- rule.call
16
- end
17
- end
18
- end
19
- end