urlscan 0.4.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +23 -0
- data/README.md +15 -26
- data/lib/urlscan/cli.rb +1 -4
- data/lib/urlscan/clients/base.rb +9 -6
- data/lib/urlscan/clients/community.rb +13 -8
- data/lib/urlscan/clients/pro.rb +26 -22
- data/lib/urlscan/commands/community.rb +17 -5
- data/lib/urlscan/version.rb +1 -1
- data/lib/urlscan.rb +0 -1
- data/renovate.json +5 -0
- data/urlscan.gemspec +7 -7
- metadata +24 -24
- data/.travis.yml +0 -9
- data/lib/urlscan/commands/pro.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22f4d64dfca8b7ee22806108031b47a532dd3968e60afa641352c4a471647c51
|
4
|
+
data.tar.gz: a5b30512b61221b181e60e6712d327d92de34879b0268ea10b53cb2e0feb2748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41fc1f52104b46aa979e822bd11618888dcadefd0bdbfab98d8428621dad1583945cbcb3b80271f4db72023307bea6283bacc830963ba2941e7afde81d6e6ea
|
7
|
+
data.tar.gz: 829b96a975ac28e5417594e67644bc9578cd48c24ce92e349007a3f427659de05dbaa8e355da4c6b1f07458062efe06117a5c45e44bc74246fadac762209c54f
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on: [pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby: [2.7, "3.0"]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler-cache: true
|
21
|
+
- name: Build and test with Rake
|
22
|
+
run: |
|
23
|
+
bundle exec rake
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# urlscan
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/urlscan.svg)](https://badge.fury.io/rb/urlscan)
|
4
|
-
[![
|
4
|
+
[![Ruby CI](https://github.com/ninoseki/urlscan/actions/workflows/test.yml/badge.svg)](https://github.com/ninoseki/urlscan/actions/workflows/test.yml)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/c6625486f2d57039adef/maintainability)](https://codeclimate.com/github/ninoseki/urlscan/maintainability)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/urlscan/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/urlscan?branch=master)
|
7
7
|
|
8
8
|
## Description
|
9
9
|
|
10
|
-
|
10
|
+
[urlscan.io](https://urlscan.io/) API wrapper for Ruby.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -40,21 +40,22 @@ res = api.search("wikipedia.org")
|
|
40
40
|
|
41
41
|
## Supported API endpoints
|
42
42
|
|
43
|
-
| HTTP Method | URI | API method
|
44
|
-
|
45
|
-
| POST | /scan | `UrlScan::Clients::Community#submit(url,
|
46
|
-
| GET | /result/`uuid`/ | `UrlScan::Clients::Community#result(uuid)`
|
47
|
-
| GET | /dom/`uuid`/ | `UrlScan::Clients::Community#dom(uuid)`
|
48
|
-
| GET | /screenshots/`uuid`.png | `UrlScan::Clients::Community#screenshot(uuid)`
|
49
|
-
| GET | /search | `UrlScan::Clients::Community#search(q, size: 100,
|
43
|
+
| HTTP Method | URI | API method |
|
44
|
+
|-------------|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
|
45
|
+
| POST | /scan | `UrlScan::Clients::Community#submit(url, customagent: nil, referer: nil, visibility: nil, tags: nil, override_safety: nil, country: nil))` |
|
46
|
+
| GET | /result/`uuid`/ | `UrlScan::Clients::Community#result(uuid)` |
|
47
|
+
| GET | /dom/`uuid`/ | `UrlScan::Clients::Community#dom(uuid)` |
|
48
|
+
| GET | /screenshots/`uuid`.png | `UrlScan::Clients::Community#screenshot(uuid)` |
|
49
|
+
| GET | /search | `UrlScan::Clients::Community#search(q, size: 100, search_after: nil)` |
|
50
50
|
|
51
51
|
### Pro
|
52
52
|
|
53
|
-
| HTTP Method | URI
|
54
|
-
|
55
|
-
| GET | /
|
56
|
-
| GET | /
|
57
|
-
| GET | /
|
53
|
+
| HTTP Method | URI | API method |
|
54
|
+
|-------------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
|
55
|
+
| GET | /brands | `UrlScan::Clients::Pro#brands` |
|
56
|
+
| GET | /kits | `UrlScan::Clients::Pro#kits` |
|
57
|
+
| GET | /phishfeed | `UrlScan::Clients::Pro#phishfeed(q: "result.task.time:>now-24h", format: "json", limit: ni)` |
|
58
|
+
| GET | /result/`uuid`/similar/ | `UrlScan::Clients::Pro#similar(uuid, q: nil, size: nil, search_after: nil, threshold: nil, min_size: nil, method: nil, resource_types: nil))` |
|
58
59
|
|
59
60
|
## CLI usage
|
60
61
|
|
@@ -72,15 +73,3 @@ Options:
|
|
72
73
|
[--API-KEY=API_KEY]
|
73
74
|
|
74
75
|
```
|
75
|
-
|
76
|
-
### Pro
|
77
|
-
|
78
|
-
```bash
|
79
|
-
$ urlscan pro
|
80
|
-
Commands:
|
81
|
-
urlscan pro help [COMMAND] # Describe subcommands or one specific subcommand
|
82
|
-
urlscan pro search # search for scans
|
83
|
-
|
84
|
-
Options:
|
85
|
-
[--API-KEY=API_KEY]
|
86
|
-
```
|
data/lib/urlscan/cli.rb
CHANGED
data/lib/urlscan/clients/base.rb
CHANGED
@@ -18,7 +18,7 @@ module UrlScan
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def url
|
21
|
-
@url ||= "https://#{
|
21
|
+
@url ||= "https://#{HOST}/api/v#{VERSION}"
|
22
22
|
end
|
23
23
|
|
24
24
|
def url_for(path)
|
@@ -61,17 +61,20 @@ module UrlScan
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
{ "API-KEY": key }
|
64
|
+
def default_headers
|
65
|
+
@default_headers ||= { "API-KEY": key }.compact
|
66
66
|
end
|
67
67
|
|
68
|
-
def get(path, &block)
|
69
|
-
|
68
|
+
def get(path, params = {}, &block)
|
69
|
+
uri = url_for(path)
|
70
|
+
uri.query = URI.encode_www_form(params)
|
71
|
+
|
72
|
+
get = Net::HTTP::Get.new(uri, default_headers)
|
70
73
|
request(get, &block)
|
71
74
|
end
|
72
75
|
|
73
76
|
def post(path, json, &block)
|
74
|
-
post = Net::HTTP::Post.new(url_for(path),
|
77
|
+
post = Net::HTTP::Post.new(url_for(path), default_headers)
|
75
78
|
post.content_type = "application/json"
|
76
79
|
post.body = json.to_json
|
77
80
|
|
@@ -4,10 +4,16 @@ module UrlScan
|
|
4
4
|
module Clients
|
5
5
|
class Community < Base
|
6
6
|
# @return [Hash]
|
7
|
-
def submit(url,
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def submit(url, customagent: nil, referer: nil, visibility: nil, tags: nil, override_safety: nil, country: nil)
|
8
|
+
params = {
|
9
|
+
url: url,
|
10
|
+
customagent: customagent,
|
11
|
+
referer: referer,
|
12
|
+
visibility: visibility,
|
13
|
+
tags: tags,
|
14
|
+
overrideSafety: override_safety,
|
15
|
+
country: country
|
16
|
+
}.compact
|
11
17
|
post("/scan/", params) { |json| json }
|
12
18
|
end
|
13
19
|
|
@@ -26,10 +32,9 @@ module UrlScan
|
|
26
32
|
end
|
27
33
|
|
28
34
|
# @return [Hash]
|
29
|
-
def search(q, size: 100,
|
30
|
-
params = { q: q, size: size,
|
31
|
-
|
32
|
-
get("/search/?#{query}") { |json| json }
|
35
|
+
def search(q, size: 100, search_after: nil)
|
36
|
+
params = { q: q, size: size, search_after: search_after }.compact
|
37
|
+
get("/search/", params) { |json| json }
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
data/lib/urlscan/clients/pro.rb
CHANGED
@@ -4,32 +4,41 @@ module UrlScan
|
|
4
4
|
module Clients
|
5
5
|
class Pro < Base
|
6
6
|
VERSION = 1
|
7
|
-
HOST = "
|
7
|
+
HOST = "urlscan.io"
|
8
8
|
|
9
9
|
# @return [Hash]
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
filter = build_filter(filter)
|
14
|
-
params = { q: query, size: size }.compact
|
15
|
-
uri_query = URI.encode_www_form(params)
|
16
|
-
uri_query << "&filter=#{filter}" if filter
|
17
|
-
|
18
|
-
get("/search?#{uri_query}") { |json| json }
|
10
|
+
def brands
|
11
|
+
get("/brands") { |json| json }
|
19
12
|
end
|
20
13
|
|
21
14
|
# @return [Hash]
|
22
|
-
def
|
23
|
-
|
15
|
+
def kits
|
16
|
+
get("/kits") { |json| json }
|
17
|
+
end
|
24
18
|
|
25
|
-
|
19
|
+
# @return [Hash]
|
20
|
+
def phishfeed(q: "result.task.time:>now-24h", format: "json", limit: nil)
|
21
|
+
params = { q: q, format: format, limit: limit }.compact
|
22
|
+
get("/phishfeed", params) { |json| json }
|
26
23
|
end
|
27
24
|
|
28
25
|
# @return [Hash]
|
29
|
-
def
|
30
|
-
|
26
|
+
def similar(uuid, q: nil, size: nil, search_after: nil, threshold: nil, min_size: nil, method: nil, resource_types: nil)
|
27
|
+
params = {
|
28
|
+
q: q,
|
29
|
+
size: size,
|
30
|
+
search_after: search_after,
|
31
|
+
threshold: threshold,
|
32
|
+
minSize: min_size,
|
33
|
+
method: method,
|
34
|
+
resourceTypes: resource_types
|
35
|
+
}.compact
|
36
|
+
get("/result/#{uuid}/similar/", params) { |json| json }
|
37
|
+
end
|
31
38
|
|
32
|
-
|
39
|
+
# @return [Hash]
|
40
|
+
def scanners
|
41
|
+
get("/livescan/scanners/") { |json| json }
|
33
42
|
end
|
34
43
|
|
35
44
|
private
|
@@ -41,12 +50,7 @@ module UrlScan
|
|
41
50
|
end
|
42
51
|
|
43
52
|
def url
|
44
|
-
@url ||= "https://#{
|
45
|
-
end
|
46
|
-
|
47
|
-
def get(path, &block)
|
48
|
-
get = Net::HTTP::Get.new(url_for(path), auth_header)
|
49
|
-
request(get, &block)
|
53
|
+
@url ||= "https://#{HOST}/api/v#{VERSION}/pro"
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
@@ -4,10 +4,23 @@ module UrlScan
|
|
4
4
|
module Commands
|
5
5
|
class Community < Base
|
6
6
|
desc "submit [URL]", "submit a scan to [URL]"
|
7
|
-
method_option :
|
7
|
+
method_option :customagent, type: :string
|
8
|
+
method_option :referer, type: :string
|
9
|
+
method_option :visibility, type: :string
|
10
|
+
method_option :tags, type: :array
|
11
|
+
method_option :override_safety, type: :string
|
12
|
+
method_option :country, type: :string
|
8
13
|
def submit(url)
|
9
14
|
with_error_handling do
|
10
|
-
res = api.submit(
|
15
|
+
res = api.submit(
|
16
|
+
url,
|
17
|
+
customagent: options[:customagent],
|
18
|
+
referer: options[:referer],
|
19
|
+
visibility: options[:visibility],
|
20
|
+
tags: options[:tags],
|
21
|
+
override_safety: options[:override_safety],
|
22
|
+
country: options[:country]
|
23
|
+
)
|
11
24
|
puts JSON.pretty_generate(res)
|
12
25
|
end
|
13
26
|
end
|
@@ -22,11 +35,10 @@ module UrlScan
|
|
22
35
|
|
23
36
|
desc "search [QUERY]", "search for scans by [QUERY]"
|
24
37
|
method_option :size, type: :numeric, default: 100
|
25
|
-
method_option :
|
26
|
-
method_option :sort, type: :string, default: "_score"
|
38
|
+
method_option :search_after, type: :string
|
27
39
|
def search(query)
|
28
40
|
with_error_handling do
|
29
|
-
res = api.search(query, size: options["size"],
|
41
|
+
res = api.search(query, size: options["size"], search_after: options["search_after"])
|
30
42
|
puts JSON.pretty_generate(res)
|
31
43
|
end
|
32
44
|
end
|
data/lib/urlscan/version.rb
CHANGED
data/lib/urlscan.rb
CHANGED
data/urlscan.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 2.
|
25
|
-
spec.add_development_dependency "
|
26
|
-
spec.add_development_dependency "rake", "~>
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
28
|
-
spec.add_development_dependency "vcr", "~>
|
29
|
-
spec.add_development_dependency "webmock", "~> 3.
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
25
|
+
spec.add_development_dependency "coveralls_reborn", "~> 0.23"
|
26
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
28
|
+
spec.add_development_dependency "vcr", "~> 6.0"
|
29
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
30
30
|
|
31
|
-
spec.add_runtime_dependency "thor", "~>
|
31
|
+
spec.add_runtime_dependency "thor", "~> 1.1"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urlscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,99 +16,99 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: coveralls_reborn
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.23'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.23'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '6.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '6.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.14'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.14'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: thor
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
-
description:
|
110
|
+
version: '1.1'
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- manabu.niseki@gmail.com
|
114
114
|
executables:
|
@@ -117,10 +117,10 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- ".codeclimate.yml"
|
120
|
+
- ".github/workflows/test.yml"
|
120
121
|
- ".gitignore"
|
121
122
|
- ".rspec"
|
122
123
|
- ".rubocop.yml"
|
123
|
-
- ".travis.yml"
|
124
124
|
- Gemfile
|
125
125
|
- LICENSE
|
126
126
|
- README.md
|
@@ -134,15 +134,15 @@ files:
|
|
134
134
|
- lib/urlscan/clients/pro.rb
|
135
135
|
- lib/urlscan/commands/base.rb
|
136
136
|
- lib/urlscan/commands/community.rb
|
137
|
-
- lib/urlscan/commands/pro.rb
|
138
137
|
- lib/urlscan/exceptions.rb
|
139
138
|
- lib/urlscan/version.rb
|
139
|
+
- renovate.json
|
140
140
|
- urlscan.gemspec
|
141
141
|
homepage: https://github.com/ninoseki/urlscan
|
142
142
|
licenses:
|
143
143
|
- MIT
|
144
144
|
metadata: {}
|
145
|
-
post_install_message:
|
145
|
+
post_install_message:
|
146
146
|
rdoc_options: []
|
147
147
|
require_paths:
|
148
148
|
- lib
|
@@ -157,8 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
-
signing_key:
|
160
|
+
rubygems_version: 3.2.14
|
161
|
+
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Ruby API client for urlscan.io
|
164
164
|
test_files: []
|
data/.travis.yml
DELETED
data/lib/urlscan/commands/pro.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UrlScan
|
4
|
-
module Commands
|
5
|
-
class Pro < Base
|
6
|
-
desc "search", "search for scans"
|
7
|
-
method_option :size, type: :numeric, default: 50
|
8
|
-
method_option :query, type: :string
|
9
|
-
method_option :filter, type: :string
|
10
|
-
def search
|
11
|
-
with_error_handling do
|
12
|
-
res = api.pro.search(query: options["query"], filter: options["filter"], size: options["size"])
|
13
|
-
puts JSON.pretty_generate(res)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|