misp 0.1.1 → 0.1.2

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: 3be99f0060b369edec33cbfd1f8451ecfdd1d3c4942091087473abdc96579fc8
4
- data.tar.gz: eb6d2f9fe09fd030f6cf0f4e9f73e4b19d650809c3f0121c29b9de2b421fb97c
3
+ metadata.gz: 5d6567e8d9336fb5b0cc67fcc200ed9d4865c3b2ad9ec533842b8d87477e17fc
4
+ data.tar.gz: ca93f9e4643ef0e89fc1e1e87e377b60843d30f8de291d34b12582ee8197a85f
5
5
  SHA512:
6
- metadata.gz: b0659e4345163616f8ad38fd43a391ab3f9921c0cf4d5e926ac74bda7b13762cbaca7f5518041e67795b9518c63a81945f503e54e25d4c8e37e14801e41a3335
7
- data.tar.gz: 2e85ada078b9b82eb9221cec0d0b012d731c0dd082b147306f7c0b69a473aa583ac98153c882ba51e6a072fce26d348f607a1178515cca38395624d5db59d7e3
6
+ metadata.gz: f0030178281eca5c3cbe1f13d7c8ed21360735ea5d9127b2915ea315f16b6c4a739e4e7dd3b8f56c99f89e4d6a046c93a4823f630a4f25d3181a2c4a1976b39b
7
+ data.tar.gz: 9c863d088be6efc8c84339c2d553a70b238ce078ab7ba3a89957ad9b7c953aa7fa51ea1ab70e3a08a4bbc94ffed04ba273200ee3a12eefc7354f49899fe8b0df
data/.travis.yml CHANGED
@@ -4,4 +4,5 @@ language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
6
  - 2.6
7
- before_install: gem install bundler -v 2.0.2
7
+ - 2.7
8
+ before_install: gem install bundler -v 2.1
@@ -39,7 +39,7 @@ module MISP
39
39
  attr_accessor :tags
40
40
 
41
41
  def initialize(**attributes)
42
- attributes = normalize_attributes(attributes)
42
+ attributes = normalize_attributes(**attributes)
43
43
 
44
44
  @id = attributes.dig(:id)
45
45
  @type = attributes.dig(:type)
@@ -112,7 +112,7 @@ module MISP
112
112
  # @return [MISP::Attribute]
113
113
  #
114
114
  def create(event_id)
115
- _post("/attributes/add/#{event_id}", wrap(to_h)) { |attribute| Attribute.new attribute }
115
+ _post("/attributes/add/#{event_id}", wrap(to_h)) { |attribute| Attribute.new(**attribute) }
116
116
  end
117
117
 
118
118
  #
@@ -125,7 +125,7 @@ module MISP
125
125
  def update(**attrs)
126
126
  payload = to_h.merge(attrs)
127
127
  payload[:timestamp] = nil
128
- _post("/attributes/edit/#{id}", wrap(payload)) { |json| Attribute.new json.dig(:response, :Attribute) }
128
+ _post("/attributes/edit/#{id}", wrap(payload)) { |json| Attribute.new(**json.dig(:response, :Attribute)) }
129
129
  end
130
130
 
131
131
  #
@@ -144,7 +144,7 @@ module MISP
144
144
 
145
145
  _post("/attributes/restSearch", base.merge(params)) do |json|
146
146
  attributes = json.dig(:response, :Attribute) || []
147
- attributes.map { |attribute| Attribute.new attribute }
147
+ attributes.map { |attribute| Attribute.new(**attribute) }
148
148
  end
149
149
  end
150
150
 
@@ -158,7 +158,7 @@ module MISP
158
158
  def add_tag(tag)
159
159
  tag = Tag.new(tag) unless tag.is_a?(MISP::Tag)
160
160
  payload = { uuid: uuid, tag: tag.name }
161
- _post("/tags/attachTagToObject", payload) { |json| Tag.new json }
161
+ _post("/tags/attachTagToObject", payload) { |json| Tag.new(**json) }
162
162
  end
163
163
 
164
164
  #
@@ -184,11 +184,11 @@ module MISP
184
184
  end
185
185
 
186
186
  def create(event_id, **attributes)
187
- new(attributes).create(event_id)
187
+ new(**attributes).create(event_id)
188
188
  end
189
189
 
190
190
  def search(**params)
191
- new.search params
191
+ new.search(**params)
192
192
  end
193
193
  end
194
194
  end
data/lib/misp/base.rb CHANGED
@@ -37,7 +37,7 @@ module MISP
37
37
  def build_attribute(item:, klass:)
38
38
  return nil unless item
39
39
 
40
- klass.new item
40
+ klass.new(**item)
41
41
  end
42
42
 
43
43
  #
@@ -50,7 +50,7 @@ module MISP
50
50
  #
51
51
  def build_plural_attribute(items:, klass:)
52
52
  (items || []).map do |item|
53
- klass.new item
53
+ klass.new(**item)
54
54
  end
55
55
  end
56
56
 
@@ -63,7 +63,7 @@ module MISP
63
63
  self.class.to_s.split("::").last.to_s
64
64
  end
65
65
 
66
- def normalize_attributes(attributes)
66
+ def normalize_attributes(**attributes)
67
67
  klass = class_name.to_sym
68
68
 
69
69
  attributes.key?(klass) ? attributes.dig(klass) : attributes
data/lib/misp/event.rb CHANGED
@@ -58,7 +58,7 @@ module MISP
58
58
  attr_accessor :tags
59
59
 
60
60
  def initialize(**attrs)
61
- attrs = normalize_attributes(attrs)
61
+ attrs = normalize_attributes(**attrs)
62
62
 
63
63
  @id = attrs.dig(:id)
64
64
  @orgc_id = attrs.dig(:orgc_id)
@@ -132,7 +132,7 @@ module MISP
132
132
  # @return [MISP::Event]
133
133
  #
134
134
  def get(id)
135
- _get("/events/#{id}") { |event| Event.new event }
135
+ _get("/events/#{id}") { |event| Event.new(**event) }
136
136
  end
137
137
 
138
138
  #
@@ -144,7 +144,7 @@ module MISP
144
144
  #
145
145
  def create(**attrs)
146
146
  payload = to_h.merge(attrs)
147
- _post("/events/add", wrap(payload)) { |event| Event.new event }
147
+ _post("/events/add", wrap(payload)) { |event| Event.new(**event) }
148
148
  end
149
149
 
150
150
  #
@@ -164,7 +164,7 @@ module MISP
164
164
  def list
165
165
  _get("/events/index") do |events|
166
166
  events.map do |event|
167
- Event.new event
167
+ Event.new(**event)
168
168
  end
169
169
  end
170
170
  end
@@ -175,9 +175,9 @@ module MISP
175
175
  # @return [MISP::Event]
176
176
  #
177
177
  def update(**attrs)
178
- payload = to_h.merge(attrs)
178
+ payload = to_h.merge(**attrs)
179
179
  payload[:timestamp] = nil
180
- _post("/events/#{id}", wrap(payload)) { |event| Event.new event }
180
+ _post("/events/#{id}", wrap(payload)) { |event| Event.new(**event) }
181
181
  end
182
182
 
183
183
  #
@@ -194,7 +194,7 @@ module MISP
194
194
 
195
195
  _post("/events/restSearch", base.merge(params)) do |json|
196
196
  events = json.dig(:response) || []
197
- events.map { |event| Event.new event }
197
+ events.map { |event| Event.new(**event) }
198
198
  end
199
199
  end
200
200
 
@@ -226,7 +226,7 @@ module MISP
226
226
  end
227
227
 
228
228
  def create(**attrs)
229
- new.create attrs
229
+ new.create(**attrs)
230
230
  end
231
231
 
232
232
  def delete(id)
@@ -238,11 +238,11 @@ module MISP
238
238
  end
239
239
 
240
240
  def update(id, **attrs)
241
- new(id: id).update attrs
241
+ new(id: id).update(**attrs)
242
242
  end
243
243
 
244
244
  def search(**params)
245
- new.search params
245
+ new.search(**params)
246
246
  end
247
247
  end
248
248
 
data/lib/misp/feed.rb CHANGED
@@ -48,7 +48,7 @@ module MISP
48
48
  attr_reader :caching_enabled
49
49
 
50
50
  def initialize(**attributes)
51
- attributes = normalize_attributes(attributes)
51
+ attributes = normalize_attributes(**attributes)
52
52
 
53
53
  @id = attributes.dig(:id)
54
54
  @name = attributes.dig(:name) || "feed name"
@@ -114,7 +114,7 @@ module MISP
114
114
  def list
115
115
  _get("/feeds/index") do |feeds|
116
116
  feeds.map do |feed|
117
- Feed.new feed
117
+ Feed.new(**feed)
118
118
  end
119
119
  end
120
120
  end
data/lib/misp/galaxy.rb CHANGED
@@ -19,7 +19,7 @@ module MISP
19
19
  attr_reader :galaxy_clusters
20
20
 
21
21
  def initialize(**attributes)
22
- attributes = normalize_attributes(attributes)
22
+ attributes = normalize_attributes(**attributes)
23
23
 
24
24
  @id = attributes.dig(:id)
25
25
  @uuid = attributes.dig(:uuid)
@@ -56,7 +56,7 @@ module MISP
56
56
  def list
57
57
  _get("/galaxies/") do |galaxies|
58
58
  galaxies.map do |galaxy|
59
- Galaxy.new galaxy
59
+ Galaxy.new(**galaxy)
60
60
  end
61
61
  end
62
62
  end
@@ -67,7 +67,7 @@ module MISP
67
67
  # @return [MISP::Galaxy]
68
68
  #
69
69
  def get
70
- _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new galaxy }
70
+ _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new(**galaxy) }
71
71
  end
72
72
 
73
73
  class << self
data/lib/misp/org.rb CHANGED
@@ -10,7 +10,7 @@ module MISP
10
10
  attr_reader :uuid
11
11
 
12
12
  def initialize(**attributes)
13
- attributes = normalize_attributes(attributes)
13
+ attributes = normalize_attributes(**attributes)
14
14
 
15
15
  @id = attributes.dig(:id)
16
16
  @name = attributes.dig(:name)
data/lib/misp/orgc.rb CHANGED
@@ -10,7 +10,7 @@ module MISP
10
10
  attr_reader :uuid
11
11
 
12
12
  def initialize(**attributes)
13
- attributes = normalize_attributes(attributes)
13
+ attributes = normalize_attributes(**attributes)
14
14
 
15
15
  @id = attributes.dig(:id)
16
16
  @name = attributes.dig(:name)
data/lib/misp/server.rb CHANGED
@@ -10,7 +10,7 @@ module MISP
10
10
  attr_reader :name
11
11
 
12
12
  def initialize(**attributes)
13
- attributes = normalize_attributes(attributes)
13
+ attributes = normalize_attributes(**attributes)
14
14
 
15
15
  @id = attributes.dig(:id)
16
16
  @url = attributes.dig(:url)
@@ -38,7 +38,7 @@ module MISP
38
38
  attr_reader :sharing_group_servers
39
39
 
40
40
  def initialize(**attributes)
41
- attributes = normalize_attributes(attributes)
41
+ attributes = normalize_attributes(**attributes)
42
42
 
43
43
  @id = attributes.dig(:id)
44
44
  @name = attributes.dig(:name) || "default name"
@@ -95,7 +95,7 @@ module MISP
95
95
  _get("/sharing_groups/") do |res|
96
96
  sharing_groups = res.dig(:response) || []
97
97
  sharing_groups.map do |sharing_group|
98
- SharingGroup.new sharing_group
98
+ SharingGroup.new(**sharing_group)
99
99
  end
100
100
  end
101
101
  end
@@ -15,7 +15,7 @@ module MISP
15
15
  attr_reader :servers
16
16
 
17
17
  def initialize(**attributes)
18
- attributes = normalize_attributes(attributes)
18
+ attributes = normalize_attributes(**attributes)
19
19
 
20
20
  @id = attributes.dig(:id)
21
21
  @sharing_group_id = attributes.dig(:sharing_group_id)
data/lib/misp/tag.rb CHANGED
@@ -14,7 +14,7 @@ module MISP
14
14
  attr_accessor :hide_tag
15
15
 
16
16
  def initialize(**attributes)
17
- attributes = normalize_attributes(attributes)
17
+ attributes = normalize_attributes(**attributes)
18
18
 
19
19
  @id = attributes.dig(:id)
20
20
  @name = attributes.dig(:name)
@@ -44,7 +44,7 @@ module MISP
44
44
  # @return [MISP::Tag]
45
45
  #
46
46
  def get
47
- _get("/tags/view/#{id}") { |json| Tag.new json }
47
+ _get("/tags/view/#{id}") { |json| Tag.new(**json) }
48
48
  end
49
49
 
50
50
  #
@@ -55,7 +55,7 @@ module MISP
55
55
  # @return [MISP::Tag]
56
56
  #
57
57
  def create(**attributes)
58
- _post("/tags/add", wrap(attributes)) { |json| Tag.new json }
58
+ _post("/tags/add", wrap(attributes)) { |json| Tag.new(**json) }
59
59
  end
60
60
 
61
61
  #
@@ -76,7 +76,7 @@ module MISP
76
76
  #
77
77
  def update(**attributes)
78
78
  payload = to_h.merge(attributes)
79
- _post("/tags/edit/#{id}", wrap(payload)) { |json| Tag.new json }
79
+ _post("/tags/edit/#{id}", wrap(payload)) { |json| Tag.new(**json) }
80
80
  end
81
81
 
82
82
  #
@@ -98,7 +98,7 @@ module MISP
98
98
  end
99
99
 
100
100
  def create(**attributes)
101
- new.create attributes
101
+ new.create(**attributes)
102
102
  end
103
103
 
104
104
  def delete(id)
@@ -106,7 +106,7 @@ module MISP
106
106
  end
107
107
 
108
108
  def update(id, **attributes)
109
- Tag.new(id: id).update attributes
109
+ Tag.new(id: id).update(**attributes)
110
110
  end
111
111
  end
112
112
  end
data/lib/misp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MISP
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/misp.gemspec CHANGED
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "bundler", "~> 2.1"
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
29
  spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.8"
31
- spec.add_development_dependency "vcr", "~> 5.0"
32
- spec.add_development_dependency "webmock", "~> 3.7"
30
+ spec.add_development_dependency "rspec", "~> 3.9"
31
+ spec.add_development_dependency "vcr", "~> 5.1"
32
+ spec.add_development_dependency "webmock", "~> 3.8"
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2020-03-08 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: '2.0'
19
+ version: '2.1'
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.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.8'
61
+ version: '3.9'
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.9'
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: '5.1'
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: '5.1'
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.8'
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.8'
97
97
  description: A dead simple MISP API wrapper for Ruby
98
98
  email:
99
99
  - manabu.niseki@gmail.com
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.4
147
+ rubygems_version: 3.1.2
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: A dead simple MISP API wrapper for Ruby