Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test remote host via ipv6 address #110

Closed
atomic111 opened this issue May 24, 2016 · 3 comments
Closed

test remote host via ipv6 address #110

atomic111 opened this issue May 24, 2016 · 3 comments
Labels

Comments

@atomic111
Copy link

I want to test a remote host via ipv6 address and i got the following output:

inspec shell -t ssh://pmuench@2000:111b:ffe2:1:0:0:0:2 --port 545 --key-files /home/user/.ssh/id_rsa
/usr/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): ssh://pmuench@2000:111b:ffe2:1:0:0:0:2 (URI::InvalidURIError)
        from /usr/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse'
        from /usr/lib/ruby/2.3.0/uri/common.rb:227:in `parse'
        from /usr/lib/ruby/gems/2.3.0/gems/r-train-0.11.3/lib/train.rb:66:in `target_config'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/lib/inspec/backend.rb:16:in `create'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/lib/inspec/runner.rb:45:in `configure_transport'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/lib/inspec/runner.rb:29:in `initialize'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/lib/inspec/cli.rb:141:in `new'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/lib/inspec/cli.rb:141:in `shell_func'
        from /usr/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /usr/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /usr/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /usr/lib/ruby/gems/2.3.0/gems/inspec-0.21.1/bin/inspec:9:in `<top (required)>'
        from /home/user/.gem/ruby/2.3.0/bin/inspec:22:in `load'
        from /home/user/.gem/ruby/2.3.0/bin/inspec:22:in `<main>'

if i add a host entry in the ssh config like this:

Host testhost
        Hostname 2000:111b:ffe2:1::2

and the use the following command then it works:

inspec shell -t ssh://pmuench@testhost --port 545 --key-files /home/user/.ssh/id_rsa                  
WARN: Unresolved specs during Gem::Specification.reset:
      mixlib-shellout (~> 2.0)
      winrm-fs (~> 0.3)
      excon (>= 0.38.0)
      ffi (>= 1.0.1)
      unf_ext (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Welcome to the interactive InSpec Shell
To find out how to use it, type: help

inspec> 

please keep in mind the compressed ipv6 address notation

@chris-rock chris-rock added the bug label May 24, 2016
@chris-rock
Copy link
Contributor

Thanks for the finding @atomic111

@mgrobelin
Copy link
Contributor

Hi,
a very similar issue when passing a URL username with @-sign included: Ruby's URI module fails to parse correctly.

I tried:

[mgrobelin@corp.internal@mybox inspec-stig-apache]$ inspec exec controls/V-13613.rb -t ssh://mgrobelin@corp.internal@localhost --key-files ~/.ssh/id_rsa
bad URI(is not URI?): ssh://mgrobelin@corp.internal@localhost

... and understood Ruby's builtin URI doesn't behave as desired...

2.3.3 :007 > URI.parse("ssh://mgrobelin@corp.internal@localhost")
URI::InvalidURIError: bad URI(is not URI?): ssh://mgrobelin@corp.internal@localhost
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split'
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse'
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/common.rb:227:in `parse'
	from (irb):7
	from /usr/local/rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'

# ... origin bug report
2.3.3 :011 > URI.parse("ssh://pmuench@2000:111b:ffe2:1:0:0:0:2")
URI::InvalidURIError: bad URI(is not URI?): ssh://pmuench@2000:111b:ffe2:1:0:0:0:2
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split'
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse'
	from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/common.rb:227:in `parse'
	from (irb):11
	from /usr/local/rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'

People on the internet suggested, to do the parsing with the Addressable Gem (https://github.com/sporkmonger/addressable) instead, which obviously solves both issues at once:

2.3.3 :001 > require "addressable/uri"
2.3.3 :002 > uri = Addressable::URI.parse("ssh://mgrobelin@corp.internal@localhost")
2.3.3 :003 > uri.user
 => "mgrobelin@corp.internal" 
2.3.3 :004 > uri.host
 => "localhost" 

# .... origin bug report
2.3.3 :008 > uri = Addressable::URI.parse("ssh://pmuench@2000:111b:ffe2:1:0:0:0:2")
2.3.3 :009 > uri.user
 => "pmuench" 
2.3.3 :010 > uri.host
 => "2000:111b:ffe2:1:0:0:0" 

PR welcome or do you have negative complains/feelings regarding Addressable Gem?

@clintoncwolfe
Copy link
Contributor

Thanks for the suggestion, @mgrobelin ! A PR is certainly welcome.

mgrobelin added a commit to mgrobelin/train that referenced this issue Aug 21, 2018
"Addressable is a replacement for the URI implementation that is part of Ruby's standard library. It more closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4), additionally providing support for IRIs and URI templates.", see https://github.com/sporkmonger/addressable

Fixes inspec#110

Signed-off-by: Markus Grobelin <grobi@koppzu.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants