feduxorg / proxy_pac_rb

proxy_pac _rb is a gem to test, compress, lint, and parse proxy auto-config files
https://github.com/fedux-org/proxy_pac_rb
MIT License
3 stars 2 forks source link

problems with processing isInNet case if dnsResolve is in use #1

Closed Sea-you closed 9 years ago

Sea-you commented 10 years ago

Hi,

I discovered a bug, that could be reproduced by adding the following to proxy.pac:

hostip = dnsResolve(host); if (isInNet(hostip, "x.x.x.x", "255.255.255.255") || isInNet(hostip, "x.x.x.x", "255.255.255.255") || isInNet(hostip, "x.x.x.x", "255.255.255.255") || isInNet(hostip, "x.x.x.x", "255.255.255.255")) return proxy;

The debug data looks like the following: /usr/local/rvm/gems/ruby-1.9.3-p547/gems/local_pac-0.10.2/app/controllers/lookup_controller.rb in rescue in block in class:LookupController

raise Exceptions::PacFileInvalid, name: name

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/local_pac-0.10.2/app/controllers/lookup_controller.rb in block in class:LookupController

begin

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

proc { |a,p| unbound_method.bind(a).call }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in compile!

proc { |a,p| unbound_method.bind(a).call }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in []

route_eval { block[*args] }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block (3 levels) in route!

route_eval { block[*args] }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in route_eval

throw :halt, yield

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block (2 levels) in route!

route_eval { block[*args] }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in process_route

block ? block[self, values] : yield(self, values)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in catch

catch(:pass) do

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in process_route

catch(:pass) do

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in route!

returned_pass_block = process_route(pattern, keys, conditions) do |*args|

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in each

routes.each do |pattern, keys, conditions, block|

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in route!

routes.each do |pattern, keys, conditions, block|

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in dispatch!

route!

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in invoke

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in catch

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in invoke

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in dispatch!

invoke do

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in call!

invoke { dispatch! }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in invoke

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in catch

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in invoke

res = catch(:halt) { yield }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call!

invoke { dispatch! }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

dup.call!(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-contrib-1.1.0/lib/rack/contrib/post_body_content_type_parser.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-contrib-1.1.0/lib/rack/contrib/nested_params.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-contrib-1.1.0/lib/rack/contrib/locale.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/deflater.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb in call

app.call env

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb in call

status, headers, body = app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/base.rb in call

result or app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/base.rb in call

result or app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/nulllogger.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/head.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

result, callback = app.call(env), env['async.callback']

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

@stack.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in block in call

synchronize { prototype.call(env) }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in synchronize

yield

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

synchronize { prototype.call(env) }

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/builder.rb in call

to_app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/urlmap.rb in block in call

return app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/urlmap.rb in each

@mapping.each do |host, location, match, app|

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/rack-1.5.2/lib/rack/urlmap.rb in call

@mapping.each do |host, location, match, app|

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/rack_patch.rb in call

status, header, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/sinatra-1.4.5/lib/sinatra/base.rb in call

call_without_check(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/configuration.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/server.rb in handle_request

status, headers, res_body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/server.rb in process_client

case handle_request(client, buffer)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/server.rb in block in run

process_client client, buffer

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/thread_pool.rb in call

block.call(work, *extra)

/usr/local/rvm/gems/ruby-1.9.3-p547/gems/puma-2.8.2/lib/puma/thread_pool.rb in block in spawn_thread

block.call(work, *extra)

My ruby gem-list is the following: * LOCAL GEMS *

activesupport (4.2.0.beta1) addressable (2.3.6) backports (3.6.0) bigdecimal (1.1.0) bundler (1.7.2) bundler-unload (1.0.2) chunky_png (1.3.1) coderay (1.1.0) columnize (0.8.9) compass (1.1.0.alpha.1) compass-core (1.1.0.alpha.1) compass-import-once (1.0.5) debugger (1.6.8) debugger-linecache (1.2.0) debugger-ruby_core_source (1.3.5) execjs (2.2.1) executable-hooks (1.3.2) facter (2.2.0) ffi (1.9.3) gem-wrappers (1.2.5) haml (4.1.0.beta.1) hike (1.2.3) i18n (0.7.0.beta1) io-console (0.3) json (1.8.1, 1.5.5) libv8 (3.16.14.3 x86_64-linux) local_pac (0.10.2) method_source (0.8.2) minitest (5.4.1, 2.5.1) multi_json (1.10.1) pager (1.0.1) phantomjs (1.9.7.1) proxy_pac_rb (0.2.6) pry (0.10.1) puma (2.8.2) rack (1.5.2) rack-contrib (1.1.0) rack-protection (1.5.3) rack-test (0.6.2) rake (0.9.2.2) rb-fsevent (0.9.4) rb-inotify (0.9.5) rdoc (3.9.5) ref (1.0.5) rubygems-bundler (1.4.4) rugged (0.19.0) rvm (1.11.3.9) sass (3.4.3) sinatra (1.4.5) sinatra-contrib (1.4.2) sinatra-param (1.2.2) slop (3.6.0) sprockets (2.12.2) sprockets-helpers (1.1.0) sprockets-sass (1.2.0) sys-proctable (0.9.4 universal-linux) therubyracer (0.12.1) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) tzinfo (1.2.2) uglifier (2.5.3)

Any idea why this is happening?

Thanks in advance, cU

ghost commented 10 years ago

Thanks for your bug report. Would you mind to reformat it, so that it is better to read?

ghost commented 10 years ago

Any idea why this is happening?

Not now. I will need to look into this. But this will take some time, as I'm a bit busy at the moment. So please stay tuned. :-)

ghost commented 10 years ago

You are using a quite old version of proxy_pac_rb (0.2.6). Please upgrade to 0.3.6.

Sea-you commented 10 years ago

Thank you, I'm using this with the latest version of your local_pac, but the depency is ~> 0.2.0, hence it installed the older version. I'll try to modify the depency and see if that helps. No experience with Ruby at all, but it seems to be easy :)

ghost commented 10 years ago

You're right. I need to update local_pac very soon. But this will be a rewrite of that tool. I'm going to switch the framework to rails if it is fast enough. So please stay tuned. :-)

Sea-you commented 10 years ago

That's great, thanks for your work!

ghost commented 9 years ago

@Sea-you Unfortunately I will discountinue local_pac. Instead I now use middleman + proxy_pac_rb (rack middleware) + apache 2.4 with RewriteCond expr "-R 10.0.0.0/24" to serve the proxy.pac.

cu12 commented 9 years ago

thanks for letting me know!

ghost commented 9 years ago

No problem, you may want to look at [this part](https://github.com/fedux-org/proxy_pac_rb#using-rack-middleware-with-middleman] of the proxy_pac_rb-readme. There's a description of some rack-middleware which is now part of proxy_pac_rb.