Skip to content

Commit

Permalink
Allow to specify host key verification via URL query (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
dim authored Mar 17, 2022
1 parent 10a4f8e commit cd4cfe9
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["2.6", "2.7", "3.0"]
ruby-version: ["2.7", "3.0", "3.1"]
services:
ftp:
image: delfer/alpine-ftp-server
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inherit_mode:
- Exclude

AllCops:
TargetRubyVersion: "2.6"
TargetRubyVersion: "2.7"

Metrics/ParameterLists:
Max: 8
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1
161 changes: 89 additions & 72 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
PATH
remote: core
specs:
bfs (0.9.0)
bfs (0.9.1)

PATH
remote: ftp
specs:
bfs-ftp (0.9.0)
bfs (= 0.9.0)
bfs-ftp (0.9.1)
bfs (= 0.9.1)
net-ftp (>= 0.1.3)
net-ftp-list

PATH
remote: gs
specs:
bfs-gs (0.9.0)
bfs (= 0.9.0)
bfs-gs (0.9.1)
bfs (= 0.9.1)
google-cloud-storage (~> 1.18)

PATH
remote: s3
specs:
bfs-s3 (0.9.0)
bfs-s3 (0.9.1)
aws-sdk-s3 (~> 1.38)
bfs (= 0.9.0)
bfs (= 0.9.1)

PATH
remote: scp
specs:
bfs-scp (0.9.0)
bfs (= 0.9.0)
bfs-scp (0.9.1)
bfs (= 0.9.1)
net-scp

PATH
remote: sftp
specs:
bfs-sftp (0.9.0)
bfs (= 0.9.0)
bfs-sftp (0.9.1)
bfs (= 0.9.1)
net-sftp

GEM
Expand All @@ -44,46 +45,53 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
aws-eventstream (1.1.1)
aws-partitions (1.477.0)
aws-sdk-core (3.117.0)
aws-eventstream (1.2.0)
aws-partitions (1.568.0)
aws-sdk-core (3.130.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.44.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (1.55.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.96.1)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-s3 (1.113.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.4)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.4.0)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt_pbkdf (1.1.0)
date (3.2.2)
declarative (0.0.20)
diff-lcs (1.4.4)
digest-crc (0.6.3)
diff-lcs (1.5.0)
digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0)
ed25519 (1.2.4)
faraday (1.5.1)
ed25519 (1.3.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
multipart-post (>= 1.2, < 3)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
google-apis-core (0.4.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
google-apis-core (0.4.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand All @@ -92,105 +100,114 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.6.0)
google-apis-iamcredentials_v1 (0.10.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-storage_v1 (0.6.0)
google-apis-storage_v1 (0.11.0)
google-apis-core (>= 0.4, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.1.0)
google-cloud-storage (1.34.1)
addressable (~> 2.5)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.1)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.1)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (0.16.2)
faraday (>= 0.17.3, < 2.0)
googleauth (1.1.2)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.14)
signet (>= 0.16, < 2.a)
httpclient (2.8.3)
jmespath (1.4.0)
jwt (2.2.3)
io-wait (0.2.1)
jmespath (1.6.1)
jwt (2.3.0)
memoist (0.16.2)
mini_mime (1.1.0)
mini_mime (1.1.2)
multi_json (1.15.0)
multipart-post (2.1.1)
net-ftp (0.1.3)
net-protocol
time
net-ftp-list (3.3.0)
net-protocol (0.1.2)
io-wait
timeout
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-sftp (3.0.0)
net-ssh (>= 5.0.0, < 7.0.0)
net-ssh (6.1.0)
os (1.1.1)
parallel (1.20.1)
parser (3.0.2.0)
os (1.1.4)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
public_suffix (4.0.6)
rainbow (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.1.1)
regexp_parser (2.2.1)
representable (3.1.1)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rubocop (1.18.3)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.26.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.7.0, < 2.0)
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.7.0)
parser (>= 3.0.1.1)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-bsm (0.6.0)
rubocop (~> 1.0)
rubocop-performance
rubocop-rake
rubocop-rspec
rubocop-performance (1.11.4)
rubocop-performance (1.13.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop-rspec (2.9.0)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.4)
signet (0.15.0)
addressable (~> 2.3)
faraday (>= 0.17.3, < 2.0)
ruby2_keywords (0.0.5)
signet (0.16.1)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
trailblazer-option (0.1.1)
time (0.2.0)
date
timeout (0.2.0)
trailblazer-option (0.1.2)
uber (0.1.0)
unicode-display_width (2.0.0)
unicode-display_width (2.1.0)
webrick (1.7.0)

PLATFORMS
Expand All @@ -211,4 +228,4 @@ DEPENDENCIES
webrick

BUNDLED WITH
2.2.21
2.3.9
3 changes: 2 additions & 1 deletion core/bfs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7'
s.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion core/spec/bfs/bucket/fs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
metadata: false

it 'resolves from URL' do
File.open(File.join(tmpdir, 'test.txt'), 'wb') {|f| f.write 'TESTDATA' }
File.binwrite(File.join(tmpdir, 'test.txt'), 'TESTDATA')

bucket = BFS.resolve("file://#{tmpdir}")
expect(bucket).to be_instance_of(described_class)
Expand Down
4 changes: 3 additions & 1 deletion ftp/bfs-ftp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7'

s.add_dependency 'bfs', s.version
s.add_dependency 'net-ftp', '>= 0.1.3'
s.add_dependency 'net-ftp-list'
s.metadata['rubygems_mfa_required'] = 'true'
end
3 changes: 2 additions & 1 deletion gs/bfs-gs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7'

s.add_dependency 'bfs', s.version
s.add_dependency 'google-cloud-storage', '~> 1.18'
s.metadata['rubygems_mfa_required'] = 'true'
end
3 changes: 2 additions & 1 deletion s3/bfs-s3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7'

s.add_dependency 'aws-sdk-s3', '~> 1.38'
s.add_dependency 'bfs', s.version
s.metadata['rubygems_mfa_required'] = 'true'
end
3 changes: 2 additions & 1 deletion scp/bfs-scp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7'

s.add_dependency 'bfs', s.version
s.add_dependency 'net-scp'
s.metadata['rubygems_mfa_required'] = 'true'
end
3 changes: 2 additions & 1 deletion scp/lib/bfs/bucket/scp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(cmd, status, extra = nil)
# @option opts [Boolean] :keepalive use keepalive.
# @option opts [Integer] :keepalive_interval interval if keepalive enabled. Default: 300.
# @option opts [Array<String>] :keys an array of file names of private keys to use for publickey and hostbased authentication.
# @option opts [Boolean|Symbol] :verify_host_key specifying how strict host-key verification should be, either false, true, :very, or :secure.
# @option opts [Symbol] :verify_host_key host-key verification should be, either :never, :accept_new_or_local_tunnel, :accept_new, or :always.
def initialize(host, prefix: nil, **opts)
super(**opts)

Expand Down Expand Up @@ -214,6 +214,7 @@ def sh!(command) # rubocop:disable Metrics/MethodLength
opts[:user] ||= CGI.unescape(url.user) if url.user
opts[:password] ||= CGI.unescape(url.password) if url.password
opts[:port] ||= url.port if url.port
opts[:verify_host_key] = opts[:verify_host_key].to_sym if opts[:verify_host_key]

BFS::Bucket::SCP.open(url.host, **opts, &block)
end
Loading

0 comments on commit cd4cfe9

Please sign in to comment.