mihari 5.6.2 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) 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/docs/analyzers/fofa.md +31 -0
  6. data/docs/analyzers/index.md +1 -0
  7. data/frontend/package-lock.json +73 -73
  8. data/frontend/package.json +5 -5
  9. data/frontend/src/components/alert/Form.vue +1 -14
  10. data/frontend/src/components/artifact/AS.vue +2 -8
  11. data/frontend/src/components/artifact/DnsRecords.vue +2 -8
  12. data/frontend/src/components/artifact/ReverseDnsNames.vue +2 -10
  13. data/frontend/src/components/artifact/WhoisRecord.vue +1 -1
  14. data/lib/mihari/actor.rb +14 -4
  15. data/lib/mihari/analyzers/base.rb +13 -12
  16. data/lib/mihari/analyzers/binaryedge.rb +4 -1
  17. data/lib/mihari/analyzers/censys.rb +4 -2
  18. data/lib/mihari/analyzers/circl.rb +4 -1
  19. data/lib/mihari/analyzers/crtsh.rb +4 -1
  20. data/lib/mihari/analyzers/dnstwister.rb +4 -1
  21. data/lib/mihari/analyzers/feed.rb +3 -0
  22. data/lib/mihari/analyzers/fofa.rb +65 -0
  23. data/lib/mihari/analyzers/greynoise.rb +4 -1
  24. data/lib/mihari/analyzers/hunterhow.rb +6 -1
  25. data/lib/mihari/analyzers/onyphe.rb +4 -1
  26. data/lib/mihari/analyzers/otx.rb +4 -1
  27. data/lib/mihari/analyzers/passivetotal.rb +4 -1
  28. data/lib/mihari/analyzers/pulsedive.rb +3 -0
  29. data/lib/mihari/analyzers/securitytrails.rb +4 -1
  30. data/lib/mihari/analyzers/shodan.rb +4 -1
  31. data/lib/mihari/analyzers/urlscan.rb +4 -1
  32. data/lib/mihari/analyzers/virustotal.rb +4 -1
  33. data/lib/mihari/analyzers/virustotal_intelligence.rb +4 -1
  34. data/lib/mihari/analyzers/zoomeye.rb +5 -2
  35. data/lib/mihari/cli/alert.rb +3 -0
  36. data/lib/mihari/cli/base.rb +3 -0
  37. data/lib/mihari/cli/database.rb +3 -0
  38. data/lib/mihari/cli/main.rb +3 -0
  39. data/lib/mihari/cli/rule.rb +3 -0
  40. data/lib/mihari/clients/base.rb +3 -0
  41. data/lib/mihari/clients/binaryedge.rb +5 -2
  42. data/lib/mihari/clients/censys.rb +7 -4
  43. data/lib/mihari/clients/circl.rb +3 -0
  44. data/lib/mihari/clients/crtsh.rb +3 -0
  45. data/lib/mihari/clients/dnstwister.rb +3 -0
  46. data/lib/mihari/clients/fofa.rb +83 -0
  47. data/lib/mihari/clients/greynoise.rb +5 -2
  48. data/lib/mihari/clients/hunterhow.rb +5 -2
  49. data/lib/mihari/clients/misp.rb +3 -0
  50. data/lib/mihari/clients/onyphe.rb +5 -2
  51. data/lib/mihari/clients/otx.rb +3 -0
  52. data/lib/mihari/clients/passivetotal.rb +3 -0
  53. data/lib/mihari/clients/publsedive.rb +4 -1
  54. data/lib/mihari/clients/securitytrails.rb +3 -0
  55. data/lib/mihari/clients/shodan.rb +5 -2
  56. data/lib/mihari/clients/the_hive.rb +3 -0
  57. data/lib/mihari/clients/urlscan.rb +7 -4
  58. data/lib/mihari/clients/virustotal.rb +5 -2
  59. data/lib/mihari/clients/zoomeye.rb +3 -0
  60. data/lib/mihari/commands/alert.rb +5 -14
  61. data/lib/mihari/commands/database.rb +3 -0
  62. data/lib/mihari/commands/rule.rb +10 -1
  63. data/lib/mihari/commands/search.rb +9 -6
  64. data/lib/mihari/commands/version.rb +3 -0
  65. data/lib/mihari/commands/web.rb +4 -1
  66. data/lib/mihari/config.rb +139 -150
  67. data/lib/mihari/constants.rb +1 -1
  68. data/lib/mihari/database.rb +6 -0
  69. data/lib/mihari/emitters/base.rb +13 -11
  70. data/lib/mihari/emitters/database.rb +4 -1
  71. data/lib/mihari/emitters/misp.rb +7 -4
  72. data/lib/mihari/emitters/slack.rb +3 -3
  73. data/lib/mihari/emitters/the_hive.rb +3 -3
  74. data/lib/mihari/emitters/webhook.rb +4 -3
  75. data/lib/mihari/enrichers/base.rb +15 -9
  76. data/lib/mihari/enrichers/google_public_dns.rb +6 -5
  77. data/lib/mihari/enrichers/ipinfo.rb +10 -8
  78. data/lib/mihari/enrichers/shodan.rb +4 -6
  79. data/lib/mihari/enrichers/whois.rb +12 -9
  80. data/lib/mihari/errors.rb +6 -0
  81. data/lib/mihari/feed/parser.rb +3 -0
  82. data/lib/mihari/feed/reader.rb +3 -0
  83. data/lib/mihari/http.rb +6 -0
  84. data/lib/mihari/mixins/autonomous_system.rb +3 -0
  85. data/lib/mihari/mixins/configurable.rb +3 -0
  86. data/lib/mihari/mixins/error_notification.rb +3 -0
  87. data/lib/mihari/mixins/falsepositive.rb +3 -0
  88. data/lib/mihari/mixins/refang.rb +3 -0
  89. data/lib/mihari/mixins/retriable.rb +6 -2
  90. data/lib/mihari/models/alert.rb +7 -4
  91. data/lib/mihari/models/artifact.rb +6 -0
  92. data/lib/mihari/models/autonomous_system.rb +4 -1
  93. data/lib/mihari/models/cpe.rb +4 -1
  94. data/lib/mihari/models/dns.rb +4 -1
  95. data/lib/mihari/models/geolocation.rb +4 -1
  96. data/lib/mihari/models/port.rb +4 -1
  97. data/lib/mihari/models/reverse_dns.rb +4 -1
  98. data/lib/mihari/models/rule.rb +6 -3
  99. data/lib/mihari/models/tag.rb +3 -0
  100. data/lib/mihari/models/tagging.rb +3 -0
  101. data/lib/mihari/models/whois.rb +4 -3
  102. data/lib/mihari/rule.rb +17 -12
  103. data/lib/mihari/schemas/alert.rb +3 -0
  104. data/lib/mihari/schemas/analyzer.rb +11 -0
  105. data/lib/mihari/schemas/emitter.rb +3 -0
  106. data/lib/mihari/schemas/enricher.rb +3 -0
  107. data/lib/mihari/schemas/macros.rb +4 -0
  108. data/lib/mihari/schemas/mixins.rb +5 -0
  109. data/lib/mihari/schemas/rule.rb +3 -0
  110. data/lib/mihari/service.rb +16 -0
  111. data/lib/mihari/services/alert_builder.rb +8 -5
  112. data/lib/mihari/services/alert_proxy.rb +6 -1
  113. data/lib/mihari/services/alert_runner.rb +8 -12
  114. data/lib/mihari/services/rule_builder.rb +8 -5
  115. data/lib/mihari/services/rule_runner.rb +8 -10
  116. data/lib/mihari/structs/binaryedge.rb +13 -28
  117. data/lib/mihari/structs/censys.rb +48 -127
  118. data/lib/mihari/structs/config.rb +19 -30
  119. data/lib/mihari/structs/filters.rb +38 -0
  120. data/lib/mihari/structs/fofa.rb +44 -0
  121. data/lib/mihari/structs/google_public_dns.rb +10 -28
  122. data/lib/mihari/structs/greynoise.rb +33 -84
  123. data/lib/mihari/structs/hunterhow.rb +24 -22
  124. data/lib/mihari/structs/ipinfo.rb +14 -35
  125. data/lib/mihari/structs/onyphe.rb +31 -76
  126. data/lib/mihari/structs/shodan.rb +47 -112
  127. data/lib/mihari/structs/urlscan.rb +24 -63
  128. data/lib/mihari/structs/virustotal_intelligence.rb +20 -56
  129. data/lib/mihari/type_checker.rb +4 -0
  130. data/lib/mihari/types.rb +3 -0
  131. data/lib/mihari/version.rb +1 -1
  132. data/lib/mihari/web/api.rb +15 -10
  133. data/lib/mihari/web/app.rb +59 -54
  134. data/lib/mihari/web/endpoints/alerts.rb +94 -89
  135. data/lib/mihari/web/endpoints/artifacts.rb +115 -110
  136. data/lib/mihari/web/endpoints/configs.rb +18 -13
  137. data/lib/mihari/web/endpoints/ip_addresses.rb +21 -16
  138. data/lib/mihari/web/endpoints/rules.rb +203 -198
  139. data/lib/mihari/web/endpoints/tags.rb +41 -36
  140. data/lib/mihari/web/middleware/connection_adapter.rb +16 -9
  141. data/lib/mihari/web/middleware/error_notification_adapter.rb +17 -10
  142. data/lib/mihari/web/public/assets/{index-28d4c79d.js → index-821134e2.js} +30 -30
  143. data/lib/mihari/web/public/assets/mode-yaml-24faa242.js +8 -0
  144. data/lib/mihari/web/public/index.html +1 -1
  145. data/lib/mihari.rb +24 -5
  146. data/mihari.gemspec +8 -1
  147. data/mkdocs.yml +3 -2
  148. metadata +39 -7
  149. data/lib/mihari/templates/rule.yml.erb +0 -5
  150. data/lib/mihari/web/public/assets/mode-yaml-a21faa53.js +0 -8
@@ -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
@@ -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
12
+
13
+ # @!attribute [r] country_code
14
+ # @return [String, nll]
10
15
  attribute :country_code, Types::String.optional
11
- attribute :ip, Types::String
12
- attribute :metadata, Types::Hash
13
16
 
14
- #
15
- # @return [String]
16
- #
17
- def asn
18
- attributes[:asn]
19
- end
17
+ # @!attribute [r] ip
18
+ # @return [String]
20
19
 
21
- #
22
- # @return [String, nil]
23
- #
24
- def country_code
25
- attributes[:country_code]
26
- end
27
-
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]
@@ -90,62 +74,33 @@ module Mihari
90
74
  end
91
75
 
92
76
  class Response < Dry::Struct
77
+ # @!attribute [r] count
78
+ # @return [Integer]
93
79
  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
80
 
108
- #
109
- # @return [Integer]
110
- #
111
- def error
112
- attributes[:error]
113
- end
81
+ # @!attribute [r] error
82
+ # @return [Integer]
83
+ attribute :error, Types::Int
114
84
 
115
- #
116
- # @return [Integer]
117
- #
118
- def max_page
119
- attributes[:max_page]
120
- end
85
+ # @!attribute [r] max_page
86
+ # @return [Integer]
87
+ attribute :max_page, Types::Int
121
88
 
122
- #
123
- # @return [Integer]
124
- #
125
- def page
126
- attributes[:page]
127
- end
89
+ # @!attribute [r] page
90
+ # @return [Integer]
91
+ attribute :page, Types::Int
128
92
 
129
- #
130
- # @return [Array<Result>]
131
- #
132
- def results
133
- attributes[:results]
134
- end
93
+ # @!attribute [r] results
94
+ # @return [Array<Result>]
95
+ attribute :results, Types.Array(Result)
135
96
 
136
- #
137
- # @return [String]
138
- #
139
- def status
140
- attributes[:status]
141
- end
97
+ # @!attribute [r] status
98
+ # @return [String]
99
+ attribute :status, Types::String
142
100
 
143
- #
144
- # @return [Integer]
145
- #
146
- def total
147
- attributes[:total]
148
- end
101
+ # @!attribute [r] total
102
+ # @return [Integer]
103
+ attribute :total, Types::Int
149
104
 
150
105
  #
151
106
  # @return [Array<Mihari::Models::Artifact>]
@@ -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,54 +193,29 @@ 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
-
243
- #
244
- # @return [String]
245
- #
246
- def ip
247
- attributes[:ip]
248
- end
249
199
 
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
  #
@@ -4,30 +4,17 @@ 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
  #
@@ -47,38 +34,21 @@ module Mihari
47
34
  end
48
35
 
49
36
  class Result < Dry::Struct
37
+ # @!attribute [r] page
38
+ # @return [Page]
50
39
  attribute :page, Page
51
- attribute :id, Types::String
52
- attribute :sort, Types.Array(Types::String | Types::Integer)
53
- attribute :metadata, Types::Hash
54
-
55
- #
56
- # @return [Page]
57
- #
58
- def page
59
- attributes[:page]
60
- end
61
40
 
62
- #
63
- # @return [String]
64
- #
65
- def id
66
- attributes[:id]
67
- end
41
+ # @!attribute [r] pid
42
+ # @return [String]
43
+ attribute :id, Types::String
68
44
 
69
- #
70
- # @return [Array<String, Integer>]
71
- #
72
- def sort
73
- attributes[:sort]
74
- end
45
+ # @!attribute [r] sort
46
+ # @return [Array<String, Integer>]
47
+ attribute :sort, Types.Array(Types::String | Types::Int)
75
48
 
76
- #
77
- # @return [Array<String, Integer>]
78
- #
79
- def metadata
80
- attributes[:metadata]
81
- end
49
+ # @!attribute [r] metadata
50
+ # @return [Hash]
51
+ attribute :metadata, Types::Hash
82
52
 
83
53
  #
84
54
  # @return [Array<Mihari::Models::Artifact>]
@@ -107,22 +77,13 @@ module Mihari
107
77
  end
108
78
 
109
79
  class Response < Dry::Struct
80
+ # @!attribute [r] results
81
+ # @return [Array<Result>]
110
82
  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
83
 
120
- #
121
- # @return [Boolean]
122
- #
123
- def has_more
124
- attributes[:has_more]
125
- end
84
+ # @!attribute [r] has_more
85
+ # @return [Boolean]
86
+ attribute :has_more, Types::Bool
126
87
 
127
88
  #
128
89
  # @return [Array<Mihari::Models::Artifact>]
@@ -4,15 +4,10 @@ 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
@@ -27,38 +22,21 @@ module Mihari
27
22
  end
28
23
 
29
24
  class Datum < Dry::Struct
25
+ # @!attribute [r] type
26
+ # @return [String]
30
27
  attribute :type, Types::String
31
- attribute :id, Types::String
32
- attribute :context_attributes, ContextAttributes.optional
33
- attribute :metadata, Types::Hash
34
28
 
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
29
+ # @!attribute [r] id
30
+ # @return [String]
31
+ attribute :id, Types::String
48
32
 
49
- #
50
- # @return [ContextAttributes, nil]
51
- #
52
- def context_attributes
53
- attributes[:context_attributes]
54
- end
33
+ # @!attribute [r] context_attributes
34
+ # @return [ContextAttributes, nil]
35
+ attribute :context_attributes, ContextAttributes.optional
55
36
 
56
- #
57
- # @return [Hash, nil]
58
- #
59
- def metadata
60
- attributes[:metadata]
61
- end
37
+ # @!attribute [r] metadata
38
+ # @return [Hash]
39
+ attribute :metadata, Types::Hash
62
40
 
63
41
  #
64
42
  # @return [String, nil]
@@ -108,15 +86,10 @@ module Mihari
108
86
  end
109
87
 
110
88
  class Meta < Dry::Struct
89
+ # @!attribute [r] cursor
90
+ # @return [String, nil]
111
91
  attribute :cursor, Types::String.optional
112
92
 
113
- #
114
- # @return [String, nil]
115
- #
116
- def cursor
117
- attributes[:cursor]
118
- end
119
-
120
93
  class << self
121
94
  #
122
95
  # @param [Hash] d
@@ -133,22 +106,13 @@ module Mihari
133
106
  end
134
107
 
135
108
  class Response < Dry::Struct
109
+ # @!attribute [r] meta
110
+ # @return [Meta]
136
111
  attribute :meta, Meta
137
- attribute :data, Types.Array(Datum)
138
-
139
- #
140
- # @return [Meta]
141
- #
142
- def meta
143
- attributes[:meta]
144
- end
145
112
 
146
- #
147
- # @return [Array<Datum>]
148
- #
149
- def data
150
- attributes[:data]
151
- end
113
+ # @!attribute [r] data
114
+ # @return [Array<Datum>]
115
+ attribute :data, Types.Array(Datum)
152
116
 
153
117
  #
154
118
  # @return [Array<Mihari::Models::Artifact>]
@@ -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.0"
5
5
  end
@@ -9,17 +9,22 @@ require "mihari/web/endpoints/rules"
9
9
  require "mihari/web/endpoints/tags"
10
10
 
11
11
  module Mihari
12
- class API < Grape::API
13
- prefix "api"
14
- format :json
12
+ module Web
13
+ #
14
+ # Grape API
15
+ #
16
+ class API < Grape::API
17
+ prefix "api"
18
+ format :json
15
19
 
16
- mount Endpoints::Alerts
17
- mount Endpoints::Artifacts
18
- mount Endpoints::Configs
19
- mount Endpoints::IPAddresses
20
- mount Endpoints::Rules
21
- mount Endpoints::Tags
20
+ mount Endpoints::Alerts
21
+ mount Endpoints::Artifacts
22
+ mount Endpoints::Configs
23
+ mount Endpoints::IPAddresses
24
+ mount Endpoints::Rules
25
+ mount Endpoints::Tags
22
26
 
23
- add_swagger_documentation(api_version: "v1", info: { title: "Mihari API" })
27
+ add_swagger_documentation(api_version: "v1", info: { title: "Mihari API" })
28
+ end
24
29
  end
25
30
  end