KB No. 05: Converting a script.pac file into an exclusion list

Description

Isolate URLs excluded by a script.pac in list form.

Background

In the case of an on-premise migration to SaaS, the administrator must import the proxy flow exclusions. If these exclusions are listed in a GPO, the administrator can simply copy and paste the list. However, if they are using a .pac script to indicate these exclusions and the proxy through which they must pass, they must retrieve the excluded URLs through a tedious process of isolation and copy-pasting. This KB aims to facilitate this process using regular expressions (known as RegEx).

Prerequisites

Have a proxy.pac script

Procedure

Let's take the example of this proxy.pac:

To extract all host names in list format with only the host name, use this RegEx:

/(?<=host\ \=\=\=\ \ »)(.*?)(?=\ »)/gm

To apply it, go to https://regexr.com and copy the list obtained directly into the "List" tab in the second half of the screen:

Screenshot on the regexr.com website

Finally, to extract all excluded domain names using the dnsDomainIs comparison method, we use this RegEx:

/(?<=dnsDomainIs\(host\,\ »)(.*?)(?=\ »\))/gm

You can use regexr.com again to apply this RegEx.

You can concatenate the two lists obtained and paste the resulting list into: Configuration > Traffic Management > (Edit your .pac) > Content > Multiple Edit.

Note

Don't forget to save by clicking on "Validate" then "Save and exit."