mihari 4.12.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/Steepfile +0 -1
  3. data/lib/mihari/analyzers/base.rb +18 -37
  4. data/lib/mihari/analyzers/rule.rb +23 -36
  5. data/lib/mihari/cli/main.rb +6 -11
  6. data/lib/mihari/commands/initializer.rb +47 -0
  7. data/lib/mihari/commands/searcher.rb +57 -0
  8. data/lib/mihari/commands/validator.rb +2 -2
  9. data/lib/mihari/constants.rb +3 -3
  10. data/lib/mihari/database.rb +52 -87
  11. data/lib/mihari/emitters/database.rb +16 -7
  12. data/lib/mihari/emitters/misp.rb +13 -5
  13. data/lib/mihari/emitters/slack.rb +15 -8
  14. data/lib/mihari/emitters/the_hive.rb +42 -21
  15. data/lib/mihari/emitters/webhook.rb +99 -31
  16. data/lib/mihari/entities/alert.rb +7 -5
  17. data/lib/mihari/entities/artifact.rb +20 -8
  18. data/lib/mihari/entities/config.rb +2 -6
  19. data/lib/mihari/entities/rule.rb +8 -0
  20. data/lib/mihari/http.rb +13 -13
  21. data/lib/mihari/mixins/{disallowed_data_value.rb → falsepositive.rb} +8 -8
  22. data/lib/mihari/models/alert.rb +2 -15
  23. data/lib/mihari/models/artifact.rb +28 -17
  24. data/lib/mihari/models/rule.rb +7 -13
  25. data/lib/mihari/schemas/emitter.rb +6 -8
  26. data/lib/mihari/schemas/rule.rb +11 -13
  27. data/lib/mihari/structs/config.rb +41 -0
  28. data/lib/mihari/structs/filters.rb +2 -2
  29. data/lib/mihari/structs/rule.rb +94 -85
  30. data/lib/mihari/templates/rule.yml.erb +5 -23
  31. data/lib/mihari/types.rb +1 -1
  32. data/lib/mihari/version.rb +1 -1
  33. data/lib/mihari/web/api.rb +0 -2
  34. data/lib/mihari/web/endpoints/alerts.rb +11 -3
  35. data/lib/mihari/web/endpoints/configs.rb +1 -6
  36. data/lib/mihari/web/endpoints/rules.rb +27 -15
  37. data/lib/mihari/web/public/assets/{fa-brands-400-b1d1c1b0.ttf → fa-brands-400-2ef6fdde.ttf} +0 -0
  38. data/lib/mihari/web/public/assets/fa-brands-400-f4617423.woff2 +0 -0
  39. data/lib/mihari/web/public/assets/fa-regular-400-12dea17b.ttf +0 -0
  40. data/lib/mihari/web/public/assets/fa-regular-400-7ba24c41.woff2 +0 -0
  41. data/lib/mihari/web/public/assets/fa-solid-900-67a880b4.ttf +0 -0
  42. data/lib/mihari/web/public/assets/fa-solid-900-e2c5cf54.woff2 +0 -0
  43. data/lib/mihari/web/public/assets/fa-v4compatibility-7c377405.woff2 +0 -0
  44. data/lib/mihari/web/public/assets/fa-v4compatibility-8d9500e8.ttf +0 -0
  45. data/lib/mihari/web/public/assets/{index-07aa1ba2.css → index-625e95fe.css} +3 -3
  46. data/lib/mihari/web/public/assets/index-63900d73.js +50 -0
  47. data/lib/mihari/web/public/index.html +2 -2
  48. data/lib/mihari/web/public/redoc-static.html +26 -27
  49. data/lib/mihari.rb +11 -21
  50. data/mihari.gemspec +4 -4
  51. metadata +25 -111
  52. data/lib/mihari/cli/init.rb +0 -11
  53. data/lib/mihari/cli/validator.rb +0 -11
  54. data/lib/mihari/commands/init.rb +0 -51
  55. data/lib/mihari/commands/search.rb +0 -63
  56. data/lib/mihari/emitters/http.rb +0 -127
  57. data/lib/mihari/entities/source.rb +0 -9
  58. data/lib/mihari/status.rb +0 -55
  59. data/lib/mihari/web/endpoints/sources.rb +0 -19
  60. data/lib/mihari/web/public/assets/fa-brands-400-c61287c2.woff2 +0 -0
  61. data/lib/mihari/web/public/assets/fa-regular-400-5da313b0.woff2 +0 -0
  62. data/lib/mihari/web/public/assets/fa-regular-400-d7b19fe2.ttf +0 -0
  63. data/lib/mihari/web/public/assets/fa-solid-900-8f06540f.woff2 +0 -0
  64. data/lib/mihari/web/public/assets/fa-solid-900-e4f6a7e9.ttf +0 -0
  65. data/lib/mihari/web/public/assets/fa-v4compatibility-2ddb3b41.ttf +0 -0
  66. data/lib/mihari/web/public/assets/fa-v4compatibility-f46715c9.woff2 +0 -0
  67. data/lib/mihari/web/public/assets/index-a7fe697b.js +0 -63
  68. data/sig/lib/mihari/analyzers/base.rbs +0 -90
  69. data/sig/lib/mihari/analyzers/binaryedge.rbs +0 -26
  70. data/sig/lib/mihari/analyzers/censys.rbs +0 -41
  71. data/sig/lib/mihari/analyzers/circl.rbs +0 -31
  72. data/sig/lib/mihari/analyzers/crtsh.rbs +0 -17
  73. data/sig/lib/mihari/analyzers/dnpedia.rbs +0 -15
  74. data/sig/lib/mihari/analyzers/dnstwister.rbs +0 -25
  75. data/sig/lib/mihari/analyzers/feed.rbs +0 -20
  76. data/sig/lib/mihari/analyzers/onyphe.rbs +0 -34
  77. data/sig/lib/mihari/analyzers/otx.rbs +0 -33
  78. data/sig/lib/mihari/analyzers/passivetotal.rbs +0 -35
  79. data/sig/lib/mihari/analyzers/pulsedive.rbs +0 -27
  80. data/sig/lib/mihari/analyzers/rule.rbs +0 -68
  81. data/sig/lib/mihari/analyzers/securitytrails.rbs +0 -33
  82. data/sig/lib/mihari/analyzers/shodan.rbs +0 -36
  83. data/sig/lib/mihari/analyzers/urlscan.rbs +0 -31
  84. data/sig/lib/mihari/analyzers/virustotal.rbs +0 -31
  85. data/sig/lib/mihari/analyzers/virustotal_intelligence.rbs +0 -33
  86. data/sig/lib/mihari/analyzers/zoomeye.rbs +0 -35
  87. data/sig/lib/mihari/cli/base.rbs +0 -9
  88. data/sig/lib/mihari/cli/init.rbs +0 -7
  89. data/sig/lib/mihari/cli/main.rbs +0 -9
  90. data/sig/lib/mihari/cli/validator.rbs +0 -7
  91. data/sig/lib/mihari/commands/init.rbs +0 -9
  92. data/sig/lib/mihari/commands/json.rbs +0 -7
  93. data/sig/lib/mihari/commands/search.rbs +0 -35
  94. data/sig/lib/mihari/commands/validator.rbs +0 -9
  95. data/sig/lib/mihari/commands/web.rbs +0 -7
  96. data/sig/lib/mihari/constants.rbs +0 -5
  97. data/sig/lib/mihari/database.rbs +0 -25
  98. data/sig/lib/mihari/emitters/base.rbs +0 -18
  99. data/sig/lib/mihari/emitters/database.rbs +0 -9
  100. data/sig/lib/mihari/emitters/http.rbs +0 -35
  101. data/sig/lib/mihari/emitters/misp.rbs +0 -34
  102. data/sig/lib/mihari/emitters/slack.rbs +0 -73
  103. data/sig/lib/mihari/emitters/stdout.rbs +0 -9
  104. data/sig/lib/mihari/emitters/the_hive.rbs +0 -32
  105. data/sig/lib/mihari/emitters/webhook.rbs +0 -20
  106. data/sig/lib/mihari/enrichers/base.rbs +0 -12
  107. data/sig/lib/mihari/enrichers/google_public_dns.rbs +0 -18
  108. data/sig/lib/mihari/enrichers/ipinfo.rbs +0 -16
  109. data/sig/lib/mihari/errors.rbs +0 -10
  110. data/sig/lib/mihari/feed/parser.rbs +0 -11
  111. data/sig/lib/mihari/feed/reader.rbs +0 -56
  112. data/sig/lib/mihari/http.rbs +0 -64
  113. data/sig/lib/mihari/mixins/autonomous_system.rbs +0 -14
  114. data/sig/lib/mihari/mixins/configurable.rbs +0 -30
  115. data/sig/lib/mihari/mixins/configuration.rbs +0 -45
  116. data/sig/lib/mihari/mixins/disallowed_data_value.rbs +0 -23
  117. data/sig/lib/mihari/mixins/error_notification.rbs +0 -12
  118. data/sig/lib/mihari/mixins/hash.rbs +0 -14
  119. data/sig/lib/mihari/mixins/refang.rbs +0 -14
  120. data/sig/lib/mihari/mixins/retriable.rbs +0 -15
  121. data/sig/lib/mihari/models/alert.rbs +0 -18
  122. data/sig/lib/mihari/models/artifact.rbs +0 -69
  123. data/sig/lib/mihari/models/autonomous_system.rbs +0 -14
  124. data/sig/lib/mihari/models/cpe.rbs +0 -7
  125. data/sig/lib/mihari/models/dns.rbs +0 -19
  126. data/sig/lib/mihari/models/geolocation.rbs +0 -15
  127. data/sig/lib/mihari/models/port.rbs +0 -7
  128. data/sig/lib/mihari/models/reverse_dns.rbs +0 -14
  129. data/sig/lib/mihari/models/rule.rbs +0 -17
  130. data/sig/lib/mihari/models/tag.rbs +0 -5
  131. data/sig/lib/mihari/models/tagging.rbs +0 -4
  132. data/sig/lib/mihari/models/whois.rbs +0 -66
  133. data/sig/lib/mihari/status.rbs +0 -25
  134. data/sig/lib/mihari/structs/censys.rbs +0 -58
  135. data/sig/lib/mihari/structs/filters.rbs +0 -40
  136. data/sig/lib/mihari/structs/google_public_dns.rbs +0 -21
  137. data/sig/lib/mihari/structs/greynoise.rbs +0 -30
  138. data/sig/lib/mihari/structs/ipinfo.rbs +0 -17
  139. data/sig/lib/mihari/structs/onyphe.rbs +0 -25
  140. data/sig/lib/mihari/structs/rule.rbs +0 -57
  141. data/sig/lib/mihari/structs/shodan.rbs +0 -30
  142. data/sig/lib/mihari/structs/urlscan.rbs +0 -28
  143. data/sig/lib/mihari/structs/virustotal_intelligence.rbs +0 -33
  144. data/sig/lib/mihari/type_checker.rbs +0 -48
  145. data/sig/lib/mihari/types.rbs +0 -23
  146. data/sig/lib/mihari/version.rbs +0 -3
  147. data/sig/lib/mihari/web/app.rbs +0 -5
  148. data/sig/lib/mihari.rbs +0 -54
data/lib/mihari/status.rb DELETED
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- class Status
5
- def check
6
- statuses
7
- end
8
-
9
- def self.check
10
- new.check
11
- end
12
-
13
- private
14
-
15
- #
16
- # Statuses of analyzers and emitters
17
- #
18
- # @return [Array<Hash>]
19
- #
20
- def statuses
21
- (Mihari.analyzers + Mihari.emitters + Mihari.enrichers).to_h do |klass|
22
- name = klass.to_s.split("::").last.to_s
23
-
24
- [name, build_status(klass)]
25
- end.compact
26
- end
27
-
28
- #
29
- # Build a status of a class
30
- #
31
- # @param [Class<Mihari::Analyzers::Base>, Class<Mihari::Emitters::Base>] klass
32
- #
33
- # @return [Hash, nil]
34
- #
35
- def build_status(klass)
36
- return nil if klass == Mihari::Analyzers::Rule
37
-
38
- is_analyzer = klass.ancestors.include?(Mihari::Analyzers::Base)
39
- is_emitter = klass.ancestors.include?(Mihari::Emitters::Base)
40
- is_enricher = klass.ancestors.include?(Mihari::Enrichers::Base)
41
-
42
- instance = is_analyzer ? klass.new("dummy") : klass.new
43
- is_configured = instance.configured?
44
- values = instance.configuration_values
45
-
46
- type = "Analyzer"
47
- type = "Emitter" if is_emitter
48
- type = "Enricher" if is_enricher
49
-
50
- values ? { is_configured: is_configured, values: values, type: type } : nil
51
- rescue ArgumentError => _e
52
- nil
53
- end
54
- end
55
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module Endpoints
5
- class Sources < Grape::API
6
- namespace :sources do
7
- desc "Get sources", {
8
- is_array: true,
9
- success: Entities::Sources,
10
- summary: "Get sources"
11
- }
12
- get "/" do
13
- sources = Mihari::Alert.distinct.pluck(:source)
14
- present({ sources: sources }, with: Entities::Sources)
15
- end
16
- end
17
- end
18
- end
19
- end