onfido 0.8.4 → 0.9.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
- SHA1:
3
- metadata.gz: 9b8943db59807d0aca9c9e8caa5b5509878432d6
4
- data.tar.gz: 0c12bf449f543db534205f3944ee69251408b025
2
+ SHA256:
3
+ metadata.gz: 02ec5c2316de975b17ee9818699d45f47eff8e9f93bb89400e7ef4dd9d6b5170
4
+ data.tar.gz: ed1a1accb7575b5483eb17cd5631d0abe98641a5c34922b79a9c26bce13eab53
5
5
  SHA512:
6
- metadata.gz: d7eeae37b53e98a3d46e4e8a4fa4ec20ff0dc0d77fdf79be49f7c1d2a9f50466d61503a00db7fef9d3c7b39216095ab6e2340f4577d989b6e305c8167cbd7d0c
7
- data.tar.gz: 64e81f488051a276972cb3476e540bb6fae1d2a9b19699a6512b7184b66fc7a808ed8ccb13f34cf767b12cfb434501084e08bb6bb18661454a8277f37724dc9d
6
+ metadata.gz: b51ceca16f8c19c95234e8ba5b5e5e86c3cca098273a79e3880c46175861c6efd9d97858bc463d6a8ad029268d66866306792b5dea822473cd89100c5f4a9b75
7
+ data.tar.gz: 0f149d1be7d19d1c3f4edbef29d80d0ac5ebfd4ed26e17a29b66e44afbc2e9aa4d473e5ce770d7247284d993a054e6349f043cce62f6d7c9315525b1b6558b92
@@ -9,6 +9,7 @@ AllCops:
9
9
  - vendor/**/*
10
10
  - .*/**
11
11
  - spec/fixtures/**/*
12
+ TargetRubyVersion: 2.2.0
12
13
 
13
14
  Style/StringLiterals:
14
15
  Enabled: false
@@ -1,3 +1,8 @@
1
+ ## v0.9.0, 8 March 2018
2
+
3
+ - Remove the ability to create Documents and Live Photos from a remote URL or local path, mitigating a potential security vulnerability (see #45 for details) (@timrogers)
4
+ - Drop support for Ruby versions earlier than 2.2.0, since they have [reached end-of-life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/) (@timrogers)
5
+
1
6
  ## v0.8.4, 29 January 2018
2
7
 
3
8
  - Replace use of `method_missing` with explicitly-defined accessors when accessing
data/README.md CHANGED
@@ -12,9 +12,11 @@ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API d
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'onfido', '~> 0.8.4'
15
+ gem 'onfido', '~> 0.9.0'
16
16
  ```
17
17
 
18
+ The gem is compatible with Ruby 2.2.0 and onwards. Earlier versions of Ruby have [reached end-of-life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/), are no longer supported and no longer receive security fixes.
19
+
18
20
  ## Configuration
19
21
 
20
22
  There are 5 configuration options:
@@ -72,7 +74,10 @@ api.document.download('applicant_id', 'document_id') # => Downloads a document a
72
74
  api.document.all('applicant_id') # => Returns all applicant's documents
73
75
  ```
74
76
 
75
- **Note:** The file parameter can be either a `File` object or a link to an image.
77
+ **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
78
+ Previous versions of this gem supported providing a URL to a file accessible over HTTP or a path
79
+ to a file in the local filesystem. You should instead load the file yourself and then pass it in
80
+ to `#create`.
76
81
 
77
82
  #### Live Photos
78
83
 
@@ -83,7 +88,10 @@ They can only be created - the Onfido does not support finding or listing them.
83
88
  api.live_photo.create('applicant_id', file: 'http://example.com')
84
89
  ```
85
90
 
86
- **Note:** The file parameter can be either a `File` object or a link to an image.
91
+ **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
92
+ Previous versions of this gem supported providing a URL to a file accessible over HTTP or a path
93
+ to a file in the local filesystem. You should instead load the file yourself and then pass it in
94
+ to `#create`.
87
95
 
88
96
  #### Checks
89
97
 
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
  require 'rack'
3
3
  require 'rest-client'
4
- require 'open-uri'
5
4
  require 'openssl'
6
5
 
7
6
  require 'onfido/version'
@@ -144,5 +144,12 @@ module Onfido
144
144
 
145
145
  raise ConnectionError.new(full_message)
146
146
  end
147
+
148
+ def validate_file!(file)
149
+ return if file.respond_to?(:read) && file.respond_to?(:path)
150
+
151
+ raise ArgumentError, "File must be a `File`-like object which responds to " \
152
+ "`#read` and `#path`"
153
+ end
147
154
  end
148
155
  end
@@ -3,7 +3,8 @@ module Onfido
3
3
  # with open-uri the file can be a link or an actual file
4
4
 
5
5
  def create(applicant_id, payload)
6
- payload[:file] = open(payload.fetch(:file), 'r')
6
+ validate_file!(payload.fetch(:file))
7
+
7
8
  post(
8
9
  url: url_for("applicants/#{applicant_id}/documents"),
9
10
  payload: payload
@@ -3,8 +3,9 @@ module Onfido
3
3
  # with open-uri the file can be a link or an actual file
4
4
 
5
5
  def create(applicant_id, payload)
6
+ validate_file!(payload.fetch(:file))
6
7
  payload[:applicant_id] = applicant_id
7
- payload[:file] = open(payload.fetch(:file), 'r')
8
+
8
9
  post(
9
10
  url: url_for("/live_photos"),
10
11
  payload: payload
@@ -1,3 +1,3 @@
1
1
  module Onfido
2
- VERSION = '0.8.4'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ['lib']
24
+ spec.required_ruby_version = ">= 2.2.0"
24
25
 
25
26
  spec.add_development_dependency 'bundler', '~> 1.7'
26
27
  spec.add_development_dependency 'rake', '~> 12.0'
@@ -4,13 +4,6 @@ describe Onfido::Document do
4
4
  subject(:document) { described_class.new }
5
5
 
6
6
  describe '#create' do
7
- after do
8
- file.close
9
- file.unlink
10
- end
11
-
12
- let(:file) { Tempfile.new(['passport', '.jpg']) }
13
- before { allow(document).to receive(:open).and_return(:file) }
14
7
  let(:params) do
15
8
  {
16
9
  type: 'passport',
@@ -20,9 +13,27 @@ describe Onfido::Document do
20
13
  end
21
14
  let(:applicant_id) { '1030303-123123-123123' }
22
15
 
23
- it 'creates a new document' do
24
- response = document.create('foobar', params)
25
- expect(response['id']).not_to be_nil
16
+ context 'with a File-like object to upload' do
17
+ let(:file) { Tempfile.new(['passport', '.jpg']) }
18
+
19
+ after do
20
+ file.close
21
+ file.unlink
22
+ end
23
+
24
+ it 'creates a new document' do
25
+ response = document.create('foobar', params)
26
+ expect(response['id']).not_to be_nil
27
+ end
28
+ end
29
+
30
+ context 'passing in a non-File-like file to upload' do
31
+ let(:file) { 'https://onfido.com/images/logo.png' }
32
+
33
+ it 'raises an ArgumentError' do
34
+ expect { document.create('foobar', params) }.
35
+ to raise_error(ArgumentError, /must be a `File`-like object/)
36
+ end
26
37
  end
27
38
  end
28
39
 
@@ -4,19 +4,29 @@ describe Onfido::LivePhoto do
4
4
  subject(:live_photo) { described_class.new }
5
5
 
6
6
  describe '#create' do
7
- after do
8
- file.close
9
- file.unlink
7
+ let(:params) { { file: file } }
8
+
9
+ context 'with a File-like object to upload' do
10
+ let(:file) { Tempfile.new(['passport', '.jpg']) }
11
+
12
+ after do
13
+ file.close
14
+ file.unlink
15
+ end
16
+
17
+ it 'creates a new photo' do
18
+ response = live_photo.create('foobar', params)
19
+ expect(response['id']).not_to be_nil
20
+ end
10
21
  end
11
22
 
12
- let(:file) { Tempfile.new(['photo', '.jpg']) }
13
- before { allow(live_photo).to receive(:open).and_return(:file) }
14
- let(:params) { { file: file } }
15
- let(:applicant_id) { '1030303-123123-123123' }
23
+ context 'passing in a non-File-like file to upload' do
24
+ let(:file) { 'https://onfido.com/images/photo.jpg' }
16
25
 
17
- it 'creates a new photo' do
18
- response = live_photo.create('foobar', params)
19
- expect(response['id']).not_to be_nil
26
+ it 'raises an ArgumentError' do
27
+ expect { live_photo.create('foobar', params) }.
28
+ to raise_error(ArgumentError, /must be a `File`-like object/)
29
+ end
20
30
  end
21
31
  end
22
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pericles Theodorou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-29 00:00:00.000000000 Z
12
+ date: 2018-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - ">="
226
226
  - !ruby/object:Gem::Version
227
- version: '0'
227
+ version: 2.2.0
228
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  requirements:
230
230
  - - ">="
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.6.13
235
+ rubygems_version: 2.7.4
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: A wrapper for Onfido API