mihari 5.4.6 → 5.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +2 -0
- data/docs/analyzers/index.md +5 -0
- data/docs/emitters/misp.md +1 -1
- data/docs/requirements.md +8 -15
- data/frontend/package-lock.json +258 -249
- data/frontend/package.json +12 -12
- data/lib/mihari/analyzers/base.rb +8 -1
- data/lib/mihari/analyzers/binaryedge.rb +1 -1
- data/lib/mihari/analyzers/censys.rb +1 -1
- data/lib/mihari/analyzers/feed.rb +1 -0
- data/lib/mihari/analyzers/greynoise.rb +1 -1
- data/lib/mihari/analyzers/hunterhow.rb +1 -1
- data/lib/mihari/analyzers/onyphe.rb +1 -1
- data/lib/mihari/analyzers/shodan.rb +1 -1
- data/lib/mihari/analyzers/urlscan.rb +1 -1
- data/lib/mihari/analyzers/virustotal_intelligence.rb +1 -1
- data/lib/mihari/analyzers/zoomeye.rb +1 -1
- data/lib/mihari/clients/base.rb +18 -5
- data/lib/mihari/clients/binaryedge.rb +4 -3
- data/lib/mihari/clients/censys.rb +3 -2
- data/lib/mihari/clients/greynoise.rb +3 -2
- data/lib/mihari/clients/hunterhow.rb +3 -2
- data/lib/mihari/clients/onyphe.rb +4 -2
- data/lib/mihari/clients/shodan.rb +3 -2
- data/lib/mihari/clients/urlscan.rb +3 -2
- data/lib/mihari/clients/virustotal.rb +3 -2
- data/lib/mihari/clients/zoomeye.rb +3 -2
- data/lib/mihari/config.rb +13 -0
- data/lib/mihari/database.rb +2 -2
- data/lib/mihari/emitters/webhook.rb +11 -11
- data/lib/mihari/enrichers/google_public_dns.rb +7 -1
- data/lib/mihari/enrichers/ipinfo.rb +13 -6
- data/lib/mihari/enrichers/shodan.rb +7 -1
- data/lib/mihari/errors.rb +0 -2
- data/lib/mihari/feed/reader.rb +15 -10
- data/lib/mihari/http.rb +26 -100
- data/lib/mihari/schemas/analyzer.rb +1 -0
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/public/assets/{index-0a5a47bf.js → index-a92abd57.js} +1 -1
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari/web/public/redoc-static.html +400 -400
- data/mihari.gemspec +8 -5
- data/requirements.txt +1 -1
- metadata +57 -15
data/lib/mihari/http.rb
CHANGED
@@ -1,115 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "http"
|
4
4
|
|
5
5
|
module Mihari
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
# Make a GET request
|
20
|
-
#
|
21
|
-
# @param [Hash, nil] params
|
22
|
-
#
|
23
|
-
# @return [Net::HTTPResponse]
|
24
|
-
#
|
25
|
-
def get(params: nil)
|
26
|
-
new_url = url.deep_dup
|
27
|
-
new_url.query = Addressable::URI.form_encode(params) unless (params || {}).empty?
|
28
|
-
|
29
|
-
get = Net::HTTP::Get.new(new_url, headers)
|
30
|
-
request get
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Make a POST request
|
35
|
-
#
|
36
|
-
# @param [Hash, nil] params
|
37
|
-
# @param [Hash, nil] json
|
38
|
-
# @param [Hash, nil] data
|
39
|
-
#
|
40
|
-
# @return [Net::HTTPResponse]
|
41
|
-
#
|
42
|
-
def post(params: nil, json: nil, data: nil)
|
43
|
-
new_url = url.deep_dup
|
44
|
-
new_url.query = Addressable::URI.form_encode(params) unless (params || {}).empty?
|
45
|
-
|
46
|
-
post = Net::HTTP::Post.new(new_url, headers)
|
47
|
-
|
48
|
-
if json
|
49
|
-
post.body = JSON.generate(json) if json
|
50
|
-
post.content_type = "application/json"
|
51
|
-
end
|
52
|
-
|
53
|
-
if data
|
54
|
-
post.set_form_data(data) if data
|
55
|
-
post.content_type = "application/x-www-form-urlencoded"
|
56
|
-
end
|
57
|
-
|
58
|
-
request post
|
59
|
-
end
|
60
|
-
|
61
|
-
class << self
|
62
|
-
def get(url, headers: {}, params: nil)
|
63
|
-
client = new(url, headers: headers)
|
64
|
-
client.get(params: params)
|
6
|
+
module HTTP
|
7
|
+
class BetterError < ::HTTP::Feature
|
8
|
+
def wrap_response(response)
|
9
|
+
unless response.status.success?
|
10
|
+
raise StatusCodeError.new(
|
11
|
+
"Unsuccessful response code returned: #{response.code}",
|
12
|
+
response.code,
|
13
|
+
response.body.to_s
|
14
|
+
)
|
15
|
+
end
|
16
|
+
response
|
65
17
|
end
|
66
18
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
19
|
+
def on_error(_request, error)
|
20
|
+
raise TimeoutError, error if error.is_a?(::HTTP::TimeoutError)
|
21
|
+
raise NetworkError, error if error.is_a?(::HTTP::Error)
|
70
22
|
end
|
71
|
-
end
|
72
23
|
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
# Get options for HTTP request
|
77
|
-
#
|
78
|
-
# @return [Hahs]
|
79
|
-
#
|
80
|
-
def https_options
|
81
|
-
return { use_ssl: true } if url.scheme == "https"
|
82
|
-
|
83
|
-
{}
|
24
|
+
::HTTP::Options.register_feature(:better_error, self)
|
84
25
|
end
|
85
26
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
unless res.is_a?(Net::HTTPSuccess)
|
98
|
-
raise StatusCodeError.new(
|
99
|
-
"Unsuccessful response code returned: #{res.code}",
|
100
|
-
res.code.to_i,
|
101
|
-
res.body
|
102
|
-
)
|
27
|
+
class Factory
|
28
|
+
class << self
|
29
|
+
#
|
30
|
+
# @param [Integer, nil] timeout
|
31
|
+
# @param [Hash] headers
|
32
|
+
#
|
33
|
+
# @return [::HTTP::Client]
|
34
|
+
#
|
35
|
+
def build(headers: {}, timeout: nil)
|
36
|
+
::HTTP.use(:better_error).headers(headers).timeout(timeout || {})
|
103
37
|
end
|
104
|
-
|
105
|
-
res
|
106
38
|
end
|
107
|
-
rescue Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, EOFError, SocketError, Net::ProtocolError => e
|
108
|
-
raise NetworkError, e
|
109
|
-
rescue Timeout::Error => e
|
110
|
-
raise TimeoutError, e
|
111
|
-
rescue OpenSSL::SSL::SSLError => e
|
112
|
-
raise SSLError, e
|
113
39
|
end
|
114
40
|
end
|
115
41
|
end
|
@@ -8,6 +8,7 @@ module Mihari
|
|
8
8
|
optional(:retry_times).value(:integer).default(Mihari.config.retry_times)
|
9
9
|
optional(:retry_interval).value(:integer).default(Mihari.config.retry_interval)
|
10
10
|
optional(:ignore_error).value(:bool).default(Mihari.config.ignore_error)
|
11
|
+
optional(:timeout).value(:integer)
|
11
12
|
end
|
12
13
|
|
13
14
|
AnalyzerWithoutAPIKey = Dry::Schema.Params do
|
data/lib/mihari/version.rb
CHANGED
@@ -940,7 +940,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
940
940
|
.ace-tm .ace_indent-guide-active {
|
941
941
|
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAZSURBVHjaYvj///9/hivKyv8BAAAA//8DACLqBhbvk+/eAAAAAElFTkSuQmCC") right repeat-y;
|
942
942
|
}
|
943
|
-
`}),ace.define("ace/theme/textmate",["require","exports","module","ace/theme/textmate-css","ace/lib/dom"],function(n,i,p){i.isDark=!1,i.cssClass="ace-tm",i.cssText=n("./textmate-css"),i.$id="ace/theme/textmate";var u=n("../lib/dom");u.importCssString(i.cssText,i.cssClass,!1)}),ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/net","ace/lib/dom","ace/lib/app_config","ace/theme/textmate"],function(n,i,p){"no use strict";var u=n("./lib/lang"),f=n("./lib/net"),g=n("./lib/dom"),s=n("./lib/app_config").AppConfig;p.exports=i=new s;var h={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{},loadWorkerFromBlob:!0,sharedPopups:!1,useStrictCSP:null};i.get=function(c){if(!h.hasOwnProperty(c))throw new Error("Unknown config key: "+c);return h[c]},i.set=function(c,a){if(h.hasOwnProperty(c))h[c]=a;else if(this.setDefaultValue("",c,a)==!1)throw new Error("Unknown config key: "+c);c=="useStrictCSP"&&g.useStrictCSP(a)},i.all=function(){return u.copyObject(h)},i.$modes={},i.moduleUrl=function(c,a){if(h.$moduleUrls[c])return h.$moduleUrls[c];var d=c.split("/");a=a||d[d.length-2]||"";var m=a=="snippets"?"/":"-",y=d[d.length-1];if(a=="worker"&&m=="-"){var b=new RegExp("^"+a+"[\\-_]|[\\-_]"+a+"$","g");y=y.replace(b,"")}(!y||y==a)&&d.length>1&&(y=d[d.length-2]);var E=h[a+"Path"];return E==null?E=h.basePath:m=="/"&&(a=m=""),E&&E.slice(-1)!="/"&&(E+="/"),E+a+m+y+this.get("suffix")},i.setModuleUrl=function(c,a){return h.$moduleUrls[c]=a};var o=function(c,a){if(c==="ace/theme/textmate"||c==="./theme/textmate")return a(null,n("./theme/textmate"));if(r)return r(c,a);console.error("loader is not configured")},r;i.setLoader=function(c){r=c},i.dynamicModules=Object.create(null),i.$loading={},i.$loaded={},i.loadModule=function(c,a){var d,m;Array.isArray(c)&&(m=c[0],c=c[1]);var y=function(b){if(b&&!i.$loading[c])return a&&a(b);if(i.$loading[c]||(i.$loading[c]=[]),i.$loading[c].push(a),!(i.$loading[c].length>1)){var E=function(){o(c,function(S,C){C&&(i.$loaded[c]=C),i._emit("load.module",{name:c,module:C});var $=i.$loading[c];i.$loading[c]=null,$.forEach(function(R){R&&R(C)})})};if(!i.get("packaged"))return E();f.loadScript(i.moduleUrl(c,m),E),l()}};if(i.dynamicModules[c])i.dynamicModules[c]().then(function(b){b.default?y(b.default):y(b)});else{try{d=this.$require(c)}catch{}y(d||i.$loaded[c])}},i.$require=function(c){if(typeof p.require=="function"){var a="require";return p[a](c)}},i.setModuleLoader=function(c,a){i.dynamicModules[c]=a};var l=function(){!h.basePath&&!h.workerPath&&!h.modePath&&!h.themePath&&!Object.keys(h.$moduleUrls).length&&(console.error("Unable to infer path to ace from script src,","use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes","or with webpack use ace/webpack-resolver"),l=function(){})};i.version="1.
|
943
|
+
`}),ace.define("ace/theme/textmate",["require","exports","module","ace/theme/textmate-css","ace/lib/dom"],function(n,i,p){i.isDark=!1,i.cssClass="ace-tm",i.cssText=n("./textmate-css"),i.$id="ace/theme/textmate";var u=n("../lib/dom");u.importCssString(i.cssText,i.cssClass,!1)}),ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/net","ace/lib/dom","ace/lib/app_config","ace/theme/textmate"],function(n,i,p){"no use strict";var u=n("./lib/lang"),f=n("./lib/net"),g=n("./lib/dom"),s=n("./lib/app_config").AppConfig;p.exports=i=new s;var h={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{},loadWorkerFromBlob:!0,sharedPopups:!1,useStrictCSP:null};i.get=function(c){if(!h.hasOwnProperty(c))throw new Error("Unknown config key: "+c);return h[c]},i.set=function(c,a){if(h.hasOwnProperty(c))h[c]=a;else if(this.setDefaultValue("",c,a)==!1)throw new Error("Unknown config key: "+c);c=="useStrictCSP"&&g.useStrictCSP(a)},i.all=function(){return u.copyObject(h)},i.$modes={},i.moduleUrl=function(c,a){if(h.$moduleUrls[c])return h.$moduleUrls[c];var d=c.split("/");a=a||d[d.length-2]||"";var m=a=="snippets"?"/":"-",y=d[d.length-1];if(a=="worker"&&m=="-"){var b=new RegExp("^"+a+"[\\-_]|[\\-_]"+a+"$","g");y=y.replace(b,"")}(!y||y==a)&&d.length>1&&(y=d[d.length-2]);var E=h[a+"Path"];return E==null?E=h.basePath:m=="/"&&(a=m=""),E&&E.slice(-1)!="/"&&(E+="/"),E+a+m+y+this.get("suffix")},i.setModuleUrl=function(c,a){return h.$moduleUrls[c]=a};var o=function(c,a){if(c==="ace/theme/textmate"||c==="./theme/textmate")return a(null,n("./theme/textmate"));if(r)return r(c,a);console.error("loader is not configured")},r;i.setLoader=function(c){r=c},i.dynamicModules=Object.create(null),i.$loading={},i.$loaded={},i.loadModule=function(c,a){var d,m;Array.isArray(c)&&(m=c[0],c=c[1]);var y=function(b){if(b&&!i.$loading[c])return a&&a(b);if(i.$loading[c]||(i.$loading[c]=[]),i.$loading[c].push(a),!(i.$loading[c].length>1)){var E=function(){o(c,function(S,C){C&&(i.$loaded[c]=C),i._emit("load.module",{name:c,module:C});var $=i.$loading[c];i.$loading[c]=null,$.forEach(function(R){R&&R(C)})})};if(!i.get("packaged"))return E();f.loadScript(i.moduleUrl(c,m),E),l()}};if(i.dynamicModules[c])i.dynamicModules[c]().then(function(b){b.default?y(b.default):y(b)});else{try{d=this.$require(c)}catch{}y(d||i.$loaded[c])}},i.$require=function(c){if(typeof p.require=="function"){var a="require";return p[a](c)}},i.setModuleLoader=function(c,a){i.dynamicModules[c]=a};var l=function(){!h.basePath&&!h.workerPath&&!h.modePath&&!h.themePath&&!Object.keys(h.$moduleUrls).length&&(console.error("Unable to infer path to ace from script src,","use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes","or with webpack use ace/webpack-resolver"),l=function(){})};i.version="1.29.0"}),ace.define("ace/loader_build",["require","exports","module","ace/lib/fixoldbrowsers","ace/config"],function(n,i,p){n("./lib/fixoldbrowsers");var u=n("./config");u.setLoader(function(h,o){n([h],function(r){o(null,r)})});var f=function(){return this||typeof window<"u"&&window}();p.exports=function(h){u.init=g,u.$require=n,h.require=n},g(!0);function g(h){if(!(!f||!f.document)){u.set("packaged",h||n.packaged||p.packaged||f.define&&(void 0).packaged);var o={},r="",l=document.currentScript||document._currentScript,c=l&&l.ownerDocument||document;l&&l.src&&(r=l.src.split(/[?#]/)[0].split("/").slice(0,-1).join("/")||"");for(var a=c.getElementsByTagName("script"),d=0;d<a.length;d++){var m=a[d],y=m.src||m.getAttribute("src");if(y){for(var b=m.attributes,E=0,S=b.length;E<S;E++){var C=b[E];C.name.indexOf("data-ace-")===0&&(o[s(C.name.replace(/^data-ace-/,""))]=C.value)}var $=y.match(/^(.*)\/ace([\-.]\w+)?\.js(\?|$)/);$&&(r=$[1])}}r&&(o.base=o.base||r,o.packaged=!0),o.basePath=o.base,o.workerPath=o.workerPath||o.base,o.modePath=o.modePath||o.base,o.themePath=o.themePath||o.base,delete o.base;for(var R in o)typeof o[R]<"u"&&u.set(R,o[R])}}function s(h){return h.replace(/-(.)/g,function(o,r){return r.toUpperCase()})}}),ace.define("ace/range",["require","exports","module"],function(n,i,p){var u=function(g,s){return g.row-s.row||g.column-s.column},f=function(){function g(s,h,o,r){this.start={row:s,column:h},this.end={row:o,column:r}}return g.prototype.isEqual=function(s){return this.start.row===s.start.row&&this.end.row===s.end.row&&this.start.column===s.start.column&&this.end.column===s.end.column},g.prototype.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},g.prototype.contains=function(s,h){return this.compare(s,h)==0},g.prototype.compareRange=function(s){var h,o=s.end,r=s.start;return h=this.compare(o.row,o.column),h==1?(h=this.compare(r.row,r.column),h==1?2:h==0?1:0):h==-1?-2:(h=this.compare(r.row,r.column),h==-1?-1:h==1?42:0)},g.prototype.comparePoint=function(s){return this.compare(s.row,s.column)},g.prototype.containsRange=function(s){return this.comparePoint(s.start)==0&&this.comparePoint(s.end)==0},g.prototype.intersects=function(s){var h=this.compareRange(s);return h==-1||h==0||h==1},g.prototype.isEnd=function(s,h){return this.end.row==s&&this.end.column==h},g.prototype.isStart=function(s,h){return this.start.row==s&&this.start.column==h},g.prototype.setStart=function(s,h){typeof s=="object"?(this.start.column=s.column,this.start.row=s.row):(this.start.row=s,this.start.column=h)},g.prototype.setEnd=function(s,h){typeof s=="object"?(this.end.column=s.column,this.end.row=s.row):(this.end.row=s,this.end.column=h)},g.prototype.inside=function(s,h){return this.compare(s,h)==0?!(this.isEnd(s,h)||this.isStart(s,h)):!1},g.prototype.insideStart=function(s,h){return this.compare(s,h)==0?!this.isEnd(s,h):!1},g.prototype.insideEnd=function(s,h){return this.compare(s,h)==0?!this.isStart(s,h):!1},g.prototype.compare=function(s,h){return!this.isMultiLine()&&s===this.start.row?h<this.start.column?-1:h>this.end.column?1:0:s<this.start.row?-1:s>this.end.row?1:this.start.row===s?h>=this.start.column?0:-1:this.end.row===s?h<=this.end.column?0:1:0},g.prototype.compareStart=function(s,h){return this.start.row==s&&this.start.column==h?-1:this.compare(s,h)},g.prototype.compareEnd=function(s,h){return this.end.row==s&&this.end.column==h?1:this.compare(s,h)},g.prototype.compareInside=function(s,h){return this.end.row==s&&this.end.column==h?1:this.start.row==s&&this.start.column==h?-1:this.compare(s,h)},g.prototype.clipRows=function(s,h){if(this.end.row>h)var o={row:h+1,column:0};else if(this.end.row<s)var o={row:s,column:0};if(this.start.row>h)var r={row:h+1,column:0};else if(this.start.row<s)var r={row:s,column:0};return g.fromPoints(r||this.start,o||this.end)},g.prototype.extend=function(s,h){var o=this.compare(s,h);if(o==0)return this;if(o==-1)var r={row:s,column:h};else var l={row:s,column:h};return g.fromPoints(r||this.start,l||this.end)},g.prototype.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},g.prototype.isMultiLine=function(){return this.start.row!==this.end.row},g.prototype.clone=function(){return g.fromPoints(this.start,this.end)},g.prototype.collapseRows=function(){return this.end.column==0?new g(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new g(this.start.row,0,this.end.row,0)},g.prototype.toScreenRange=function(s){var h=s.documentToScreenPosition(this.start),o=s.documentToScreenPosition(this.end);return new g(h.row,h.column,o.row,o.column)},g.prototype.moveBy=function(s,h){this.start.row+=s,this.start.column+=h,this.end.row+=s,this.end.column+=h},g}();f.fromPoints=function(g,s){return new f(g.row,g.column,s.row,s.column)},f.comparePoints=u,f.comparePoints=function(g,s){return g.row-s.row||g.column-s.column},i.Range=f}),ace.define("ace/lib/keys",["require","exports","module","ace/lib/oop"],function(n,i,p){/*! @license
|
944
944
|
==========================================================================
|
945
945
|
SproutCore -- JavaScript Application Framework
|
946
946
|
copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors.
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
7
7
|
<link rel="icon" href="/favicon.ico" />
|
8
8
|
<title>Mihari</title>
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
9
|
+
<script type="module" crossorigin src="/assets/index-a92abd57.js"></script>
|
10
10
|
<link rel="stylesheet" href="/assets/index-33165282.css">
|
11
11
|
</head>
|
12
12
|
<body>
|