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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c64c50eef43387533567d006b5a7cc5d91e9756c828d8c2abb0c71fb7cdfd8a0
4
- data.tar.gz: 9804b57e3aa1e639af02f6d251572fde399e244a4978fd215de652451c9301b9
3
+ metadata.gz: 22f4d64dfca8b7ee22806108031b47a532dd3968e60afa641352c4a471647c51
4
+ data.tar.gz: a5b30512b61221b181e60e6712d327d92de34879b0268ea10b53cb2e0feb2748
5
5
  SHA512:
6
- metadata.gz: f314f8dc01685bc52b4d4e0546cdf121ad26c82615c7021f2eb4341ed034dc4ee2ec6e00970e2749419baccf00991ae6aea92ead472b1ff335a25492d537ac3d
7
- data.tar.gz: 9466cdb9855100e645554851697128a7df854afc1bb1fd34b6561e4ea1eb0d137457b43f694a88dbdd7047cdbcf7b42431774a081357c27717f080ec382c2d7e
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
- [![Build Status](https://travis-ci.org/ninoseki/urlscan.svg?branch=master)](https://travis-ci.org/ninoseki/urlscan)
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
- Ruby API client for [urlscan.io](https://urlscan.io/).
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, is_public = true)` |
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, offset: 0, sort: "_score")` |
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 | API method |
54
- |-------------|---------|-------------------------------------------------------------------|
55
- | GET | /search | `UrlScan::Clients::Pro#search(query: nil, filter: nil, size: 50)` |
56
- | GET | /brands | `UrlScan::Clients::Pro#brands` |
57
- | GET | /kits | `UrlScan::Clients::Pro#kits` |
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
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UrlScan
4
- class CLI < Commands::Community
5
- desc "pro", "PRO api commands"
6
- subcommand "pro", Commands::Pro
7
- end
4
+ class CLI < Commands::Community; end
8
5
  end
@@ -18,7 +18,7 @@ module UrlScan
18
18
  private
19
19
 
20
20
  def url
21
- @url ||= "https://#{self.class::HOST}/api/v#{self.class::VERSION}"
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 auth_header
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
- get = Net::HTTP::Get.new(url_for(path))
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), auth_header)
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, is_public = true)
8
- raise ArgumentError, "API key is required for this method." if key.nil?
9
-
10
- params = { url: url, public: is_public ? "on" : "off" }
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, offset: 0, sort: "_score")
30
- params = { q: q, size: size, offset: offset, sort: sort }
31
- query = URI.encode_www_form(params)
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
@@ -4,32 +4,41 @@ module UrlScan
4
4
  module Clients
5
5
  class Pro < Base
6
6
  VERSION = 1
7
- HOST = "pro.urlscan.com"
7
+ HOST = "urlscan.io"
8
8
 
9
9
  # @return [Hash]
10
- def search(query: nil, filter: nil, size: 50)
11
- raise ArgumentError, "API key is required for this method." if key.nil?
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 brands
23
- raise ArgumentError, "API key is required for this method." if key.nil?
15
+ def kits
16
+ get("/kits") { |json| json }
17
+ end
24
18
 
25
- get("/brands") { |json| json }
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 kits
30
- raise ArgumentError, "API key is required for this method." if key.nil?
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
- get("/kits") { |json| json }
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://#{self.class::HOST}/api/v#{self.class::VERSION}/pro"
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 :public, type: :boolean, default: true
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(url, options[:public])
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 :offset, type: :numeric, default: 0
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"], offset: options["offset"], sort: options["sort"])
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UrlScan
4
- VERSION = "0.4.1"
4
+ VERSION = "0.8.0"
5
5
  end
data/lib/urlscan.rb CHANGED
@@ -9,7 +9,6 @@ require "urlscan/clients/pro"
9
9
 
10
10
  require "urlscan/commands/base"
11
11
  require "urlscan/commands/community"
12
- require "urlscan/commands/pro"
13
12
 
14
13
  require "urlscan/api"
15
14
  require "urlscan/cli"
data/renovate.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
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.0"
25
- spec.add_development_dependency "coveralls", "~> 0.8"
26
- spec.add_development_dependency "rake", "~> 12.3"
27
- spec.add_development_dependency "rspec", "~> 3.8"
28
- spec.add_development_dependency "vcr", "~> 5.0"
29
- spec.add_development_dependency "webmock", "~> 3.7"
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", "~> 0.20"
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.1
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: 2019-09-19 00:00:00.000000000 Z
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.0'
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.0'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: coveralls
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.8'
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.8'
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: '12.3'
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: '12.3'
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.8'
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.8'
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: '5.0'
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: '5.0'
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.7'
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.7'
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: '0.20'
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: '0.20'
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.0.4
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
@@ -1,9 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5
6
- - 2.6
7
- before_install:
8
- - gem update --system
9
- - gem install bundler
@@ -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