mihari 5.6.2 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/README.md +1 -0
  4. data/config.ru +1 -1
  5. data/lib/mihari/actor.rb +18 -2
  6. data/lib/mihari/analyzers/base.rb +13 -12
  7. data/lib/mihari/analyzers/binaryedge.rb +4 -1
  8. data/lib/mihari/analyzers/censys.rb +4 -2
  9. data/lib/mihari/analyzers/circl.rb +4 -1
  10. data/lib/mihari/analyzers/crtsh.rb +4 -1
  11. data/lib/mihari/analyzers/dnstwister.rb +4 -1
  12. data/lib/mihari/analyzers/feed.rb +3 -0
  13. data/lib/mihari/analyzers/fofa.rb +65 -0
  14. data/lib/mihari/analyzers/greynoise.rb +4 -1
  15. data/lib/mihari/analyzers/hunterhow.rb +6 -1
  16. data/lib/mihari/analyzers/onyphe.rb +4 -1
  17. data/lib/mihari/analyzers/otx.rb +4 -1
  18. data/lib/mihari/analyzers/passivetotal.rb +4 -1
  19. data/lib/mihari/analyzers/pulsedive.rb +3 -0
  20. data/lib/mihari/analyzers/securitytrails.rb +4 -1
  21. data/lib/mihari/analyzers/shodan.rb +4 -1
  22. data/lib/mihari/analyzers/urlscan.rb +4 -1
  23. data/lib/mihari/analyzers/virustotal.rb +4 -1
  24. data/lib/mihari/analyzers/virustotal_intelligence.rb +4 -1
  25. data/lib/mihari/analyzers/zoomeye.rb +5 -2
  26. data/lib/mihari/cli/alert.rb +3 -0
  27. data/lib/mihari/cli/base.rb +3 -0
  28. data/lib/mihari/cli/database.rb +3 -0
  29. data/lib/mihari/cli/main.rb +3 -0
  30. data/lib/mihari/cli/rule.rb +3 -0
  31. data/lib/mihari/clients/base.rb +3 -0
  32. data/lib/mihari/clients/binaryedge.rb +5 -2
  33. data/lib/mihari/clients/censys.rb +7 -4
  34. data/lib/mihari/clients/circl.rb +3 -0
  35. data/lib/mihari/clients/crtsh.rb +3 -0
  36. data/lib/mihari/clients/dnstwister.rb +3 -0
  37. data/lib/mihari/clients/fofa.rb +83 -0
  38. data/lib/mihari/clients/greynoise.rb +5 -2
  39. data/lib/mihari/clients/hunterhow.rb +5 -2
  40. data/lib/mihari/clients/misp.rb +3 -0
  41. data/lib/mihari/clients/onyphe.rb +5 -2
  42. data/lib/mihari/clients/otx.rb +3 -0
  43. data/lib/mihari/clients/passivetotal.rb +3 -0
  44. data/lib/mihari/clients/publsedive.rb +4 -1
  45. data/lib/mihari/clients/securitytrails.rb +3 -0
  46. data/lib/mihari/clients/shodan.rb +5 -2
  47. data/lib/mihari/clients/the_hive.rb +3 -0
  48. data/lib/mihari/clients/urlscan.rb +7 -4
  49. data/lib/mihari/clients/virustotal.rb +5 -2
  50. data/lib/mihari/clients/zoomeye.rb +3 -0
  51. data/lib/mihari/commands/alert.rb +9 -16
  52. data/lib/mihari/commands/database.rb +3 -0
  53. data/lib/mihari/commands/rule.rb +10 -1
  54. data/lib/mihari/commands/search.rb +13 -29
  55. data/lib/mihari/commands/version.rb +3 -0
  56. data/lib/mihari/commands/web.rb +4 -1
  57. data/lib/mihari/config.rb +139 -150
  58. data/lib/mihari/constants.rb +1 -1
  59. data/lib/mihari/database.rb +6 -0
  60. data/lib/mihari/emitters/base.rb +13 -11
  61. data/lib/mihari/emitters/database.rb +4 -1
  62. data/lib/mihari/emitters/misp.rb +7 -4
  63. data/lib/mihari/emitters/slack.rb +3 -3
  64. data/lib/mihari/emitters/the_hive.rb +3 -3
  65. data/lib/mihari/emitters/webhook.rb +4 -3
  66. data/lib/mihari/enrichers/base.rb +15 -9
  67. data/lib/mihari/enrichers/google_public_dns.rb +6 -5
  68. data/lib/mihari/enrichers/ipinfo.rb +11 -9
  69. data/lib/mihari/enrichers/shodan.rb +4 -6
  70. data/lib/mihari/enrichers/whois.rb +12 -9
  71. data/lib/mihari/entities/tag.rb +1 -0
  72. data/lib/mihari/errors.rb +6 -0
  73. data/lib/mihari/feed/parser.rb +3 -0
  74. data/lib/mihari/feed/reader.rb +3 -0
  75. data/lib/mihari/http.rb +6 -0
  76. data/lib/mihari/mixins/autonomous_system.rb +3 -0
  77. data/lib/mihari/mixins/configurable.rb +3 -0
  78. data/lib/mihari/mixins/error_notification.rb +3 -0
  79. data/lib/mihari/mixins/falsepositive.rb +3 -0
  80. data/lib/mihari/mixins/refang.rb +3 -0
  81. data/lib/mihari/mixins/retriable.rb +6 -2
  82. data/lib/mihari/models/alert.rb +7 -4
  83. data/lib/mihari/models/artifact.rb +6 -0
  84. data/lib/mihari/models/autonomous_system.rb +4 -1
  85. data/lib/mihari/models/cpe.rb +4 -1
  86. data/lib/mihari/models/dns.rb +4 -1
  87. data/lib/mihari/models/geolocation.rb +4 -1
  88. data/lib/mihari/models/port.rb +4 -1
  89. data/lib/mihari/models/reverse_dns.rb +4 -1
  90. data/lib/mihari/models/rule.rb +6 -3
  91. data/lib/mihari/models/tag.rb +3 -0
  92. data/lib/mihari/models/tagging.rb +3 -0
  93. data/lib/mihari/models/whois.rb +4 -3
  94. data/lib/mihari/rule.rb +31 -12
  95. data/lib/mihari/schemas/alert.rb +3 -0
  96. data/lib/mihari/schemas/analyzer.rb +11 -0
  97. data/lib/mihari/schemas/emitter.rb +3 -0
  98. data/lib/mihari/schemas/enricher.rb +3 -0
  99. data/lib/mihari/schemas/macros.rb +4 -0
  100. data/lib/mihari/schemas/mixins.rb +5 -0
  101. data/lib/mihari/schemas/rule.rb +3 -0
  102. data/lib/mihari/service.rb +26 -0
  103. data/lib/mihari/services/alert_builder.rb +85 -9
  104. data/lib/mihari/services/alert_runner.rb +8 -19
  105. data/lib/mihari/services/rule_builder.rb +13 -12
  106. data/lib/mihari/services/rule_runner.rb +7 -32
  107. data/lib/mihari/structs/binaryedge.rb +22 -28
  108. data/lib/mihari/structs/censys.rb +48 -141
  109. data/lib/mihari/structs/config.rb +19 -30
  110. data/lib/mihari/structs/filters.rb +38 -0
  111. data/lib/mihari/structs/fofa.rb +47 -0
  112. data/lib/mihari/structs/google_public_dns.rb +10 -32
  113. data/lib/mihari/structs/greynoise.rb +33 -90
  114. data/lib/mihari/structs/hunterhow.rb +24 -28
  115. data/lib/mihari/structs/ipinfo.rb +14 -37
  116. data/lib/mihari/structs/onyphe.rb +31 -80
  117. data/lib/mihari/structs/shodan.rb +47 -114
  118. data/lib/mihari/structs/urlscan.rb +24 -69
  119. data/lib/mihari/structs/virustotal_intelligence.rb +20 -64
  120. data/lib/mihari/type_checker.rb +4 -0
  121. data/lib/mihari/types.rb +3 -0
  122. data/lib/mihari/version.rb +1 -1
  123. data/lib/mihari/web/api.rb +15 -10
  124. data/lib/mihari/web/app.rb +64 -56
  125. data/lib/mihari/web/endpoints/alerts.rb +127 -85
  126. data/lib/mihari/web/endpoints/artifacts.rb +91 -79
  127. data/lib/mihari/web/endpoints/configs.rb +18 -13
  128. data/lib/mihari/web/endpoints/ip_addresses.rb +35 -15
  129. data/lib/mihari/web/endpoints/rules.rb +236 -187
  130. data/lib/mihari/web/endpoints/tags.rb +42 -35
  131. data/lib/mihari/web/middleware/connection_adapter.rb +16 -9
  132. data/lib/mihari/web/middleware/error_notification_adapter.rb +17 -10
  133. data/lib/mihari/web/public/assets/{index-28d4c79d.js → index-07fafab5.js} +31 -30
  134. data/lib/mihari/web/public/assets/mode-yaml-24faa242.js +8 -0
  135. data/lib/mihari/web/public/index.html +1 -1
  136. data/lib/mihari.rb +24 -6
  137. data/mihari.gemspec +9 -2
  138. data/mkdocs.yml +4 -2
  139. metadata +38 -133
  140. data/docs/alternatives.md +0 -5
  141. data/docs/analyzers/binaryedge.md +0 -26
  142. data/docs/analyzers/censys.md +0 -31
  143. data/docs/analyzers/circl.md +0 -37
  144. data/docs/analyzers/crtsh.md +0 -26
  145. data/docs/analyzers/dnstwister.md +0 -25
  146. data/docs/analyzers/feed.md +0 -73
  147. data/docs/analyzers/greynoise.md +0 -26
  148. data/docs/analyzers/hunterhow.md +0 -33
  149. data/docs/analyzers/index.md +0 -103
  150. data/docs/analyzers/onyphe.md +0 -26
  151. data/docs/analyzers/otx.md +0 -28
  152. data/docs/analyzers/passivetotal.md +0 -52
  153. data/docs/analyzers/pulsedive.md +0 -28
  154. data/docs/analyzers/securitytrails.md +0 -41
  155. data/docs/analyzers/shodan.md +0 -26
  156. data/docs/analyzers/urlscan.md +0 -28
  157. data/docs/analyzers/virustotal.md +0 -43
  158. data/docs/analyzers/virustotal_intelligence.md +0 -33
  159. data/docs/analyzers/zoomeye.md +0 -38
  160. data/docs/configuration.md +0 -35
  161. data/docs/emitters/database.md +0 -22
  162. data/docs/emitters/hive.md +0 -26
  163. data/docs/emitters/index.md +0 -36
  164. data/docs/emitters/misp.md +0 -21
  165. data/docs/emitters/slack.md +0 -21
  166. data/docs/emitters/webhook.md +0 -63
  167. data/docs/enrichers/google_public_dns.md +0 -19
  168. data/docs/enrichers/index.md +0 -35
  169. data/docs/enrichers/ipinfo.md +0 -26
  170. data/docs/enrichers/shodan.md +0 -22
  171. data/docs/enrichers/whois.md +0 -17
  172. data/docs/github_actions.md +0 -43
  173. data/docs/index.md +0 -11
  174. data/docs/installation.md +0 -31
  175. data/docs/requirements.md +0 -13
  176. data/docs/rule.md +0 -168
  177. data/docs/tags.md +0 -3
  178. data/docs/usage.md +0 -103
  179. data/frontend/.eslintrc.cjs +0 -22
  180. data/frontend/.gitignore +0 -31
  181. data/frontend/.prettierrc.json +0 -8
  182. data/frontend/README.md +0 -3
  183. data/frontend/env.d.ts +0 -5
  184. data/frontend/index.html +0 -21
  185. data/frontend/package-lock.json +0 -7219
  186. data/frontend/package.json +0 -67
  187. data/frontend/public/favicon.ico +0 -0
  188. data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
  189. data/frontend/src/App.vue +0 -27
  190. data/frontend/src/ace-config.ts +0 -6
  191. data/frontend/src/api-helper.ts +0 -111
  192. data/frontend/src/api.ts +0 -105
  193. data/frontend/src/components/ErrorMessage.vue +0 -31
  194. data/frontend/src/components/Loading.vue +0 -15
  195. data/frontend/src/components/Navbar.vue +0 -42
  196. data/frontend/src/components/Pagination.vue +0 -119
  197. data/frontend/src/components/alert/Alert.vue +0 -87
  198. data/frontend/src/components/alert/Alerts.vue +0 -63
  199. data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
  200. data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
  201. data/frontend/src/components/alert/Form.vue +0 -182
  202. data/frontend/src/components/artifact/AS.vue +0 -29
  203. data/frontend/src/components/artifact/Artifact.vue +0 -287
  204. data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
  205. data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
  206. data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
  207. data/frontend/src/components/artifact/CPEs.vue +0 -23
  208. data/frontend/src/components/artifact/DnsRecords.vue +0 -38
  209. data/frontend/src/components/artifact/Ports.vue +0 -23
  210. data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -31
  211. data/frontend/src/components/artifact/Tags.vue +0 -29
  212. data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
  213. data/frontend/src/components/config/Configs.vue +0 -65
  214. data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
  215. data/frontend/src/components/link/Link.vue +0 -32
  216. data/frontend/src/components/link/Links.vue +0 -42
  217. data/frontend/src/components/rule/EditRule.vue +0 -72
  218. data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
  219. data/frontend/src/components/rule/Form.vue +0 -158
  220. data/frontend/src/components/rule/InputForm.vue +0 -45
  221. data/frontend/src/components/rule/NewRule.vue +0 -57
  222. data/frontend/src/components/rule/Rule.vue +0 -100
  223. data/frontend/src/components/rule/RuleWrapper.vue +0 -53
  224. data/frontend/src/components/rule/Rules.vue +0 -84
  225. data/frontend/src/components/rule/RulesWrapper.vue +0 -121
  226. data/frontend/src/components/rule/YAML.vue +0 -37
  227. data/frontend/src/components/tag/Tag.vue +0 -65
  228. data/frontend/src/components/tag/Tags.vue +0 -37
  229. data/frontend/src/countries.ts +0 -350
  230. data/frontend/src/index.ts +0 -20
  231. data/frontend/src/links/anyrun.ts +0 -19
  232. data/frontend/src/links/base.ts +0 -14
  233. data/frontend/src/links/censys.ts +0 -20
  234. data/frontend/src/links/crtsh.ts +0 -20
  235. data/frontend/src/links/dnslytics.ts +0 -38
  236. data/frontend/src/links/greynoise.ts +0 -20
  237. data/frontend/src/links/index.ts +0 -40
  238. data/frontend/src/links/intezer.ts +0 -20
  239. data/frontend/src/links/otx.ts +0 -33
  240. data/frontend/src/links/securitytrails.ts +0 -38
  241. data/frontend/src/links/shodan.ts +0 -20
  242. data/frontend/src/links/urlscan.ts +0 -50
  243. data/frontend/src/links/virustotal.ts +0 -72
  244. data/frontend/src/main.ts +0 -41
  245. data/frontend/src/router/index.ts +0 -57
  246. data/frontend/src/rule.ts +0 -14
  247. data/frontend/src/shims-vue.d.ts +0 -6
  248. data/frontend/src/swagger.yaml +0 -771
  249. data/frontend/src/types.ts +0 -188
  250. data/frontend/src/utils.ts +0 -54
  251. data/frontend/src/views/Alerts.vue +0 -20
  252. data/frontend/src/views/Artifact.vue +0 -39
  253. data/frontend/src/views/Configs.vue +0 -20
  254. data/frontend/src/views/EditRule.vue +0 -39
  255. data/frontend/src/views/NewRule.vue +0 -26
  256. data/frontend/src/views/Rule.vue +0 -39
  257. data/frontend/src/views/Rules.vue +0 -20
  258. data/frontend/tests/utils.spec.ts +0 -9
  259. data/frontend/tsconfig.app.json +0 -21
  260. data/frontend/tsconfig.json +0 -14
  261. data/frontend/tsconfig.node.json +0 -13
  262. data/frontend/tsconfig.vitest.json +0 -12
  263. data/frontend/vite.config.ts +0 -24
  264. data/frontend/vitest.config.ts +0 -21
  265. data/lib/mihari/services/alert_proxy.rb +0 -92
  266. data/lib/mihari/templates/rule.yml.erb +0 -5
  267. data/lib/mihari/web/public/assets/mode-yaml-a21faa53.js +0 -8
@@ -3,38 +3,21 @@
3
3
  module Mihari
4
4
  module Structs
5
5
  class Config < Dry::Struct
6
+ # @!attribute [r] name
7
+ # @return [String]
6
8
  attribute :name, Types::String
7
- attribute :type, Types::String
8
- attribute :is_configured, Types::Bool
9
- attribute :values, Types.Array(Types::Hash).optional
10
9
 
11
- #
12
- # @return [String]
13
- #
14
- def name
15
- attributes[:name]
16
- end
17
-
18
- #
19
- # @return [String]
20
- #
21
- def type
22
- attributes[:type]
23
- end
10
+ # @!attribute [r] type
11
+ # @return [String]
12
+ attribute :type, Types::String
24
13
 
25
- #
26
- # @return [Boolean]
27
- #
28
- def is_configured
29
- attributes[:is_configured]
30
- end
14
+ # @!attribute [r] is_configured
15
+ # @return [Boolean]
16
+ attribute :is_configured, Types::Bool
31
17
 
32
- #
33
- # @return [Array<Hash>]
34
- #
35
- def values
36
- attributes[:values]
37
- end
18
+ # @!attribute [r] values
19
+ # @return [Array<Hash>, nil]
20
+ attribute :values, Types.Array(Types::Hash).optional
38
21
 
39
22
  class << self
40
23
  #
@@ -61,8 +44,14 @@ module Mihari
61
44
  #
62
45
  def get_dummy(klass)
63
46
  type = get_type(klass)
64
- is_analyzer = type == "Analyzer"
65
- is_analyzer ? klass.new("dummy") : klass.new(artifacts: [], rule: nil)
47
+ case type
48
+ when "Analyzer"
49
+ klass.new("dummy")
50
+ when "Emitter"
51
+ klass.new(rule: nil)
52
+ else
53
+ klass.new
54
+ end
66
55
  end
67
56
 
68
57
  #
@@ -5,15 +5,34 @@ module Mihari
5
5
  module Filters
6
6
  module Alert
7
7
  class SearchFilter < Dry::Struct
8
+ # @!attribute [r] artifact_data
9
+ # @return [String, nil]
8
10
  attribute? :artifact_data, Types::String.optional
11
+
12
+ # @!attribute [r] rule_id
13
+ # @return [String, nil]
9
14
  attribute? :rule_id, Types::String.optional
15
+
16
+ # @!attribute [r] tag_name
17
+ # @return [String, nil]
10
18
  attribute? :tag_name, Types::String.optional
19
+
20
+ # @!attribute [r] from_at
21
+ # @return [DateTime, nil]
11
22
  attribute? :from_at, Types::DateTime.optional
23
+
24
+ # @!attribute [r] to_at
25
+ # @return [DateTime, nil]
12
26
  attribute? :to_at, Types::DateTime.optional
13
27
  end
14
28
 
15
29
  class SearchFilterWithPagination < SearchFilter
30
+ # @!attribute [r] page
31
+ # @return [Integer, nil]
16
32
  attribute? :page, Types::Int.default(1)
33
+
34
+ # @!attribute [r] limit
35
+ # @return [Integer, nil]
17
36
  attribute? :limit, Types::Int.default(10)
18
37
 
19
38
  def without_pagination
@@ -30,15 +49,34 @@ module Mihari
30
49
 
31
50
  module Rule
32
51
  class SearchFilter < Dry::Struct
52
+ # @!attribute [r] description
53
+ # @return [String, nil]
33
54
  attribute? :description, Types::String.optional
55
+
56
+ # @!attribute [r] tag_name
57
+ # @return [String, nil]
34
58
  attribute? :tag_name, Types::String.optional
59
+
60
+ # @!attribute [r] title
61
+ # @return [String, nil]
35
62
  attribute? :title, Types::String.optional
63
+
64
+ # @!attribute [r] from_at
65
+ # @return [DateTime, nil]
36
66
  attribute? :from_at, Types::DateTime.optional
67
+
68
+ # @!attribute [r] to_at
69
+ # @return [DateTime, nil]
37
70
  attribute? :to_at, Types::DateTime.optional
38
71
  end
39
72
 
40
73
  class SearchFilterWithPagination < SearchFilter
74
+ # @!attribute [r] page
75
+ # @return [Integer, nil]
41
76
  attribute? :page, Types::Int.default(1)
77
+
78
+ # @!attribute [r] limit
79
+ # @return [Integer, nil]
42
80
  attribute? :limit, Types::Int.default(10)
43
81
 
44
82
  def without_pagination
@@ -0,0 +1,47 @@
1
+ module Mihari
2
+ module Structs
3
+ module Fofa
4
+ class Response < Dry::Struct
5
+ # @!attribute [r] error
6
+ # @return [Boolean]
7
+ attribute :error, Types::Bool
8
+
9
+ # @!attribute [r] size
10
+ # @return [Integer, nil]
11
+ attribute? :size, Types::Int.optional
12
+
13
+ # @!attribute [r] page
14
+ # @return [Integer, nil]
15
+ attribute? :page, Types::Int.optional
16
+
17
+ # @!attribute [r] mode
18
+ # @return [String, nil]
19
+ attribute? :mode, Types::String.optional
20
+
21
+ # @!attribute [r] query
22
+ # @return [String, nil]
23
+ attribute? :query, Types::String.optional
24
+
25
+ # @!attribute [r] results
26
+ # @return [Array<String>, nil]
27
+ attribute? :results, Types.Array(Types.Array(Types::String)).optional
28
+
29
+ class << self
30
+ #
31
+ # @param [Hash] d
32
+ #
33
+ def from_dynamic!(d)
34
+ new(
35
+ error: d.fetch("error"),
36
+ size: d["size"],
37
+ page: d["page"],
38
+ mode: d["mode"],
39
+ query: d["query"],
40
+ results: d["results"]
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -12,37 +12,22 @@ module Mihari
12
12
  }.freeze
13
13
 
14
14
  class Answer < Dry::Struct
15
+ # @!attribute [r] name
16
+ # @return [String]
15
17
  attribute :name, Types::String
16
- attribute :data, Types::String
17
- attribute :resource_type, Types::String
18
-
19
- #
20
- # @return [String]
21
- #
22
- def name
23
- attributes[:name]
24
- end
25
18
 
26
- #
27
- # @return [String]
28
- #
29
- def data
30
- attributes[:data]
31
- end
19
+ # @!attribute [r] data
20
+ # @return [String]
21
+ attribute :data, Types::String
32
22
 
33
- #
34
- # @return [String]
35
- #
36
- def resource_type
37
- attributes[:resource_type]
38
- end
23
+ # @!attribute [r] resource_type
24
+ # @return [String]
25
+ attribute :resource_type, Types::String
39
26
 
40
27
  class << self
41
28
  #
42
29
  # @param [Hash] d
43
30
  #
44
- # @return [Answer]
45
- #
46
31
  def from_dynamic!(d)
47
32
  d = Types::Hash[d]
48
33
  resource_type = INT_TYPE_TO_TYPE[d.fetch("type")]
@@ -56,21 +41,14 @@ module Mihari
56
41
  end
57
42
 
58
43
  class Response < Dry::Struct
44
+ # @!attribute [r] answers
45
+ # @return [Array<Answer>]
59
46
  attribute :answers, Types.Array(Answer)
60
47
 
61
- #
62
- # @return [Array<Answer>]
63
- #
64
- def answers
65
- attributes[:answers]
66
- end
67
-
68
48
  class << self
69
49
  #
70
50
  # @param [Hash] d
71
51
  #
72
- # @return [Response]
73
- #
74
52
  def from_dynamic!(d)
75
53
  d = Types::Hash[d]
76
54
  new(
@@ -6,30 +6,17 @@ module Mihari
6
6
  class Metadata < Dry::Struct
7
7
  include Mixins::AutonomousSystem
8
8
 
9
+ # @!attribute [r] country
10
+ # @return [String]
9
11
  attribute :country, Types::String
10
- attribute :country_code, Types::String
11
- attribute :asn, Types::String
12
-
13
- #
14
- # @return [String]
15
- #
16
- def country
17
- attributes[:country]
18
- end
19
12
 
20
- #
21
- # @return [String]
22
- #
23
- def country_code
24
- attributes[:country_code]
25
- end
13
+ # @!attribute [r] country_code
14
+ # @return [String]
15
+ attribute :country_code, Types::String
26
16
 
27
- #
28
- # @return [String]
29
- #
30
- def asn
31
- attributes[:asn]
32
- end
17
+ # @!attribute [r] asn
18
+ # @return [String]
19
+ attribute :asn, Types::String
33
20
 
34
21
  #
35
22
  # @return [Mihari::AutonomousSystem]
@@ -52,8 +39,6 @@ module Mihari
52
39
  #
53
40
  # @param [Hash] d
54
41
  #
55
- # @return [Metadata]
56
- #
57
42
  def from_dynamic!(d)
58
43
  d = Types::Hash[d]
59
44
  new(
@@ -66,30 +51,17 @@ module Mihari
66
51
  end
67
52
 
68
53
  class Datum < Dry::Struct
54
+ # @!attribute [r] ip
55
+ # @return [String]
69
56
  attribute :ip, Types::String
70
- attribute :metadata, Metadata
71
- attribute :metadata_, Types::Hash
72
-
73
- #
74
- # @return [String]
75
- #
76
- def ip
77
- attributes[:ip]
78
- end
79
57
 
80
- #
81
- # @return [Metadata]
82
- #
83
- def metadata
84
- attributes[:metadata]
85
- end
58
+ # @!attribute [r] metadata
59
+ # @return [Metadata]
60
+ attribute :metadata, Metadata
86
61
 
87
- #
88
- # @return [Hash]
89
- #
90
- def metadata_
91
- attributes[:metadata_]
92
- end
62
+ # @!attribute [r] metadata_
63
+ # @return [Hash]
64
+ attribute :metadata_, Types::Hash
93
65
 
94
66
  #
95
67
  # @return [Mihari::Models::Artifact]
@@ -107,8 +79,6 @@ module Mihari
107
79
  #
108
80
  # @param [Hash] d
109
81
  #
110
- # @return [Datum]
111
- #
112
82
  def from_dynamic!(d)
113
83
  d = Types::Hash[d]
114
84
  new(
@@ -121,54 +91,29 @@ module Mihari
121
91
  end
122
92
 
123
93
  class Response < Dry::Struct
94
+ # @!attribute [r] complete
95
+ # @return [Boolean]
124
96
  attribute :complete, Types::Bool
125
- attribute :count, Types::Int
126
- attribute :data, Types.Array(Datum)
127
- attribute :message, Types::String
128
- attribute :query, Types::String
129
- attribute :scroll, Types::String.optional
130
97
 
131
- #
132
- # @return [Boolean]
133
- #
134
- def complete
135
- attributes[:complete]
136
- end
137
-
138
- #
139
- # @return [Integer]
140
- #
141
- def count
142
- attributes[:count]
143
- end
98
+ # @!attribute [r] count
99
+ # @return [Integer]
100
+ attribute :count, Types::Int
144
101
 
145
- #
146
- # @return [Array<Datum>]
147
- #
148
- def data
149
- attributes[:data]
150
- end
102
+ # @!attribute [r] data
103
+ # @return [Array<Datnum>]
104
+ attribute :data, Types.Array(Datum)
151
105
 
152
- #
153
- # @return [String]
154
- #
155
- def message
156
- attributes[:message]
157
- end
106
+ # @!attribute [r] message
107
+ # @return [String]
108
+ attribute :message, Types::String
158
109
 
159
- #
160
- # @return [String]
161
- #
162
- def query
163
- attributes[:query]
164
- end
110
+ # @!attribute [r] query
111
+ # @return [String]
112
+ attribute :query, Types::String
165
113
 
166
- #
167
- # @return [String, nil]
168
- #
169
- def scroll
170
- attributes[:scroll]
171
- end
114
+ # @!attribute [r] scroll
115
+ # @return [String, nil]
116
+ attribute :scroll, Types::String.optional
172
117
 
173
118
  #
174
119
  # @return [Array<Mihari::Models::Artifact>]
@@ -181,8 +126,6 @@ module Mihari
181
126
  #
182
127
  # @param [Hash] d
183
128
  #
184
- # @return [Response]
185
- #
186
129
  def from_dynamic!(d)
187
130
  d = Types::Hash[d]
188
131
  new(
@@ -1,17 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mihari
2
4
  module Structs
3
5
  module HunterHow
4
6
  class ListItem < Dry::Struct
7
+ # @!attribute [r] domain
8
+ # @return [String]
5
9
  attribute :domain, Types::String
10
+
11
+ # @!attribute [r] ip
12
+ # @return [String]
6
13
  attribute :ip, Types::String
7
- attribute :port, Types::Integer
8
14
 
9
- #
10
- # @return [String]
11
- #
12
- def ip
13
- attributes[:ip]
14
- end
15
+ # @!attribute [r] port
16
+ # @return [Integer]
17
+ attribute :port, Types::Int
15
18
 
16
19
  #
17
20
  # @return [Mihari::Models::Artifact]
@@ -24,8 +27,6 @@ module Mihari
24
27
  #
25
28
  # @param [Hash] d
26
29
  #
27
- # @return [ListItem]
28
- #
29
30
  def from_dynamic!(d)
30
31
  d = Types::Hash[d]
31
32
  new(
@@ -38,15 +39,13 @@ module Mihari
38
39
  end
39
40
 
40
41
  class DataClass < Dry::Struct
42
+ # @!attribute [r] list
43
+ # @return [Array<ListItem>]
41
44
  attribute :list, Types.Array(ListItem)
42
- attribute :total, Types::Integer
43
45
 
44
- #
45
- # @return [Array<ListItem>]
46
- #
47
- def list
48
- attributes[:list]
49
- end
46
+ # @!attribute [r] total
47
+ # @return [Integer]
48
+ attribute :total, Types::Int
50
49
 
51
50
  #
52
51
  # @return [Array<Mihari::Models::Artifact>]
@@ -59,8 +58,6 @@ module Mihari
59
58
  #
60
59
  # @param [Hash] d
61
60
  #
62
- # @return [DataClass]
63
- #
64
61
  def from_dynamic!(d)
65
62
  d = Types::Hash[d]
66
63
  new(
@@ -72,23 +69,22 @@ module Mihari
72
69
  end
73
70
 
74
71
  class Response < Dry::Struct
75
- attribute :code, Types::Integer
72
+ # @!attribute [r] code
73
+ # @return [Integer]
74
+ attribute :code, Types::Int
75
+
76
+ # @!attribute [r] data
77
+ # @return [DataClass]
76
78
  attribute :data, DataClass
77
- attribute :message, Types::String
78
79
 
79
- #
80
- # @return [DataClass]
81
- #
82
- def data
83
- attributes[:data]
84
- end
80
+ # @!attribute [r] message
81
+ # @return [String]
82
+ attribute :message, Types::String
85
83
 
86
84
  class << self
87
85
  #
88
86
  # @param [Hash] d
89
87
  #
90
- # @return [Response]
91
- #
92
88
  def from_dynamic!(d)
93
89
  d = Types::Hash[d]
94
90
  new(
@@ -4,46 +4,25 @@ module Mihari
4
4
  module Structs
5
5
  module IPInfo
6
6
  class Response < Dry::Struct
7
+ # @!attribute [r] ip
8
+ # @return [String]
7
9
  attribute :ip, Types::String
8
- attribute :hostname, Types::String.optional
9
- attribute :loc, Types::String.optional
10
- attribute :country_code, Types::String.optional
11
- attribute :asn, Types::Integer.optional
12
10
 
13
- #
14
- # @return [String]
15
- #
16
- def ip
17
- attributes[:ip]
18
- end
19
-
20
- #
21
- # @return [String, nil]
22
- #
23
- def hostname
24
- attributes[:hostname]
25
- end
11
+ # @!attribute [r] hostname
12
+ # @return [String, nil]
13
+ attribute :hostname, Types::String.optional
26
14
 
27
- #
28
- # @return [String, nil]
29
- #
30
- def loc
31
- attributes[:loc]
32
- end
15
+ # @!attribute [r] loc
16
+ # @return [String, nil]
17
+ attribute :loc, Types::String.optional
33
18
 
34
- #
35
- # @return [String, nil]
36
- #
37
- def country_code
38
- attributes[:country_code]
39
- end
19
+ # @!attribute [r] country_code
20
+ # @return [String, nil]
21
+ attribute :country_code, Types::String.optional
40
22
 
41
- #
42
- # @return [Integer, nil]
43
- #
44
- def asn
45
- attributes[:asn]
46
- end
23
+ # @!attribute [r] asn
24
+ # @return [Integer, nil]
25
+ attribute :asn, Types::Int.optional
47
26
 
48
27
  class << self
49
28
  include Mixins::AutonomousSystem
@@ -51,8 +30,6 @@ module Mihari
51
30
  #
52
31
  # @param [Hash] d
53
32
  #
54
- # @return [Response]
55
- #
56
33
  def from_dynamic!(d)
57
34
  d = d.deep_stringify_keys
58
35
  d = Types::Hash[d]