Sometimes customer want to add some functions in the PAC files hosted on WSS Pac File Management System (PFMS), to port or maintain code that is present on their on-premise environment for example.
However sometimes when a function is added on the PAC file and the pac file is saved the function is not present when navigating away and back to the file, as illustrated in Image 1 (pac file as saved) and image 2 (pac file as loaded after navigating away from the pac file edit page).
Why is this happening, and how can custom functions be added to the PFMS hosted files via the WSS portal?
Image 1: Pac file content as saved on the WSS portal
Image 2: Pac file content as loaded after reloading the portal or navigating away from the pac file editor
WSS portal PAC File Management System (PFMS)
The PAC File Management System provides the possibility to add templates to the PAC file (Image 1).
Those templates will be added at the beginning of the PAC file and because of this any string above the line "function FindProxyForURL(url, host)" will be removed when the PAC file is saved in the PFMS.
Image 3: WSS portal, PAC file editor, template option toggles
As you can see on image 2 highlight the custom function "customProxy2" added at the end of the PAC file was preserved.
We can verify that the function is loaded and called without problems when using the PFMS file on a browser. First we check the WSS proxy for accessing the Internet (Image 4) and then we go to Google.com to validate that the function "customProxy2" call is made and returns the expected proxy address, which it does!
Image 4: Access to pod.threatpulse.com is via proxy.threatpulse.com (which in this instance resolved via DNS to the GUSLV1 pop ingress ip.
Image 5: Traffic to Google.com is sent via proxy 126.96.36.199 per pac file script shown in Image 2.