mihari 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/Dockerfile +3 -3
- data/README.md +0 -1
- data/Rakefile +4 -0
- data/lib/mihari/config.rb +0 -4
- data/lib/mihari/schemas/analyzer.rb +0 -1
- data/lib/mihari/version.rb +1 -3
- data/lib/mihari/web/public/assets/index-C3PsXBg7.js +1617 -0
- data/lib/mihari/web/public/assets/index-DzpJMEJU.css +1 -0
- data/lib/mihari/web/public/index.html +2 -2
- data/lib/mihari/web/public/redoc-static.html +413 -413
- data/lib/mihari.rb +0 -3
- data/mihari.gemspec +41 -42
- data/requirements.txt +1 -1
- metadata +82 -99
- data/lib/mihari/analyzers/binaryedge.rb +0 -42
- data/lib/mihari/clients/binaryedge.rb +0 -66
- data/lib/mihari/structs/binaryedge.rb +0 -83
- data/lib/mihari/web/public/assets/index-Dwa66Ymz.css +0 -1
- data/lib/mihari/web/public/assets/index-sQr_iTap.js +0 -1594
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mihari
|
4
|
-
module Analyzers
|
5
|
-
#
|
6
|
-
# BinaryEdge analyzer
|
7
|
-
#
|
8
|
-
class BinaryEdge < Base
|
9
|
-
# @return [String, nil]
|
10
|
-
attr_reader :api_key
|
11
|
-
|
12
|
-
#
|
13
|
-
# @param [String] query
|
14
|
-
# @param [Hash, nil] options
|
15
|
-
# @param [String, nil] api_key
|
16
|
-
#
|
17
|
-
def initialize(query, options: nil, api_key: nil)
|
18
|
-
super(query, options:)
|
19
|
-
|
20
|
-
@api_key = api_key || Mihari.config.binaryedge_api_key
|
21
|
-
end
|
22
|
-
|
23
|
-
def artifacts
|
24
|
-
client.search_with_pagination(query, pagination_limit:).map(&:artifacts).flatten
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# @return [Mihari::Clients::BinaryEdge]
|
32
|
-
#
|
33
|
-
def client
|
34
|
-
Clients::BinaryEdge.new(
|
35
|
-
api_key:,
|
36
|
-
pagination_interval:,
|
37
|
-
timeout:
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mihari
|
4
|
-
module Clients
|
5
|
-
#
|
6
|
-
# BinaryEdge API client
|
7
|
-
#
|
8
|
-
class BinaryEdge < Base
|
9
|
-
#
|
10
|
-
# @param [String] base_url
|
11
|
-
# @param [String, nil] api_key
|
12
|
-
# @param [Hash] headers
|
13
|
-
# @param [Integer, nil] timeout
|
14
|
-
# @param [Integer] pagination_interval
|
15
|
-
#
|
16
|
-
def initialize(
|
17
|
-
base_url = "https://api.binaryedge.io",
|
18
|
-
api_key:,
|
19
|
-
headers: {},
|
20
|
-
pagination_interval: Mihari.config.pagination_interval,
|
21
|
-
timeout: nil
|
22
|
-
)
|
23
|
-
headers["x-key"] = api_key
|
24
|
-
|
25
|
-
super(base_url, headers:, timeout:, pagination_interval:)
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# @param [String] query String used to query our data
|
30
|
-
# @param [Integer] page Default 1, Maximum: 500
|
31
|
-
# @param [Integer, nil] only_ips If selected, only output IP addresses, ports and protocols.
|
32
|
-
#
|
33
|
-
# @return [Mihari::Structs::BinaryEdge::Response]
|
34
|
-
#
|
35
|
-
def search(query, page: 1, only_ips: nil)
|
36
|
-
params = {
|
37
|
-
query:,
|
38
|
-
page:,
|
39
|
-
only_ips:
|
40
|
-
}.compact
|
41
|
-
Structs::BinaryEdge::Response.from_dynamic! get_json("/v2/query/search", params:)
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# @param [String] query
|
46
|
-
# @param [Integer, nil] only_ips
|
47
|
-
# @param [Integer] pagination_limit
|
48
|
-
#
|
49
|
-
# @return [Enumerable<Mihari::Structs::BinaryEdge::Response>]
|
50
|
-
#
|
51
|
-
def search_with_pagination(query, only_ips: nil, pagination_limit: Mihari.config.pagination_limit)
|
52
|
-
Enumerator.new do |y|
|
53
|
-
(1..pagination_limit).each do |page|
|
54
|
-
res = search(query, page:, only_ips:)
|
55
|
-
|
56
|
-
y.yield res
|
57
|
-
|
58
|
-
break if res.events.length < res.pagesize
|
59
|
-
|
60
|
-
sleep_pagination_interval
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mihari
|
4
|
-
module Structs
|
5
|
-
module BinaryEdge
|
6
|
-
class Target < Dry::Struct
|
7
|
-
# @!attribute [r] ip
|
8
|
-
# @return [String]
|
9
|
-
attribute :ip, Types::String
|
10
|
-
|
11
|
-
class << self
|
12
|
-
#
|
13
|
-
# @param [Hash] d
|
14
|
-
#
|
15
|
-
def from_dynamic!(d)
|
16
|
-
d = Types::Hash[d]
|
17
|
-
new(
|
18
|
-
ip: d.fetch("ip")
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Event < Dry::Struct
|
25
|
-
# @!attribute [r] target
|
26
|
-
# @return [Target]
|
27
|
-
attribute :target, Target
|
28
|
-
|
29
|
-
class << self
|
30
|
-
#
|
31
|
-
# @param [Hash] d
|
32
|
-
#
|
33
|
-
def from_dynamic!(d)
|
34
|
-
d = Types::Hash[d]
|
35
|
-
new(
|
36
|
-
target: Target.from_dynamic!(d.fetch("target"))
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class Response < Dry::Struct
|
43
|
-
# @!attribute [r] page
|
44
|
-
# @return [Integer]
|
45
|
-
attribute :page, Types::Int
|
46
|
-
|
47
|
-
# @!attribute [r] pagesize
|
48
|
-
# @return [Integer]
|
49
|
-
attribute :pagesize, Types::Int
|
50
|
-
|
51
|
-
# @!attribute [r] total
|
52
|
-
# @return [Integer]
|
53
|
-
attribute :total, Types::Int
|
54
|
-
|
55
|
-
# @!attribute [r] events
|
56
|
-
# @return [Array<Event>]
|
57
|
-
attribute :events, Types.Array(Event)
|
58
|
-
|
59
|
-
#
|
60
|
-
# @return [Array<Artifact>]
|
61
|
-
#
|
62
|
-
def artifacts
|
63
|
-
events.map { |event| Models::Artifact.new(data: event.target.ip) }
|
64
|
-
end
|
65
|
-
|
66
|
-
class << self
|
67
|
-
#
|
68
|
-
# @param [Hash] d
|
69
|
-
#
|
70
|
-
def from_dynamic!(d)
|
71
|
-
d = Types::Hash[d]
|
72
|
-
new(
|
73
|
-
page: d.fetch("page"),
|
74
|
-
pagesize: d.fetch("pagesize"),
|
75
|
-
total: d.fetch("total"),
|
76
|
-
events: d.fetch("events").map { |x| Event.from_dynamic!(x) }
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|