Guest User!

You are not Sophos Staff.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Yet another regex cry for help

I have blocked the download of .EXE files in the default content filter (running UTM 9.209-8). This works really well.

I get requests now and again to allow some specific download and for this I have been creating exceptions using regular expressions to match the URL where the specific exe is being downloaded from - typically these are updates for legitimate software we are running and are therefore downloaded regularly. This has also worked well.

However, one specific download location has me stumped. The exe is being downloaded from this content server - this is the URL that is displayed in the log:

df975b643fb977f682c3-8243d3bde40a04822331a45aadc0149c.r48.cf3.rackcdn.com/IRIS110601-55.exe


So, my attempt at a regular expression to match this is as follows:

^http?://([A-Za-z0-9.-]*\.)rackcdn\.com/IRIS*[0-9-]\.exe


When I test this in the Policy tester, it comes back as allowed, but the tester does not state a match with an exception and the end user still cannot download the EXE. Other exceptions that I know work will also say "allowed" in the tester even when the exception is disabled but the end user cannot get the EXE - but when the exception is enabled the tester still comes back saying "allowed", but it also states that an exception has been matched and this time the end user can download the exe as expected.

I suspect my reg exp is wrong - probably the multiple subdomains - can anyone enlighten me please?


This thread was automatically locked due to age.
  • Quick RegEx for URLs | UTM Tools

    This tool at that site will give you the regex you are looking for..[:)]
  • I worked it out - it was the bit trying to match the file name that was wrong. Plus a missing "?" before rackcdn.com.

    When I use the Policy Filter I now get a match against my exception. This is what works:

    ^http?://([A-Za-z0-9.-]*\.)?rackcdn\.com/IRIS.*\.exe
  • Quick RegEx for URLs | UTM Tools

    This tool at that site will give you the regex you are looking for..[:)]


    Thanks William - I tried that earlier, but inputting the original URL just gave me this suggestion

    ^http://([A-Za-z0-9.-]*\.)?df975b643fb977f682c3-8243d3bde40a04822331a45aadc0149c\.r48\.cf3\.rackcdn\.com/IRIS110601-55.exe


    I wanted to match anything before the rackcdn.com just incase the location changed (it seems a random generated list of numbers) and I wanted to make sure that the file name could change as well (i.e. it will always contain "IRIS" but the numbers after and before the .exe can change).
  • Thanks William - I tried that earlier, but inputting the original URL just gave me this suggestion

    ^http://([A-Za-z0-9.-]*\.)?df975b643fb977f682c3-8243d3bde40a04822331a45aadc0149c\.r48\.cf3\.rackcdn\.com/IRIS110601-55.exe
    


    I wanted to match anything before the rackcdn.com just incase the location changed (it seems a random generated list of numbers) and I wanted to make sure that the file name could change as well (i.e. it will always contain "IRIS" but the numbers after and before the .exe can change).


    Right so if you want to except a certain subdomain you put just that subdomain into the tool and it would have generated that exact code for you...i use this tool all of the time to generate all kinds of regex...inlcuindg situations like yours.  It is not restricted to only top level domains you can "start" it at a sub domain level and it will generate the appropriate code.
  • James, although your REGEX will work, here's your glitch in your first one...  The "*" should not be after "IRIS" - here's what you wanted: [;)]

    ^https?://([A-Za-z0-9.-]*\.)rackcdn\.com/IRIS[0-9-]*\.exe


    Cheers - Bob
  • James, although your REGEX will work, here's your glitch in your first one...  The "*" should not be after "IRIS" - here's what you wanted: [;)]

    ^https?://([A-Za-z0-9.-]*\.)rackcdn\.com/IRIS[0-9-]*\.exe


    Cheers - Bob


    Many thanks Bob. I was on the right track I guess!