mihari 5.6.2 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/README.md +1 -0
- data/config.ru +1 -1
- data/lib/mihari/actor.rb +18 -2
- data/lib/mihari/analyzers/base.rb +13 -12
- data/lib/mihari/analyzers/binaryedge.rb +4 -1
- data/lib/mihari/analyzers/censys.rb +4 -2
- data/lib/mihari/analyzers/circl.rb +4 -1
- data/lib/mihari/analyzers/crtsh.rb +4 -1
- data/lib/mihari/analyzers/dnstwister.rb +4 -1
- data/lib/mihari/analyzers/feed.rb +3 -0
- data/lib/mihari/analyzers/fofa.rb +65 -0
- data/lib/mihari/analyzers/greynoise.rb +4 -1
- data/lib/mihari/analyzers/hunterhow.rb +6 -1
- data/lib/mihari/analyzers/onyphe.rb +4 -1
- data/lib/mihari/analyzers/otx.rb +4 -1
- data/lib/mihari/analyzers/passivetotal.rb +4 -1
- data/lib/mihari/analyzers/pulsedive.rb +3 -0
- data/lib/mihari/analyzers/securitytrails.rb +4 -1
- data/lib/mihari/analyzers/shodan.rb +4 -1
- data/lib/mihari/analyzers/urlscan.rb +4 -1
- data/lib/mihari/analyzers/virustotal.rb +4 -1
- data/lib/mihari/analyzers/virustotal_intelligence.rb +4 -1
- data/lib/mihari/analyzers/zoomeye.rb +5 -2
- data/lib/mihari/cli/alert.rb +3 -0
- data/lib/mihari/cli/base.rb +3 -0
- data/lib/mihari/cli/database.rb +3 -0
- data/lib/mihari/cli/main.rb +3 -0
- data/lib/mihari/cli/rule.rb +3 -0
- data/lib/mihari/clients/base.rb +3 -0
- data/lib/mihari/clients/binaryedge.rb +5 -2
- data/lib/mihari/clients/censys.rb +7 -4
- data/lib/mihari/clients/circl.rb +3 -0
- data/lib/mihari/clients/crtsh.rb +3 -0
- data/lib/mihari/clients/dnstwister.rb +3 -0
- data/lib/mihari/clients/fofa.rb +83 -0
- data/lib/mihari/clients/greynoise.rb +5 -2
- data/lib/mihari/clients/hunterhow.rb +5 -2
- data/lib/mihari/clients/misp.rb +3 -0
- data/lib/mihari/clients/onyphe.rb +5 -2
- data/lib/mihari/clients/otx.rb +3 -0
- data/lib/mihari/clients/passivetotal.rb +3 -0
- data/lib/mihari/clients/publsedive.rb +4 -1
- data/lib/mihari/clients/securitytrails.rb +3 -0
- data/lib/mihari/clients/shodan.rb +5 -2
- data/lib/mihari/clients/the_hive.rb +3 -0
- data/lib/mihari/clients/urlscan.rb +7 -4
- data/lib/mihari/clients/virustotal.rb +5 -2
- data/lib/mihari/clients/zoomeye.rb +3 -0
- data/lib/mihari/commands/alert.rb +9 -16
- data/lib/mihari/commands/database.rb +3 -0
- data/lib/mihari/commands/rule.rb +10 -1
- data/lib/mihari/commands/search.rb +13 -29
- data/lib/mihari/commands/version.rb +3 -0
- data/lib/mihari/commands/web.rb +4 -1
- data/lib/mihari/config.rb +139 -150
- data/lib/mihari/constants.rb +1 -1
- data/lib/mihari/database.rb +6 -0
- data/lib/mihari/emitters/base.rb +13 -11
- data/lib/mihari/emitters/database.rb +4 -1
- data/lib/mihari/emitters/misp.rb +7 -4
- data/lib/mihari/emitters/slack.rb +3 -3
- data/lib/mihari/emitters/the_hive.rb +3 -3
- data/lib/mihari/emitters/webhook.rb +4 -3
- data/lib/mihari/enrichers/base.rb +15 -9
- data/lib/mihari/enrichers/google_public_dns.rb +6 -5
- data/lib/mihari/enrichers/ipinfo.rb +11 -9
- data/lib/mihari/enrichers/shodan.rb +4 -6
- data/lib/mihari/enrichers/whois.rb +12 -9
- data/lib/mihari/entities/tag.rb +1 -0
- data/lib/mihari/errors.rb +6 -0
- data/lib/mihari/feed/parser.rb +3 -0
- data/lib/mihari/feed/reader.rb +3 -0
- data/lib/mihari/http.rb +6 -0
- data/lib/mihari/mixins/autonomous_system.rb +3 -0
- data/lib/mihari/mixins/configurable.rb +3 -0
- data/lib/mihari/mixins/error_notification.rb +3 -0
- data/lib/mihari/mixins/falsepositive.rb +3 -0
- data/lib/mihari/mixins/refang.rb +3 -0
- data/lib/mihari/mixins/retriable.rb +6 -2
- data/lib/mihari/models/alert.rb +7 -4
- data/lib/mihari/models/artifact.rb +6 -0
- data/lib/mihari/models/autonomous_system.rb +4 -1
- data/lib/mihari/models/cpe.rb +4 -1
- data/lib/mihari/models/dns.rb +4 -1
- data/lib/mihari/models/geolocation.rb +4 -1
- data/lib/mihari/models/port.rb +4 -1
- data/lib/mihari/models/reverse_dns.rb +4 -1
- data/lib/mihari/models/rule.rb +6 -3
- data/lib/mihari/models/tag.rb +3 -0
- data/lib/mihari/models/tagging.rb +3 -0
- data/lib/mihari/models/whois.rb +4 -3
- data/lib/mihari/rule.rb +31 -12
- data/lib/mihari/schemas/alert.rb +3 -0
- data/lib/mihari/schemas/analyzer.rb +11 -0
- data/lib/mihari/schemas/emitter.rb +3 -0
- data/lib/mihari/schemas/enricher.rb +3 -0
- data/lib/mihari/schemas/macros.rb +4 -0
- data/lib/mihari/schemas/mixins.rb +5 -0
- data/lib/mihari/schemas/rule.rb +3 -0
- data/lib/mihari/service.rb +26 -0
- data/lib/mihari/services/alert_builder.rb +85 -9
- data/lib/mihari/services/alert_runner.rb +8 -19
- data/lib/mihari/services/rule_builder.rb +13 -12
- data/lib/mihari/services/rule_runner.rb +7 -32
- data/lib/mihari/structs/binaryedge.rb +22 -28
- data/lib/mihari/structs/censys.rb +48 -141
- data/lib/mihari/structs/config.rb +19 -30
- data/lib/mihari/structs/filters.rb +38 -0
- data/lib/mihari/structs/fofa.rb +47 -0
- data/lib/mihari/structs/google_public_dns.rb +10 -32
- data/lib/mihari/structs/greynoise.rb +33 -90
- data/lib/mihari/structs/hunterhow.rb +24 -28
- data/lib/mihari/structs/ipinfo.rb +14 -37
- data/lib/mihari/structs/onyphe.rb +31 -80
- data/lib/mihari/structs/shodan.rb +47 -114
- data/lib/mihari/structs/urlscan.rb +24 -69
- data/lib/mihari/structs/virustotal_intelligence.rb +20 -64
- data/lib/mihari/type_checker.rb +4 -0
- data/lib/mihari/types.rb +3 -0
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/api.rb +15 -10
- data/lib/mihari/web/app.rb +64 -56
- data/lib/mihari/web/endpoints/alerts.rb +127 -85
- data/lib/mihari/web/endpoints/artifacts.rb +91 -79
- data/lib/mihari/web/endpoints/configs.rb +18 -13
- data/lib/mihari/web/endpoints/ip_addresses.rb +35 -15
- data/lib/mihari/web/endpoints/rules.rb +236 -187
- data/lib/mihari/web/endpoints/tags.rb +42 -35
- data/lib/mihari/web/middleware/connection_adapter.rb +16 -9
- data/lib/mihari/web/middleware/error_notification_adapter.rb +17 -10
- data/lib/mihari/web/public/assets/{index-28d4c79d.js → index-07fafab5.js} +31 -30
- data/lib/mihari/web/public/assets/mode-yaml-24faa242.js +8 -0
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari.rb +24 -6
- data/mihari.gemspec +9 -2
- data/mkdocs.yml +4 -2
- metadata +38 -133
- data/docs/alternatives.md +0 -5
- data/docs/analyzers/binaryedge.md +0 -26
- data/docs/analyzers/censys.md +0 -31
- data/docs/analyzers/circl.md +0 -37
- data/docs/analyzers/crtsh.md +0 -26
- data/docs/analyzers/dnstwister.md +0 -25
- data/docs/analyzers/feed.md +0 -73
- data/docs/analyzers/greynoise.md +0 -26
- data/docs/analyzers/hunterhow.md +0 -33
- data/docs/analyzers/index.md +0 -103
- data/docs/analyzers/onyphe.md +0 -26
- data/docs/analyzers/otx.md +0 -28
- data/docs/analyzers/passivetotal.md +0 -52
- data/docs/analyzers/pulsedive.md +0 -28
- data/docs/analyzers/securitytrails.md +0 -41
- data/docs/analyzers/shodan.md +0 -26
- data/docs/analyzers/urlscan.md +0 -28
- data/docs/analyzers/virustotal.md +0 -43
- data/docs/analyzers/virustotal_intelligence.md +0 -33
- data/docs/analyzers/zoomeye.md +0 -38
- data/docs/configuration.md +0 -35
- data/docs/emitters/database.md +0 -22
- data/docs/emitters/hive.md +0 -26
- data/docs/emitters/index.md +0 -36
- data/docs/emitters/misp.md +0 -21
- data/docs/emitters/slack.md +0 -21
- data/docs/emitters/webhook.md +0 -63
- data/docs/enrichers/google_public_dns.md +0 -19
- data/docs/enrichers/index.md +0 -35
- data/docs/enrichers/ipinfo.md +0 -26
- data/docs/enrichers/shodan.md +0 -22
- data/docs/enrichers/whois.md +0 -17
- data/docs/github_actions.md +0 -43
- data/docs/index.md +0 -11
- data/docs/installation.md +0 -31
- data/docs/requirements.md +0 -13
- data/docs/rule.md +0 -168
- data/docs/tags.md +0 -3
- data/docs/usage.md +0 -103
- data/frontend/.eslintrc.cjs +0 -22
- data/frontend/.gitignore +0 -31
- data/frontend/.prettierrc.json +0 -8
- data/frontend/README.md +0 -3
- data/frontend/env.d.ts +0 -5
- data/frontend/index.html +0 -21
- data/frontend/package-lock.json +0 -7219
- data/frontend/package.json +0 -67
- data/frontend/public/favicon.ico +0 -0
- data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
- data/frontend/src/App.vue +0 -27
- data/frontend/src/ace-config.ts +0 -6
- data/frontend/src/api-helper.ts +0 -111
- data/frontend/src/api.ts +0 -105
- data/frontend/src/components/ErrorMessage.vue +0 -31
- data/frontend/src/components/Loading.vue +0 -15
- data/frontend/src/components/Navbar.vue +0 -42
- data/frontend/src/components/Pagination.vue +0 -119
- data/frontend/src/components/alert/Alert.vue +0 -87
- data/frontend/src/components/alert/Alerts.vue +0 -63
- data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
- data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
- data/frontend/src/components/alert/Form.vue +0 -182
- data/frontend/src/components/artifact/AS.vue +0 -29
- data/frontend/src/components/artifact/Artifact.vue +0 -287
- data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
- data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
- data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
- data/frontend/src/components/artifact/CPEs.vue +0 -23
- data/frontend/src/components/artifact/DnsRecords.vue +0 -38
- data/frontend/src/components/artifact/Ports.vue +0 -23
- data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -31
- data/frontend/src/components/artifact/Tags.vue +0 -29
- data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
- data/frontend/src/components/config/Configs.vue +0 -65
- data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
- data/frontend/src/components/link/Link.vue +0 -32
- data/frontend/src/components/link/Links.vue +0 -42
- data/frontend/src/components/rule/EditRule.vue +0 -72
- data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
- data/frontend/src/components/rule/Form.vue +0 -158
- data/frontend/src/components/rule/InputForm.vue +0 -45
- data/frontend/src/components/rule/NewRule.vue +0 -57
- data/frontend/src/components/rule/Rule.vue +0 -100
- data/frontend/src/components/rule/RuleWrapper.vue +0 -53
- data/frontend/src/components/rule/Rules.vue +0 -84
- data/frontend/src/components/rule/RulesWrapper.vue +0 -121
- data/frontend/src/components/rule/YAML.vue +0 -37
- data/frontend/src/components/tag/Tag.vue +0 -65
- data/frontend/src/components/tag/Tags.vue +0 -37
- data/frontend/src/countries.ts +0 -350
- data/frontend/src/index.ts +0 -20
- data/frontend/src/links/anyrun.ts +0 -19
- data/frontend/src/links/base.ts +0 -14
- data/frontend/src/links/censys.ts +0 -20
- data/frontend/src/links/crtsh.ts +0 -20
- data/frontend/src/links/dnslytics.ts +0 -38
- data/frontend/src/links/greynoise.ts +0 -20
- data/frontend/src/links/index.ts +0 -40
- data/frontend/src/links/intezer.ts +0 -20
- data/frontend/src/links/otx.ts +0 -33
- data/frontend/src/links/securitytrails.ts +0 -38
- data/frontend/src/links/shodan.ts +0 -20
- data/frontend/src/links/urlscan.ts +0 -50
- data/frontend/src/links/virustotal.ts +0 -72
- data/frontend/src/main.ts +0 -41
- data/frontend/src/router/index.ts +0 -57
- data/frontend/src/rule.ts +0 -14
- data/frontend/src/shims-vue.d.ts +0 -6
- data/frontend/src/swagger.yaml +0 -771
- data/frontend/src/types.ts +0 -188
- data/frontend/src/utils.ts +0 -54
- data/frontend/src/views/Alerts.vue +0 -20
- data/frontend/src/views/Artifact.vue +0 -39
- data/frontend/src/views/Configs.vue +0 -20
- data/frontend/src/views/EditRule.vue +0 -39
- data/frontend/src/views/NewRule.vue +0 -26
- data/frontend/src/views/Rule.vue +0 -39
- data/frontend/src/views/Rules.vue +0 -20
- data/frontend/tests/utils.spec.ts +0 -9
- data/frontend/tsconfig.app.json +0 -21
- data/frontend/tsconfig.json +0 -14
- data/frontend/tsconfig.node.json +0 -13
- data/frontend/tsconfig.vitest.json +0 -12
- data/frontend/vite.config.ts +0 -24
- data/frontend/vitest.config.ts +0 -21
- data/lib/mihari/services/alert_proxy.rb +0 -92
- data/lib/mihari/templates/rule.yml.erb +0 -5
- 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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
72
|
-
|
73
|
-
def hostnames
|
74
|
-
attributes[:hostnames]
|
75
|
-
end
|
54
|
+
# @!attribute [r] location
|
55
|
+
# @return [Location]
|
56
|
+
attribute :location, Location
|
76
57
|
|
77
|
-
#
|
78
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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(
|
data/lib/mihari/type_checker.rb
CHANGED
@@ -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
data/lib/mihari/version.rb
CHANGED