Does anyone have tips or pointers on validating proxy auto config file syntax?
For explicit proxy setups, I'll share my love of Microsoft Sysinternals tool tcpview.exe for verifying that for a given site, the client machine is doing what it's supposed to in terms of connecting to the proxy or trying to get straight out to the internet.
Verifying syntax of the PAC would be a nice proactive QA step though that I'd like to add to the process. I have a vague notion that "weblint" may be one possible avenue, but the specifics of how others do (or don't do) this would be useful as well.
This one seems to be useful:
There is a windows version you can download and run.
pactester.c: You didn't specify the PAC file
Usage: pactester.exe <-p pacfile> <-u url> [-h host] [-c client_ip] [-e]
pactester.exe <-p pacfile> <-f urlslist> [-c client_ip] [-e]
-p pacfile : PAC file to test (specify '-' to read from standard input)
-u url : URL to test for
-h host : Host part of the URL
-c client_ip : client IP address (as returned by myIpAddres() function
in PAC files), defaults to IP address on which it is running.
-e : enable microsoft extensions (Ex functions)
-f urlslist : a file containing list of URLs to be tested.
-v : print version and exit
>pactester.exe -p proxy.pac -u http://www.mcafee.com -h mcafee.com
And on PAC files with errors, it can point you in the right direction:
JSERROR: PAC script:44:
SyntaxError: missing } after function body
pacparser.c: pacparser_parse_pac_string: Failed to evaluate the pac script.
pactester.c: Could not parse the pac file: proxy.pac
Message was edited by: eelsasser on 8/10/12 1:51:13 PM EDT
I second E²'s comment. I have used pactester for years and have had great success with a pretty wide variety of pac files. Pactester is great for validating pac file logic and catching syntax errors. It will even tell you the line that failed (or a few lines later if it's something like a missing semicolon.
I would warn that there are a few other common pac file mistakes that pactester will not catch. Things like doing too many DNS lookups, myipaddress() misrepresenting the local IP, and other failures in design.
Also, a good rule of thumb for your last step is to open the file in Notepad and ensure no non windows linefeeds, tabs, etc, and save in ASCII. IE and some other MS clients (outlook, office, etc) can be touchy about the encoding. UTF8 is not a good choice in a MS environment.