pulsedive 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/Gemfile +3 -1
- data/README.md +5 -14
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/exe/pulsedive +2 -1
- data/lib/pulsedive.rb +2 -0
- data/lib/pulsedive/analyze.rb +3 -1
- data/lib/pulsedive/api.rb +19 -9
- data/lib/pulsedive/cli.rb +4 -3
- data/lib/pulsedive/client.rb +17 -19
- data/lib/pulsedive/error.rb +2 -0
- data/lib/pulsedive/feed.rb +3 -1
- data/lib/pulsedive/indicator.rb +4 -3
- data/lib/pulsedive/search.rb +3 -1
- data/lib/pulsedive/threat.rb +2 -0
- data/lib/pulsedive/version.rb +3 -1
- data/pulsedive.gemspec +10 -10
- metadata +15 -46
- data/.codeclimae.yml +0 -13
- data/lib/pulsedive/response.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b27042cde7526ac9b1425a8fe2f1872213870eec3fabbd7cdc38c54f0f5201
|
4
|
+
data.tar.gz: f4f06366ca8ffec1014dd14c3635d1cbf9d2df985d153bc3104eef58b1dd2a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9858214f93918781493fc9c92cba8f01170540738ed1074bf608c28d140610b6f11abbff81fcfc7278a39ce28b162c45097aa8b62b88246757b44a3485ef023
|
7
|
+
data.tar.gz: ecf6313b4d80e6527de5979032d256a317642657c4a63d7ed0c7316100ee906f4606ab312837197442b2de555d205af50fbc8b0df45cff0b9a0cb648be23e9e6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in pulsedive.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -1,27 +1,18 @@
|
|
1
1
|
# pulsedive-rb
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/pulsedive.svg)](https://badge.fury.io/rb/pulsedive)
|
3
4
|
[![Build Status](https://travis-ci.org/ninoseki/pulsedive-rb.svg?branch=master)](https://travis-ci.org/ninoseki/pulsedive-rb)
|
4
|
-
[![
|
5
|
+
[![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/pulsedive-rb/badge)](https://www.codefactor.io/repository/github/ninoseki/pulsedive-rb)
|
5
6
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/pulsedive-rb/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/pulsedive-rb?branch=master)
|
6
7
|
|
7
|
-
|
8
|
+
[Pulsedive](https://pulsedive.com/) API wrapper for Ruby.
|
8
9
|
|
9
10
|
## Installation
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
gem 'pulsedive'
|
12
|
+
```bash
|
13
|
+
gem install pulsedive
|
15
14
|
```
|
16
15
|
|
17
|
-
And then execute:
|
18
|
-
|
19
|
-
$ bundle
|
20
|
-
|
21
|
-
Or install it yourself as:
|
22
|
-
|
23
|
-
$ gem install pulsedive
|
24
|
-
|
25
16
|
## Usage
|
26
17
|
|
27
18
|
### As a Library
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/exe/pulsedive
CHANGED
data/lib/pulsedive.rb
CHANGED
data/lib/pulsedive/analyze.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "base64"
|
2
4
|
|
3
5
|
module Pulsedive
|
4
6
|
class Analyze < Client
|
5
|
-
def add_to_queue(ioc, enrich
|
7
|
+
def add_to_queue(ioc, enrich: 1, probe: 1)
|
6
8
|
params = {
|
7
9
|
"ioc": Base64.strict_encode64(ioc),
|
8
10
|
"enrich": enrich,
|
data/lib/pulsedive/api.rb
CHANGED
@@ -1,19 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pulsedive
|
2
4
|
class API
|
3
|
-
|
4
5
|
attr_reader :api_key
|
5
|
-
attr_reader :indicator
|
6
|
-
attr_reader :threat
|
7
|
-
attr_reader :feed
|
8
|
-
attr_reader :analyze
|
9
6
|
|
10
7
|
def initialize(api_key = ENV["PULSEDIVE_API_KEY"])
|
11
8
|
raise(ArgumentError, "'api_key' argument is required") unless api_key
|
12
9
|
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
@api_key = api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def indicator
|
14
|
+
@indicator ||= Indicator.new(api_key)
|
15
|
+
end
|
16
|
+
|
17
|
+
def threat
|
18
|
+
@threat ||= Threat.new(api_key)
|
19
|
+
end
|
20
|
+
|
21
|
+
def feed
|
22
|
+
@feed ||= Feed.new(api_key)
|
23
|
+
end
|
24
|
+
|
25
|
+
def analyze
|
26
|
+
@analyze ||= Analyze.new(api_key)
|
17
27
|
end
|
18
28
|
|
19
29
|
def search(params)
|
data/lib/pulsedive/cli.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "thor"
|
2
4
|
require "json"
|
3
5
|
|
4
6
|
module Pulsedive
|
5
7
|
module CLI
|
6
8
|
class Base < Thor
|
7
|
-
|
8
9
|
class_option :API_KEY, type: :string
|
9
10
|
|
10
11
|
no_commands do
|
@@ -16,7 +17,7 @@ module Pulsedive
|
|
16
17
|
yield
|
17
18
|
rescue ResponseError => e
|
18
19
|
puts "Warning: #{e}"
|
19
|
-
rescue ArgumentError =>
|
20
|
+
rescue ArgumentError => _e
|
20
21
|
puts "Please provide your Pulsedive API key via --API_KEY or ENV['PULSEDIVE_API_KEY']"
|
21
22
|
end
|
22
23
|
end
|
@@ -116,7 +117,7 @@ module Pulsedive
|
|
116
117
|
enrich = options[:enrich] || 1
|
117
118
|
probe = options[:probe] || 1
|
118
119
|
with_error_handling do
|
119
|
-
json = api.analyze.add_to_queue(ioc, enrich, probe)
|
120
|
+
json = api.analyze.add_to_queue(ioc, enrich: enrich, probe: probe)
|
120
121
|
puts JSON.pretty_generate(json)
|
121
122
|
end
|
122
123
|
end
|
data/lib/pulsedive/client.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "net/https"
|
4
|
+
require "uri"
|
4
5
|
|
5
6
|
module Pulsedive
|
6
7
|
class Client
|
7
|
-
|
8
8
|
attr_reader :api_key
|
9
9
|
|
10
|
-
HOST = "pulsedive.com"
|
11
|
-
URL = "https://#{HOST}"
|
10
|
+
HOST = "pulsedive.com"
|
11
|
+
URL = "https://#{HOST}"
|
12
12
|
|
13
13
|
def initialize(api_key)
|
14
14
|
@api_key = api_key
|
@@ -24,8 +24,8 @@ module Pulsedive
|
|
24
24
|
if proxy = ENV["HTTPS_PROXY"] || ENV["https_proxy"]
|
25
25
|
uri = URI(proxy)
|
26
26
|
{
|
27
|
-
proxy_address:
|
28
|
-
proxy_port:
|
27
|
+
proxy_address: uri.hostname,
|
28
|
+
proxy_port: uri.port,
|
29
29
|
proxy_from_env: false,
|
30
30
|
use_ssl: true
|
31
31
|
}
|
@@ -37,16 +37,14 @@ module Pulsedive
|
|
37
37
|
def request(req)
|
38
38
|
Net::HTTP.start(HOST, 443, https_options) do |http|
|
39
39
|
response = http.request(req)
|
40
|
-
if response.code
|
41
|
-
|
42
|
-
if json["error"]
|
43
|
-
raise(ResponseError, json["error"])
|
44
|
-
else
|
45
|
-
yield json
|
46
|
-
end
|
47
|
-
else
|
48
|
-
raise(ResponseError, "unsupported response code returned: #{response.code}")
|
40
|
+
if response.code != "200"
|
41
|
+
raise(ResponseError, "Unsupported response code returned: #{response.code}")
|
49
42
|
end
|
43
|
+
|
44
|
+
json = JSON.parse(response.body)
|
45
|
+
raise(ResponseError, json["error"]) if json["error"]
|
46
|
+
|
47
|
+
yield json
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
@@ -54,12 +52,12 @@ module Pulsedive
|
|
54
52
|
params["key"] = api_key
|
55
53
|
|
56
54
|
url = url_for(path)
|
57
|
-
url.query = params
|
55
|
+
url.query = URI.encode_www_form(params)
|
58
56
|
get = Net::HTTP::Get.new(url)
|
59
57
|
request(get, &block)
|
60
58
|
end
|
61
59
|
|
62
|
-
def post(path, params
|
60
|
+
def post(path, params, &block)
|
63
61
|
params["key"] = api_key
|
64
62
|
|
65
63
|
post = Net::HTTP::Post.new(url_for(path))
|
data/lib/pulsedive/error.rb
CHANGED
data/lib/pulsedive/feed.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pulsedive
|
2
4
|
class Feed < Client
|
3
5
|
def get_by_id(fid)
|
@@ -7,7 +9,7 @@ module Pulsedive
|
|
7
9
|
get("/api/info.php", params) { |json| json }
|
8
10
|
end
|
9
11
|
|
10
|
-
def get_linked_indicators_by_id(fid, page
|
12
|
+
def get_linked_indicators_by_id(fid, page: 0)
|
11
13
|
params = {
|
12
14
|
"fid": fid,
|
13
15
|
"get": "links",
|
data/lib/pulsedive/indicator.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pulsedive
|
2
4
|
class Indicator < Client
|
3
|
-
|
4
|
-
def get_by_id(iid, schema = 1)
|
5
|
+
def get_by_id(iid, schema: 1)
|
5
6
|
params = {
|
6
7
|
"iid": iid,
|
7
8
|
"schema": schema
|
@@ -16,7 +17,7 @@ module Pulsedive
|
|
16
17
|
get("/api/info.php", params) { |json| json }
|
17
18
|
end
|
18
19
|
|
19
|
-
def get_links_by_id(iid, page
|
20
|
+
def get_links_by_id(iid, page: 0)
|
20
21
|
params = {
|
21
22
|
"iid": iid,
|
22
23
|
"get": "links",
|
data/lib/pulsedive/search.rb
CHANGED
data/lib/pulsedive/threat.rb
CHANGED
data/lib/pulsedive/version.rb
CHANGED
data/pulsedive.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "pulsedive/version"
|
4
6
|
|
@@ -15,21 +17,19 @@ Gem::Specification.new do |spec|
|
|
15
17
|
|
16
18
|
# Specify which files should be added to the gem when it is released.
|
17
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path(
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
22
|
end
|
21
23
|
spec.bindir = "exe"
|
22
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
25
|
spec.require_paths = ["lib"]
|
24
26
|
|
25
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "
|
29
|
-
spec.add_development_dependency "
|
30
|
-
spec.add_development_dependency "
|
31
|
-
spec.add_development_dependency "webmock", "~> 3.4"
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
31
|
+
spec.add_development_dependency "vcr", "~> 5.0"
|
32
|
+
spec.add_development_dependency "webmock", "~> 3.7"
|
32
33
|
|
33
|
-
spec.add_runtime_dependency "
|
34
|
-
spec.add_runtime_dependency "thor", "~> 0.19"
|
34
|
+
spec.add_runtime_dependency "thor", "~> 0.20"
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulsedive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
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: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,104 +38,76 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dotenv
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.5'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.5'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '13.0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '13.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
61
|
+
version: '3.9'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
68
|
+
version: '3.9'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: vcr
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '5.0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '5.0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
89
|
+
version: '3.7'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3.
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: activesupport
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '5.2'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '5.2'
|
96
|
+
version: '3.7'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: thor
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
128
100
|
requirements:
|
129
101
|
- - "~>"
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
103
|
+
version: '0.20'
|
132
104
|
type: :runtime
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
136
108
|
- - "~>"
|
137
109
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
110
|
+
version: '0.20'
|
139
111
|
description: Ruby library for Pulsedive API
|
140
112
|
email:
|
141
113
|
- manabu.niseki@gmail.com
|
@@ -144,7 +116,6 @@ executables:
|
|
144
116
|
extensions: []
|
145
117
|
extra_rdoc_files: []
|
146
118
|
files:
|
147
|
-
- ".codeclimae.yml"
|
148
119
|
- ".gitignore"
|
149
120
|
- ".rspec"
|
150
121
|
- ".travis.yml"
|
@@ -164,7 +135,6 @@ files:
|
|
164
135
|
- lib/pulsedive/error.rb
|
165
136
|
- lib/pulsedive/feed.rb
|
166
137
|
- lib/pulsedive/indicator.rb
|
167
|
-
- lib/pulsedive/response.rb
|
168
138
|
- lib/pulsedive/search.rb
|
169
139
|
- lib/pulsedive/threat.rb
|
170
140
|
- lib/pulsedive/version.rb
|
@@ -188,8 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
158
|
- !ruby/object:Gem::Version
|
189
159
|
version: '0'
|
190
160
|
requirements: []
|
191
|
-
|
192
|
-
rubygems_version: 2.7.6
|
161
|
+
rubygems_version: 3.0.3
|
193
162
|
signing_key:
|
194
163
|
specification_version: 4
|
195
164
|
summary: Ruby library for Pulsedive API
|
data/.codeclimae.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
|
2
|
-
version: "2"
|
3
|
-
prepare:
|
4
|
-
fetch:
|
5
|
-
- url: "https://raw.githubusercontent.com/janlelis/relaxed.ruby.style/master/.rubocop.yml"
|
6
|
-
path: "alternate-rubocop-path.yml"
|
7
|
-
plugins:
|
8
|
-
rubocop:
|
9
|
-
enabled: true
|
10
|
-
config:
|
11
|
-
file: "alternate-rubocop-path.yml"
|
12
|
-
exclude_patterns:
|
13
|
-
- "spec/**/*"
|