carsonyl / pypac

Find and use proxy auto-config (PAC) files with Python and Requests.
https://pypac.readthedocs.io
Apache License 2.0
71 stars 18 forks source link

Possible duktape error when dnsResolve fails #34

Closed maximinus closed 5 years ago

maximinus commented 5 years ago

The current implementation of dnsResolve() returns None if the host cannot be resolved.

Because we now use dukpy, that value is potentially propagated back to the js engine if we depend on the result. For example, code such as:

isInNet(dnsResolve('bad-host', "10.1.1.0", "255.255.255.0"));

Will result in a duktape crash.

carsonyl commented 5 years ago

Could you share the crash info? Is this a really a bug in duktape? It looks to me like the real issue is the Python implementation of isInNet() (and probably others) don't expect a None argument.

maximinus commented 5 years ago

I don't think it's a bug in duktape, just that the error raises an exception there. The correct implementation of dnsResolve() should be to return an empty string on error, when None is returned, you may be right in that isInNet() cannot handle the value, but it shouldn't be there in the first place. I have several other examples of PAC files that expect a string to be returned from dnsResolve() and they all flagged this error when we tested this morning. I'll post the crash report when I'm back in the office in about 12 hours time.

carsonyl commented 5 years ago

Alright, if you're confident that dnsResolve() is incorrect to return None, that's good enough for me.