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
@@ -6,38 +6,22 @@ module Mihari
6
6
  class Result < Dry::Struct
7
7
  include Mixins::AutonomousSystem
8
8
 
9
+ # @!attribute [r] asn
10
+ # @return [String]
9
11
  attribute :asn, Types::String
10
- attribute :country_code, Types::String.optional
11
- attribute :ip, Types::String
12
- attribute :metadata, Types::Hash
13
12
 
14
- #
15
- # @return [String]
16
- #
17
- def asn
18
- attributes[:asn]
19
- end
13
+ # @!attribute [r] country_code
14
+ # @return [String, nll]
15
+ attribute :country_code, Types::String.optional
20
16
 
21
- #
22
- # @return [String, nil]
23
- #
24
- def country_code
25
- attributes[:country_code]
26
- end
17
+ # @!attribute [r] ip
18
+ # @return [String]
27
19
 
28
- #
29
- # @return [String]
30
- #
31
- def ip
32
- attributes[:ip]
33
- end
20
+ attribute :ip, Types::String
34
21
 
35
- #
36
- # @return [Hash]
37
- #
38
- def metadata
39
- attributes[:metadata]
40
- end
22
+ # @!attribute [r] metadata
23
+ # @return [Hash]
24
+ attribute :metadata, Types::Hash
41
25
 
42
26
  #
43
27
  # @return [Mihari::Models::Artifact]
@@ -74,8 +58,6 @@ module Mihari
74
58
  #
75
59
  # @param [Hash] d
76
60
  #
77
- # @return [Result]
78
- #
79
61
  def from_dynamic!(d)
80
62
  d = Types::Hash[d]
81
63
  new(
@@ -90,62 +72,33 @@ module Mihari
90
72
  end
91
73
 
92
74
  class Response < Dry::Struct
75
+ # @!attribute [r] count
76
+ # @return [Integer]
93
77
  attribute :count, Types::Int
94
- attribute :error, Types::Int
95
- attribute :max_page, Types::Int
96
- attribute :page, Types::Int
97
- attribute :results, Types.Array(Result)
98
- attribute :status, Types::String
99
- attribute :total, Types::Int
100
-
101
- #
102
- # @return [Integer]
103
- #
104
- def count
105
- attributes[:count]
106
- end
107
78
 
108
- #
109
- # @return [Integer]
110
- #
111
- def error
112
- attributes[:error]
113
- end
79
+ # @!attribute [r] error
80
+ # @return [Integer]
81
+ attribute :error, Types::Int
114
82
 
115
- #
116
- # @return [Integer]
117
- #
118
- def max_page
119
- attributes[:max_page]
120
- end
83
+ # @!attribute [r] max_page
84
+ # @return [Integer]
85
+ attribute :max_page, Types::Int
121
86
 
122
- #
123
- # @return [Integer]
124
- #
125
- def page
126
- attributes[:page]
127
- end
87
+ # @!attribute [r] page
88
+ # @return [Integer]
89
+ attribute :page, Types::Int
128
90
 
129
- #
130
- # @return [Array<Result>]
131
- #
132
- def results
133
- attributes[:results]
134
- end
91
+ # @!attribute [r] results
92
+ # @return [Array<Result>]
93
+ attribute :results, Types.Array(Result)
135
94
 
136
- #
137
- # @return [String]
138
- #
139
- def status
140
- attributes[:status]
141
- end
95
+ # @!attribute [r] status
96
+ # @return [String]
97
+ attribute :status, Types::String
142
98
 
143
- #
144
- # @return [Integer]
145
- #
146
- def total
147
- attributes[:total]
148
- end
99
+ # @!attribute [r] total
100
+ # @return [Integer]
101
+ attribute :total, Types::Int
149
102
 
150
103
  #
151
104
  # @return [Array<Mihari::Models::Artifact>]
@@ -158,8 +111,6 @@ module Mihari
158
111
  #
159
112
  # @param [Hash] d
160
113
  #
161
- # @return [Response]
162
- #
163
114
  def from_dynamic!(d)
164
115
  d = Types::Hash[d]
165
116
  new(
@@ -4,22 +4,13 @@ module Mihari
4
4
  module Structs
5
5
  module Shodan
6
6
  class Location < Dry::Struct
7
+ # @!attribute [r] country_code
8
+ # @return [String, nil]
7
9
  attribute :country_code, Types::String.optional
8
- attribute :country_name, Types::String.optional
9
-
10
- #
11
- # @return [String, nil]
12
- #
13
- def country_code
14
- attributes[:country_code]
15
- end
16
10
 
17
- #
18
- # @return [String, nil]
19
- #
20
- def country_name
21
- attributes[:country_name]
22
- end
11
+ # @!attribute [r] country_name
12
+ # @return [String, nil]
13
+ attribute :country_name, Types::String.optional
23
14
 
24
15
  #
25
16
  # @return [Mihari::Geolocation, nil]
@@ -52,55 +43,33 @@ module Mihari
52
43
  class Match < Dry::Struct
53
44
  include Mixins::AutonomousSystem
54
45
 
46
+ # @!attribute [r] asn
47
+ # @return [String, nil]
55
48
  attribute :asn, Types::String.optional
56
- attribute :hostnames, Types.Array(Types::String)
57
- attribute :location, Location
58
- attribute :domains, Types.Array(Types::String)
59
- attribute :ip_str, Types::String
60
- attribute :port, Types::Integer
61
- attribute :metadata, Types::Hash
62
49
 
63
- #
64
- # @return [String, nil]
65
- #
66
- def asn
67
- attributes[:asn]
68
- end
50
+ # @!attribute [r] hostname
51
+ # @return [Array<String>]
52
+ attribute :hostnames, Types.Array(Types::String)
69
53
 
70
- #
71
- # @return [Array<String>]
72
- #
73
- def hostnames
74
- attributes[:hostnames]
75
- end
54
+ # @!attribute [r] location
55
+ # @return [Location]
56
+ attribute :location, Location
76
57
 
77
- #
78
- # @return [Location]
79
- #
80
- def location
81
- attributes[:location]
82
- end
58
+ # @!attribute [r] domains
59
+ # @return [Array<String>]
60
+ attribute :domains, Types.Array(Types::String)
83
61
 
84
- #
85
- # @return [String]
86
- #
87
- def ip_str
88
- attributes[:ip_str]
89
- end
62
+ # @!attribute [r] ip_str
63
+ # @return [String]
64
+ attribute :ip_str, Types::String
90
65
 
91
- #
92
- # @return [Integer]
93
- #
94
- def port
95
- attributes[:port]
96
- end
66
+ # @!attribute [r] port
67
+ # @return [Integer]
68
+ attribute :port, Types::Int
97
69
 
98
- #
99
- # @return [Hash]
100
- #
101
- def metadata
102
- attributes[:metadata]
103
- end
70
+ # @!attribute [r] metadata
71
+ # @return [Hash]
72
+ attribute :metadata, Types::Hash
104
73
 
105
74
  #
106
75
  # @return [Mihari::AutonomousSystem, nil]
@@ -141,22 +110,13 @@ module Mihari
141
110
  end
142
111
 
143
112
  class Response < Dry::Struct
113
+ # @!attribute [r] matches
114
+ # @return [Array<Match>]
144
115
  attribute :matches, Types.Array(Match)
145
- attribute :total, Types::Int
146
-
147
- #
148
- # @return [Array<Match>]
149
- #
150
- def matches
151
- attributes[:matches]
152
- end
153
116
 
154
- #
155
- # @return [Integer]
156
- #
157
- def total
158
- attributes[:total]
159
- end
117
+ # @!attribute [r] total
118
+ # @return [Integer]
119
+ attribute :total, Types::Int
160
120
 
161
121
  #
162
122
  # Collect metadata from matches
@@ -233,61 +193,34 @@ module Mihari
233
193
  end
234
194
 
235
195
  class InternetDBResponse < Dry::Struct
196
+ # @!attribute [r] ip
197
+ # @return [String]
236
198
  attribute :ip, Types::String
237
- attribute :ports, Types.Array(Types::Int)
238
- attribute :cpes, Types.Array(Types::String)
239
- attribute :hostnames, Types.Array(Types::String)
240
- attribute :tags, Types.Array(Types::String)
241
- attribute :vulns, Types.Array(Types::String)
242
199
 
243
- #
244
- # @return [String]
245
- #
246
- def ip
247
- attributes[:ip]
248
- end
249
-
250
- #
251
- # @return [Array<Integer>]
252
- #
253
- def ports
254
- attributes[:ports]
255
- end
200
+ # @!attribute [r] ports
201
+ # @return [Array<Integer>]
202
+ attribute :ports, Types.Array(Types::Int)
256
203
 
257
- #
258
- # @return [Array<String>]
259
- #
260
- def cpes
261
- attributes[:cpes]
262
- end
204
+ # @!attribute [r] cpes
205
+ # @return [Array<String>]
206
+ attribute :cpes, Types.Array(Types::String)
263
207
 
264
- #
265
- # @return [Array<String>]
266
- #
267
- def hostnames
268
- attributes[:hostnames]
269
- end
208
+ # @!attribute [r] hostnames
209
+ # @return [Array<String>]
210
+ attribute :hostnames, Types.Array(Types::String)
270
211
 
271
- #
272
- # @return [Array<String>]
273
- #
274
- def tags
275
- attributes[:tags]
276
- end
212
+ # @!attribute [r] tags
213
+ # @return [Array<String>]
214
+ attribute :tags, Types.Array(Types::String)
277
215
 
278
- #
279
- # @return [Array<String>]
280
- #
281
- def vulns
282
- attributes[:vulns]
283
- end
216
+ # @!attribute [r] vulns
217
+ # @return [Array<String>]
218
+ attribute :vulns, Types.Array(Types::String)
284
219
 
285
220
  class << self
286
221
  #
287
222
  # @param [Hash] d
288
223
  #
289
- # @return [InternetDBResponse]
290
- #
291
224
  def from_dynamic!(d)
292
225
  d = Types::Hash[d]
293
226
  new(
@@ -4,37 +4,22 @@ module Mihari
4
4
  module Structs
5
5
  module Urlscan
6
6
  class Page < Dry::Struct
7
+ # @!attribute [r] domain
8
+ # @return [String]
7
9
  attribute :domain, Types::String.optional
8
- attribute :ip, Types::String.optional
9
- attribute :url, Types::String
10
-
11
- #
12
- # @return [String, nil]
13
- #
14
- def domain
15
- attributes[:domain]
16
- end
17
10
 
18
- #
19
- # @return [String, nil]
20
- #
21
- def ip
22
- attributes[:ip]
23
- end
11
+ # @!attribute [r] ip
12
+ # @return [String, nil]
13
+ attribute :ip, Types::String.optional
24
14
 
25
- #
26
- # @return [String]
27
- #
28
- def url
29
- attributes[:url]
30
- end
15
+ # @!attribute [r] url
16
+ # @return [String]
17
+ attribute :url, Types::String
31
18
 
32
19
  class << self
33
20
  #
34
21
  # @param [Hash] d
35
22
  #
36
- # @return [Page]
37
- #
38
23
  def from_dynamic!(d)
39
24
  d = Types::Hash[d]
40
25
  new(
@@ -47,38 +32,21 @@ module Mihari
47
32
  end
48
33
 
49
34
  class Result < Dry::Struct
35
+ # @!attribute [r] page
36
+ # @return [Page]
50
37
  attribute :page, Page
51
- attribute :id, Types::String
52
- attribute :sort, Types.Array(Types::String | Types::Integer)
53
- attribute :metadata, Types::Hash
54
38
 
55
- #
56
- # @return [Page]
57
- #
58
- def page
59
- attributes[:page]
60
- end
61
-
62
- #
63
- # @return [String]
64
- #
65
- def id
66
- attributes[:id]
67
- end
39
+ # @!attribute [r] pid
40
+ # @return [String]
41
+ attribute :id, Types::String
68
42
 
69
- #
70
- # @return [Array<String, Integer>]
71
- #
72
- def sort
73
- attributes[:sort]
74
- end
43
+ # @!attribute [r] sort
44
+ # @return [Array<String, Integer>]
45
+ attribute :sort, Types.Array(Types::String | Types::Int)
75
46
 
76
- #
77
- # @return [Array<String, Integer>]
78
- #
79
- def metadata
80
- attributes[:metadata]
81
- end
47
+ # @!attribute [r] metadata
48
+ # @return [Hash]
49
+ attribute :metadata, Types::Hash
82
50
 
83
51
  #
84
52
  # @return [Array<Mihari::Models::Artifact>]
@@ -92,8 +60,6 @@ module Mihari
92
60
  #
93
61
  # @param [Hash] d
94
62
  #
95
- # @return [Result]
96
- #
97
63
  def from_dynamic!(d)
98
64
  d = Types::Hash[d]
99
65
  new(
@@ -107,22 +73,13 @@ module Mihari
107
73
  end
108
74
 
109
75
  class Response < Dry::Struct
76
+ # @!attribute [r] results
77
+ # @return [Array<Result>]
110
78
  attribute :results, Types.Array(Result)
111
- attribute :has_more, Types::Bool
112
-
113
- #
114
- # @return [Array<Result>]
115
- #
116
- def results
117
- attributes[:results]
118
- end
119
79
 
120
- #
121
- # @return [Boolean]
122
- #
123
- def has_more
124
- attributes[:has_more]
125
- end
80
+ # @!attribute [r] has_more
81
+ # @return [Boolean]
82
+ attribute :has_more, Types::Bool
126
83
 
127
84
  #
128
85
  # @return [Array<Mihari::Models::Artifact>]
@@ -135,8 +92,6 @@ module Mihari
135
92
  #
136
93
  # @param [Hash] d
137
94
  #
138
- # @return [Response]
139
- #
140
95
  def from_dynamic!(d)
141
96
  d = Types::Hash[d]
142
97
  new(
@@ -4,21 +4,14 @@ module Mihari
4
4
  module Structs
5
5
  module VirusTotalIntelligence
6
6
  class ContextAttributes < Dry::Struct
7
+ # @!attribute [r] url
8
+ # @return [String, nil]
7
9
  attribute :url, Types::String.optional
8
10
 
9
- #
10
- # @return [String, nil]
11
- #
12
- def url
13
- attributes[:url]
14
- end
15
-
16
11
  class << self
17
12
  #
18
13
  # @param [Hash] d
19
14
  #
20
- # @return [ContextAttributes]
21
- #
22
15
  def from_dynamic!(d)
23
16
  d = Types::Hash[d]
24
17
  new(url: d["url"])
@@ -27,38 +20,21 @@ module Mihari
27
20
  end
28
21
 
29
22
  class Datum < Dry::Struct
23
+ # @!attribute [r] type
24
+ # @return [String]
30
25
  attribute :type, Types::String
31
- attribute :id, Types::String
32
- attribute :context_attributes, ContextAttributes.optional
33
- attribute :metadata, Types::Hash
34
26
 
35
- #
36
- # @return [String]
37
- #
38
- def type
39
- attributes[:type]
40
- end
41
-
42
- #
43
- # @return [String]
44
- #
45
- def id
46
- attributes[:id]
47
- end
27
+ # @!attribute [r] id
28
+ # @return [String]
29
+ attribute :id, Types::String
48
30
 
49
- #
50
- # @return [ContextAttributes, nil]
51
- #
52
- def context_attributes
53
- attributes[:context_attributes]
54
- end
31
+ # @!attribute [r] context_attributes
32
+ # @return [ContextAttributes, nil]
33
+ attribute :context_attributes, ContextAttributes.optional
55
34
 
56
- #
57
- # @return [Hash, nil]
58
- #
59
- def metadata
60
- attributes[:metadata]
61
- end
35
+ # @!attribute [r] metadata
36
+ # @return [Hash]
37
+ attribute :metadata, Types::Hash
62
38
 
63
39
  #
64
40
  # @return [String, nil]
@@ -87,8 +63,6 @@ module Mihari
87
63
  #
88
64
  # @param [Hash] d
89
65
  #
90
- # @return [Datum]
91
- #
92
66
  def from_dynamic!(d)
93
67
  d = Types::Hash[d]
94
68
 
@@ -108,21 +82,14 @@ module Mihari
108
82
  end
109
83
 
110
84
  class Meta < Dry::Struct
85
+ # @!attribute [r] cursor
86
+ # @return [String, nil]
111
87
  attribute :cursor, Types::String.optional
112
88
 
113
- #
114
- # @return [String, nil]
115
- #
116
- def cursor
117
- attributes[:cursor]
118
- end
119
-
120
89
  class << self
121
90
  #
122
91
  # @param [Hash] d
123
92
  #
124
- # @return [Meta]
125
- #
126
93
  def from_dynamic!(d)
127
94
  d = Types::Hash[d]
128
95
  new(
@@ -133,22 +100,13 @@ module Mihari
133
100
  end
134
101
 
135
102
  class Response < Dry::Struct
103
+ # @!attribute [r] meta
104
+ # @return [Meta]
136
105
  attribute :meta, Meta
137
- attribute :data, Types.Array(Datum)
138
-
139
- #
140
- # @return [Meta]
141
- #
142
- def meta
143
- attributes[:meta]
144
- end
145
106
 
146
- #
147
- # @return [Array<Datum>]
148
- #
149
- def data
150
- attributes[:data]
151
- end
107
+ # @!attribute [r] data
108
+ # @return [Array<Datum>]
109
+ attribute :data, Types.Array(Datum)
152
110
 
153
111
  #
154
112
  # @return [Array<Mihari::Models::Artifact>]
@@ -161,8 +119,6 @@ module Mihari
161
119
  #
162
120
  # @param [Hash] d
163
121
  #
164
- # @return [Response]
165
- #
166
122
  def from_dynamic!(d)
167
123
  d = Types::Hash[d]
168
124
  new(
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
+ #
5
+ # Artifact type checker
6
+ #
4
7
  class TypeChecker
5
8
  # @return [String]
6
9
  attr_reader :data
@@ -54,6 +57,7 @@ module Mihari
54
57
  return "ip" if ip?
55
58
  return "domain" if domain?
56
59
  return "url" if url?
60
+
57
61
  "mail" if mail?
58
62
  end
59
63
 
data/lib/mihari/types.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
+ #
5
+ # dry-type based types
6
+ #
4
7
  module Types
5
8
  include Dry.Types()
6
9
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "5.6.2"
4
+ VERSION = "5.7.1"
5
5
  end