mihari 5.7.0 → 5.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/lib/mihari/actor.rb +10 -4
  4. data/lib/mihari/cli/main.rb +2 -0
  5. data/lib/mihari/clients/base.rb +23 -1
  6. data/lib/mihari/clients/binaryedge.rb +1 -3
  7. data/lib/mihari/clients/censys.rb +1 -2
  8. data/lib/mihari/clients/crtsh.rb +2 -3
  9. data/lib/mihari/clients/dnstwister.rb +1 -2
  10. data/lib/mihari/clients/fofa.rb +1 -3
  11. data/lib/mihari/clients/greynoise.rb +1 -2
  12. data/lib/mihari/clients/hunterhow.rb +1 -2
  13. data/lib/mihari/clients/misp.rb +1 -2
  14. data/lib/mihari/clients/onyphe.rb +1 -2
  15. data/lib/mihari/clients/otx.rb +2 -14
  16. data/lib/mihari/clients/passivetotal.rb +3 -16
  17. data/lib/mihari/clients/publsedive.rb +2 -17
  18. data/lib/mihari/clients/securitytrails.rb +3 -25
  19. data/lib/mihari/clients/shodan.rb +1 -2
  20. data/lib/mihari/clients/the_hive.rb +1 -2
  21. data/lib/mihari/clients/urlscan.rb +1 -2
  22. data/lib/mihari/clients/virustotal.rb +3 -17
  23. data/lib/mihari/clients/zoomeye.rb +9 -19
  24. data/lib/mihari/commands/alert.rb +11 -9
  25. data/lib/mihari/commands/database.rb +4 -1
  26. data/lib/mihari/commands/mixins.rb +11 -0
  27. data/lib/mihari/commands/search.rb +13 -32
  28. data/lib/mihari/constants.rb +1 -1
  29. data/lib/mihari/database.rb +1 -1
  30. data/lib/mihari/enrichers/ipinfo.rb +1 -1
  31. data/lib/mihari/entities/tag.rb +1 -0
  32. data/lib/mihari/http.rb +13 -11
  33. data/lib/mihari/rule.rb +14 -0
  34. data/lib/mihari/service.rb +12 -2
  35. data/lib/mihari/services/alert_builder.rb +81 -8
  36. data/lib/mihari/services/alert_runner.rb +3 -10
  37. data/lib/mihari/services/rule_builder.rb +8 -10
  38. data/lib/mihari/services/rule_runner.rb +2 -25
  39. data/lib/mihari/structs/binaryedge.rb +9 -0
  40. data/lib/mihari/structs/censys.rb +0 -14
  41. data/lib/mihari/structs/fofa.rb +3 -0
  42. data/lib/mihari/structs/google_public_dns.rb +0 -4
  43. data/lib/mihari/structs/greynoise.rb +0 -6
  44. data/lib/mihari/structs/hunterhow.rb +0 -6
  45. data/lib/mihari/structs/ipinfo.rb +0 -2
  46. data/lib/mihari/structs/onyphe.rb +0 -4
  47. data/lib/mihari/structs/shodan.rb +0 -2
  48. data/lib/mihari/structs/urlscan.rb +0 -6
  49. data/lib/mihari/structs/virustotal_intelligence.rb +0 -8
  50. data/lib/mihari/version.rb +1 -1
  51. data/lib/mihari/web/app.rb +20 -17
  52. data/lib/mihari/web/endpoints/alerts.rb +75 -38
  53. data/lib/mihari/web/endpoints/artifacts.rb +60 -53
  54. data/lib/mihari/web/endpoints/ip_addresses.rb +19 -4
  55. data/lib/mihari/web/endpoints/rules.rb +132 -88
  56. data/lib/mihari/web/endpoints/tags.rb +15 -13
  57. data/lib/mihari/web/middleware/error_notification_adapter.rb +8 -3
  58. data/lib/mihari/web/public/assets/{index-821134e2.js → index-ec641cb0.js} +45 -44
  59. data/lib/mihari/web/public/index.html +1 -1
  60. data/lib/mihari/web/public/redoc-static.html +400 -400
  61. data/lib/mihari.rb +0 -2
  62. data/mihari.gemspec +5 -5
  63. data/mkdocs.yml +14 -7
  64. metadata +13 -140
  65. data/docs/alternatives.md +0 -5
  66. data/docs/analyzers/binaryedge.md +0 -26
  67. data/docs/analyzers/censys.md +0 -31
  68. data/docs/analyzers/circl.md +0 -37
  69. data/docs/analyzers/crtsh.md +0 -26
  70. data/docs/analyzers/dnstwister.md +0 -25
  71. data/docs/analyzers/feed.md +0 -73
  72. data/docs/analyzers/fofa.md +0 -31
  73. data/docs/analyzers/greynoise.md +0 -26
  74. data/docs/analyzers/hunterhow.md +0 -33
  75. data/docs/analyzers/index.md +0 -104
  76. data/docs/analyzers/onyphe.md +0 -26
  77. data/docs/analyzers/otx.md +0 -28
  78. data/docs/analyzers/passivetotal.md +0 -52
  79. data/docs/analyzers/pulsedive.md +0 -28
  80. data/docs/analyzers/securitytrails.md +0 -41
  81. data/docs/analyzers/shodan.md +0 -26
  82. data/docs/analyzers/urlscan.md +0 -28
  83. data/docs/analyzers/virustotal.md +0 -43
  84. data/docs/analyzers/virustotal_intelligence.md +0 -33
  85. data/docs/analyzers/zoomeye.md +0 -38
  86. data/docs/configuration.md +0 -35
  87. data/docs/emitters/database.md +0 -22
  88. data/docs/emitters/hive.md +0 -26
  89. data/docs/emitters/index.md +0 -36
  90. data/docs/emitters/misp.md +0 -21
  91. data/docs/emitters/slack.md +0 -21
  92. data/docs/emitters/webhook.md +0 -63
  93. data/docs/enrichers/google_public_dns.md +0 -19
  94. data/docs/enrichers/index.md +0 -35
  95. data/docs/enrichers/ipinfo.md +0 -26
  96. data/docs/enrichers/shodan.md +0 -22
  97. data/docs/enrichers/whois.md +0 -17
  98. data/docs/github_actions.md +0 -43
  99. data/docs/index.md +0 -11
  100. data/docs/installation.md +0 -31
  101. data/docs/requirements.md +0 -13
  102. data/docs/rule.md +0 -168
  103. data/docs/tags.md +0 -3
  104. data/docs/usage.md +0 -103
  105. data/frontend/.eslintrc.cjs +0 -22
  106. data/frontend/.gitignore +0 -31
  107. data/frontend/.prettierrc.json +0 -8
  108. data/frontend/README.md +0 -3
  109. data/frontend/env.d.ts +0 -5
  110. data/frontend/index.html +0 -21
  111. data/frontend/package-lock.json +0 -7219
  112. data/frontend/package.json +0 -67
  113. data/frontend/public/favicon.ico +0 -0
  114. data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
  115. data/frontend/src/App.vue +0 -27
  116. data/frontend/src/ace-config.ts +0 -6
  117. data/frontend/src/api-helper.ts +0 -111
  118. data/frontend/src/api.ts +0 -105
  119. data/frontend/src/components/ErrorMessage.vue +0 -31
  120. data/frontend/src/components/Loading.vue +0 -15
  121. data/frontend/src/components/Navbar.vue +0 -42
  122. data/frontend/src/components/Pagination.vue +0 -119
  123. data/frontend/src/components/alert/Alert.vue +0 -87
  124. data/frontend/src/components/alert/Alerts.vue +0 -63
  125. data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
  126. data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
  127. data/frontend/src/components/alert/Form.vue +0 -169
  128. data/frontend/src/components/artifact/AS.vue +0 -23
  129. data/frontend/src/components/artifact/Artifact.vue +0 -287
  130. data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
  131. data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
  132. data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
  133. data/frontend/src/components/artifact/CPEs.vue +0 -23
  134. data/frontend/src/components/artifact/DnsRecords.vue +0 -32
  135. data/frontend/src/components/artifact/Ports.vue +0 -23
  136. data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -23
  137. data/frontend/src/components/artifact/Tags.vue +0 -29
  138. data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
  139. data/frontend/src/components/config/Configs.vue +0 -65
  140. data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
  141. data/frontend/src/components/link/Link.vue +0 -32
  142. data/frontend/src/components/link/Links.vue +0 -42
  143. data/frontend/src/components/rule/EditRule.vue +0 -72
  144. data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
  145. data/frontend/src/components/rule/Form.vue +0 -158
  146. data/frontend/src/components/rule/InputForm.vue +0 -45
  147. data/frontend/src/components/rule/NewRule.vue +0 -57
  148. data/frontend/src/components/rule/Rule.vue +0 -100
  149. data/frontend/src/components/rule/RuleWrapper.vue +0 -53
  150. data/frontend/src/components/rule/Rules.vue +0 -84
  151. data/frontend/src/components/rule/RulesWrapper.vue +0 -121
  152. data/frontend/src/components/rule/YAML.vue +0 -37
  153. data/frontend/src/components/tag/Tag.vue +0 -65
  154. data/frontend/src/components/tag/Tags.vue +0 -37
  155. data/frontend/src/countries.ts +0 -350
  156. data/frontend/src/index.ts +0 -20
  157. data/frontend/src/links/anyrun.ts +0 -19
  158. data/frontend/src/links/base.ts +0 -14
  159. data/frontend/src/links/censys.ts +0 -20
  160. data/frontend/src/links/crtsh.ts +0 -20
  161. data/frontend/src/links/dnslytics.ts +0 -38
  162. data/frontend/src/links/greynoise.ts +0 -20
  163. data/frontend/src/links/index.ts +0 -40
  164. data/frontend/src/links/intezer.ts +0 -20
  165. data/frontend/src/links/otx.ts +0 -33
  166. data/frontend/src/links/securitytrails.ts +0 -38
  167. data/frontend/src/links/shodan.ts +0 -20
  168. data/frontend/src/links/urlscan.ts +0 -50
  169. data/frontend/src/links/virustotal.ts +0 -72
  170. data/frontend/src/main.ts +0 -41
  171. data/frontend/src/router/index.ts +0 -57
  172. data/frontend/src/rule.ts +0 -14
  173. data/frontend/src/shims-vue.d.ts +0 -6
  174. data/frontend/src/swagger.yaml +0 -771
  175. data/frontend/src/types.ts +0 -188
  176. data/frontend/src/utils.ts +0 -54
  177. data/frontend/src/views/Alerts.vue +0 -20
  178. data/frontend/src/views/Artifact.vue +0 -39
  179. data/frontend/src/views/Configs.vue +0 -20
  180. data/frontend/src/views/EditRule.vue +0 -39
  181. data/frontend/src/views/NewRule.vue +0 -26
  182. data/frontend/src/views/Rule.vue +0 -39
  183. data/frontend/src/views/Rules.vue +0 -20
  184. data/frontend/tests/utils.spec.ts +0 -9
  185. data/frontend/tsconfig.app.json +0 -21
  186. data/frontend/tsconfig.json +0 -14
  187. data/frontend/tsconfig.node.json +0 -13
  188. data/frontend/tsconfig.vitest.json +0 -12
  189. data/frontend/vite.config.ts +0 -24
  190. data/frontend/vitest.config.ts +0 -21
  191. data/lib/mihari/mixins/error_notification.rb +0 -21
  192. data/lib/mihari/services/alert_proxy.rb +0 -97
@@ -28,7 +28,7 @@ module Mihari
28
28
  #
29
29
  # @param [String] ip
30
30
  #
31
- # @return [Mihari::Structs::IPInfo::Response, nil]
31
+ # @return [Mihari::Structs::IPInfo::Response]
32
32
  #
33
33
  def call(ip)
34
34
  url = "https://ipinfo.io/#{ip}/json"
@@ -3,6 +3,7 @@
3
3
  module Mihari
4
4
  module Entities
5
5
  class Tag < Grape::Entity
6
+ expose :id, documentation: { type: Integer, required: true }
6
7
  expose :name, documentation: { type: String, required: true }
7
8
  end
8
9
 
data/lib/mihari/http.rb CHANGED
@@ -9,14 +9,13 @@ module Mihari
9
9
  #
10
10
  class BetterError < ::HTTP::Feature
11
11
  def wrap_response(response)
12
- unless response.status.success?
13
- raise StatusCodeError.new(
14
- "Unsuccessful response code returned: #{response.code}",
15
- response.code,
16
- response.body.to_s
17
- )
18
- end
19
- response
12
+ return response if response.status.success?
13
+
14
+ raise StatusCodeError.new(
15
+ "Unsuccessful response code returned: #{response.code}",
16
+ response.code,
17
+ response.body.to_s
18
+ )
20
19
  end
21
20
 
22
21
  def on_error(_request, error)
@@ -35,12 +34,15 @@ module Mihari
35
34
  #
36
35
  # @param [Integer, nil] timeout
37
36
  # @param [Hash] headers
37
+ # @param [Boolean] raise_exception
38
38
  #
39
39
  # @return [::HTTP::Client]
40
40
  #
41
- def build(headers: {}, timeout: nil)
42
- client = ::HTTP.use(:better_error).headers(headers)
43
- client.timeout(timeout) unless timeout.nil?
41
+ # @param [Object] raise_exception
42
+ def build(headers: {}, timeout: nil, raise_exception: true)
43
+ client = raise_exception ? ::HTTP.use(:better_error) : ::HTTP
44
+ client = client.headers(headers)
45
+ client = client.timeout(timeout) unless timeout.nil?
44
46
  client
45
47
  end
46
48
  end
data/lib/mihari/rule.rb CHANGED
@@ -218,6 +218,20 @@ module Mihari
218
218
  )
219
219
  end
220
220
 
221
+ #
222
+ # @return [Boolean]
223
+ #
224
+ def diff?
225
+ model = Mihari::Models::Rule.find(id)
226
+ model.data != data.deep_stringify_keys
227
+ rescue ActiveRecord::RecordNotFound
228
+ false
229
+ end
230
+
231
+ def update_or_create
232
+ model.save
233
+ end
234
+
221
235
  class << self
222
236
  #
223
237
  # Load rule from YAML string
@@ -9,8 +9,18 @@ module Mihari
9
9
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
10
10
  end
11
11
 
12
- def result
13
- Try[StandardError] { call }.to_result
12
+ def result(...)
13
+ Try[StandardError] { call(...) }.to_result
14
+ end
15
+
16
+ class << self
17
+ def call(...)
18
+ new.call(...)
19
+ end
20
+
21
+ def result(...)
22
+ new.result(...)
23
+ end
14
24
  end
15
25
  end
16
26
  end
@@ -9,23 +9,90 @@ require "yaml"
9
9
  module Mihari
10
10
  module Services
11
11
  #
12
- # Alert builder
12
+ # Alert proxy
13
13
  #
14
- class AlertBuilder < Service
15
- # @return [String]
16
- attr_reader :path
14
+ class AlertProxy
15
+ # @return [Hash]
16
+ attr_reader :data
17
+
18
+ # @return [Array, nil]
19
+ attr_reader :errors
17
20
 
18
21
  #
19
22
  # Initialize
20
23
  #
21
- # @param [String] path
24
+ # @param [Hash] data
22
25
  #
23
- def initialize(path)
26
+ def initialize(**data)
24
27
  super()
25
28
 
26
- @path = path
29
+ @data = data.deep_symbolize_keys
30
+ @errors = nil
31
+
32
+ validate!
33
+ end
34
+
35
+ #
36
+ # @return [Boolean]
37
+ #
38
+ def errors?
39
+ return false if @errors.nil?
40
+
41
+ !@errors.empty?
42
+ end
43
+
44
+ def validate!
45
+ contract = Schemas::AlertContract.new
46
+ result = contract.call(data)
47
+
48
+ @data = result.to_h
49
+ @errors = result.errors
50
+
51
+ raise ValidationError.new("Validation failed", errors) if errors?
52
+ end
53
+
54
+ def [](key)
55
+ data key.to_sym
56
+ end
57
+
58
+ #
59
+ # @return [String]
60
+ #
61
+ def rule_id
62
+ @rule_id ||= data[:rule_id]
63
+ end
64
+
65
+ #
66
+ # @return [Array<Mihari::Models::Artifact>]
67
+ #
68
+ def artifacts
69
+ @artifacts ||= data[:artifacts].map do |data|
70
+ artifact = Models::Artifact.new(data: data)
71
+ artifact.rule_id = rule_id
72
+ artifact
73
+ end.uniq(&:data).select(&:valid?)
74
+ end
75
+
76
+ #
77
+ # @return [Mihari::Rule]
78
+ #
79
+ def rule
80
+ @rule ||= [].tap do |out|
81
+ data = Mihari::Models::Rule.find(rule_id).data
82
+ out << Rule.new(**data)
83
+ end.first
27
84
  end
85
+ end
86
+
87
+ #
88
+ # Alert builder
89
+ #
90
+ class AlertBuilder < Service
91
+ # @return [String]
92
+ attr_reader :path
28
93
 
94
+ #
95
+ # @param [String] path
29
96
  #
30
97
  # @return [Hash]
31
98
  #
@@ -38,7 +105,13 @@ module Mihari
38
105
  )
39
106
  end
40
107
 
41
- def call
108
+ #
109
+ # @param [String] path
110
+ #
111
+ # @return [Mihari::AlertProxy]
112
+ #
113
+ def call(path)
114
+ @path = path
42
115
  AlertProxy.new(**data)
43
116
  end
44
117
  end
@@ -6,19 +6,12 @@ module Mihari
6
6
  # Alert runner
7
7
  #
8
8
  class AlertRunner < Service
9
- # @return [Mihari::Services::AlertProxy]
10
- attr_reader :alert
11
-
12
- def initialize(alert)
13
- super()
14
-
15
- @alert = alert
16
- end
17
-
9
+ #
10
+ # @param [Mihari::Services::AlertProxy] alert
18
11
  #
19
12
  # @return [Mihari::Models::Alert]
20
13
  #
21
- def call
14
+ def call(alert)
22
15
  emitter = Emitters::Database.new(rule: alert.rule)
23
16
  emitter.call alert.artifacts
24
17
  end
@@ -14,17 +14,8 @@ module Mihari
14
14
  # @return [String]
15
15
  attr_reader :path_or_id
16
16
 
17
- #
18
- # Initialize
19
17
  #
20
18
  # @param [String] path_or_id
21
- #
22
- def initialize(path_or_id)
23
- super()
24
-
25
- @path_or_id = path_or_id
26
- end
27
-
28
19
  #
29
20
  # @return [Hash]
30
21
  #
@@ -42,7 +33,14 @@ module Mihari
42
33
  )
43
34
  end
44
35
 
45
- def call
36
+ #
37
+ # @param [String] path_or_id
38
+ #
39
+ # @return [Mihari::Rule]
40
+ #
41
+ def call(path_or_id)
42
+ @path_or_id = path_or_id
43
+
46
44
  Rule.new(**data)
47
45
  end
48
46
  end
@@ -6,35 +6,12 @@ module Mihari
6
6
  # Rule runner
7
7
  #
8
8
  class RuleRunner < Service
9
- include Dry::Monads[:result, :try]
10
-
11
- # @return [Mihari::Rule]
12
- attr_reader :rule
13
-
14
- def initialize(rule)
15
- super()
16
-
17
- @rule = rule
18
- end
19
-
20
9
  #
21
- # @return [Boolean]
22
- #
23
- def diff?
24
- model = Mihari::Models::Rule.find(rule.id)
25
- model.data != rule.data.deep_stringify_keys
26
- rescue ActiveRecord::RecordNotFound
27
- false
28
- end
29
-
30
- def update_or_create
31
- rule.model.save
32
- end
33
-
10
+ # @params [Mihari::Rule]
34
11
  #
35
12
  # @return [Mihari::Models::Alert, nil]
36
13
  #
37
- def call
14
+ def call(rule)
38
15
  rule.call
39
16
  end
40
17
  end
@@ -9,6 +9,9 @@ module Mihari
9
9
  attribute :ip, Types::String
10
10
 
11
11
  class << self
12
+ #
13
+ # @param [Hash] d
14
+ #
12
15
  def from_dynamic!(d)
13
16
  d = Types::Hash[d]
14
17
  new(
@@ -24,6 +27,9 @@ module Mihari
24
27
  attribute :target, Target
25
28
 
26
29
  class << self
30
+ #
31
+ # @param [Hash] d
32
+ #
27
33
  def from_dynamic!(d)
28
34
  d = Types::Hash[d]
29
35
  new(
@@ -58,6 +64,9 @@ module Mihari
58
64
  end
59
65
 
60
66
  class << self
67
+ #
68
+ # @param [Hash] d
69
+ #
61
70
  def from_dynamic!(d)
62
71
  d = Types::Hash[d]
63
72
  new(
@@ -21,8 +21,6 @@ module Mihari
21
21
  #
22
22
  # @param [Hash] d
23
23
  #
24
- # @return [AutonomousSystem]
25
- #
26
24
  def from_dynamic!(d)
27
25
  d = Types::Hash[d]
28
26
  new(
@@ -59,8 +57,6 @@ module Mihari
59
57
  #
60
58
  # @param [Hash] d
61
59
  #
62
- # @return [Location]
63
- #
64
60
  def from_dynamic!(d)
65
61
  d = Types::Hash[d]
66
62
  new(
@@ -87,8 +83,6 @@ module Mihari
87
83
  #
88
84
  # @param [Hash] d
89
85
  #
90
- # @return [Service]
91
- #
92
86
  def from_dynamic!(d)
93
87
  d = Types::Hash[d]
94
88
  new(
@@ -143,8 +137,6 @@ module Mihari
143
137
  #
144
138
  # @param [Hash] d
145
139
  #
146
- # @return [Hit]
147
- #
148
140
  def from_dynamic!(d)
149
141
  d = Types::Hash[d]
150
142
  new(
@@ -171,8 +163,6 @@ module Mihari
171
163
  #
172
164
  # @param [Hash] d
173
165
  #
174
- # @return [Links]
175
- #
176
166
  def from_dynamic!(d)
177
167
  d = Types::Hash[d]
178
168
  new(
@@ -211,8 +201,6 @@ module Mihari
211
201
  #
212
202
  # @param [Hash] d
213
203
  #
214
- # @return [Result]
215
- #
216
204
  def from_dynamic!(d)
217
205
  d = Types::Hash[d]
218
206
  new(
@@ -242,8 +230,6 @@ module Mihari
242
230
  #
243
231
  # @param [Hash] d
244
232
  #
245
- # @return [Response]
246
- #
247
233
  def from_dynamic!(d)
248
234
  d = Types::Hash[d]
249
235
  new(
@@ -27,6 +27,9 @@ module Mihari
27
27
  attribute? :results, Types.Array(Types.Array(Types::String)).optional
28
28
 
29
29
  class << self
30
+ #
31
+ # @param [Hash] d
32
+ #
30
33
  def from_dynamic!(d)
31
34
  new(
32
35
  error: d.fetch("error"),
@@ -28,8 +28,6 @@ module Mihari
28
28
  #
29
29
  # @param [Hash] d
30
30
  #
31
- # @return [Answer]
32
- #
33
31
  def from_dynamic!(d)
34
32
  d = Types::Hash[d]
35
33
  resource_type = INT_TYPE_TO_TYPE[d.fetch("type")]
@@ -51,8 +49,6 @@ module Mihari
51
49
  #
52
50
  # @param [Hash] d
53
51
  #
54
- # @return [Response]
55
- #
56
52
  def from_dynamic!(d)
57
53
  d = Types::Hash[d]
58
54
  new(
@@ -39,8 +39,6 @@ module Mihari
39
39
  #
40
40
  # @param [Hash] d
41
41
  #
42
- # @return [Metadata]
43
- #
44
42
  def from_dynamic!(d)
45
43
  d = Types::Hash[d]
46
44
  new(
@@ -81,8 +79,6 @@ module Mihari
81
79
  #
82
80
  # @param [Hash] d
83
81
  #
84
- # @return [Datum]
85
- #
86
82
  def from_dynamic!(d)
87
83
  d = Types::Hash[d]
88
84
  new(
@@ -130,8 +126,6 @@ module Mihari
130
126
  #
131
127
  # @param [Hash] d
132
128
  #
133
- # @return [Response]
134
- #
135
129
  def from_dynamic!(d)
136
130
  d = Types::Hash[d]
137
131
  new(
@@ -27,8 +27,6 @@ module Mihari
27
27
  #
28
28
  # @param [Hash] d
29
29
  #
30
- # @return [ListItem]
31
- #
32
30
  def from_dynamic!(d)
33
31
  d = Types::Hash[d]
34
32
  new(
@@ -60,8 +58,6 @@ module Mihari
60
58
  #
61
59
  # @param [Hash] d
62
60
  #
63
- # @return [DataClass]
64
- #
65
61
  def from_dynamic!(d)
66
62
  d = Types::Hash[d]
67
63
  new(
@@ -89,8 +85,6 @@ module Mihari
89
85
  #
90
86
  # @param [Hash] d
91
87
  #
92
- # @return [Response]
93
- #
94
88
  def from_dynamic!(d)
95
89
  d = Types::Hash[d]
96
90
  new(
@@ -30,8 +30,6 @@ module Mihari
30
30
  #
31
31
  # @param [Hash] d
32
32
  #
33
- # @return [Response]
34
- #
35
33
  def from_dynamic!(d)
36
34
  d = d.deep_stringify_keys
37
35
  d = Types::Hash[d]
@@ -58,8 +58,6 @@ module Mihari
58
58
  #
59
59
  # @param [Hash] d
60
60
  #
61
- # @return [Result]
62
- #
63
61
  def from_dynamic!(d)
64
62
  d = Types::Hash[d]
65
63
  new(
@@ -113,8 +111,6 @@ module Mihari
113
111
  #
114
112
  # @param [Hash] d
115
113
  #
116
- # @return [Response]
117
- #
118
114
  def from_dynamic!(d)
119
115
  d = Types::Hash[d]
120
116
  new(
@@ -221,8 +221,6 @@ module Mihari
221
221
  #
222
222
  # @param [Hash] d
223
223
  #
224
- # @return [InternetDBResponse]
225
- #
226
224
  def from_dynamic!(d)
227
225
  d = Types::Hash[d]
228
226
  new(
@@ -20,8 +20,6 @@ module Mihari
20
20
  #
21
21
  # @param [Hash] d
22
22
  #
23
- # @return [Page]
24
- #
25
23
  def from_dynamic!(d)
26
24
  d = Types::Hash[d]
27
25
  new(
@@ -62,8 +60,6 @@ module Mihari
62
60
  #
63
61
  # @param [Hash] d
64
62
  #
65
- # @return [Result]
66
- #
67
63
  def from_dynamic!(d)
68
64
  d = Types::Hash[d]
69
65
  new(
@@ -96,8 +92,6 @@ module Mihari
96
92
  #
97
93
  # @param [Hash] d
98
94
  #
99
- # @return [Response]
100
- #
101
95
  def from_dynamic!(d)
102
96
  d = Types::Hash[d]
103
97
  new(
@@ -12,8 +12,6 @@ module Mihari
12
12
  #
13
13
  # @param [Hash] d
14
14
  #
15
- # @return [ContextAttributes]
16
- #
17
15
  def from_dynamic!(d)
18
16
  d = Types::Hash[d]
19
17
  new(url: d["url"])
@@ -65,8 +63,6 @@ module Mihari
65
63
  #
66
64
  # @param [Hash] d
67
65
  #
68
- # @return [Datum]
69
- #
70
66
  def from_dynamic!(d)
71
67
  d = Types::Hash[d]
72
68
 
@@ -94,8 +90,6 @@ module Mihari
94
90
  #
95
91
  # @param [Hash] d
96
92
  #
97
- # @return [Meta]
98
- #
99
93
  def from_dynamic!(d)
100
94
  d = Types::Hash[d]
101
95
  new(
@@ -125,8 +119,6 @@ module Mihari
125
119
  #
126
120
  # @param [Hash] d
127
121
  #
128
- # @return [Response]
129
- #
130
122
  def from_dynamic!(d)
131
123
  d = Types::Hash[d]
132
124
  new(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "5.7.0"
4
+ VERSION = "5.7.2"
5
5
  end
@@ -22,6 +22,12 @@ module Mihari
22
22
  # Rack + Grape based web app
23
23
  #
24
24
  class App
25
+ # @return [Array<String>]
26
+ attr_reader :filenames
27
+
28
+ # @return [Rack::Static]
29
+ attr_reader :rack_static
30
+
25
31
  def initialize
26
32
  @filenames = ["", ".html", "index.html", "/index.html"]
27
33
  @rack_static = Rack::Static.new(
@@ -31,6 +37,20 @@ module Mihari
31
37
  )
32
38
  end
33
39
 
40
+ def call(env)
41
+ status, headers, body = API.call(env)
42
+ return [status, headers, body] unless headers["X-Cascade"] == "pass"
43
+
44
+ # Check if the App wants us to pass the response along to others
45
+ request_path = env["PATH_INFO"]
46
+ filenames.each do |path|
47
+ static_status, static_headers, static_body = rack_static.call(env.merge("PATH_INFO" => request_path + path))
48
+ return [static_status, static_headers, static_body] if static_status != 404
49
+ end
50
+
51
+ [status, headers, body]
52
+ end
53
+
34
54
  class << self
35
55
  def instance
36
56
  @instance ||= Rack::Builder.new do
@@ -71,23 +91,6 @@ module Mihari
71
91
  end
72
92
  end
73
93
  end
74
-
75
- def call(env)
76
- # api
77
- api_response = API.call(env)
78
-
79
- # Check if the App wants us to pass the response along to others
80
- if api_response[1]["X-Cascade"] == "pass"
81
- # static files
82
- request_path = env["PATH_INFO"]
83
- @filenames.each do |path|
84
- response = @rack_static.call(env.merge("PATH_INFO" => request_path + path))
85
- return response if response[0] != 404
86
- end
87
- end
88
-
89
- api_response
90
- end
91
94
  end
92
95
  end
93
96
  end