ABE Script-blocking

Discussions about the Application Boundaries Enforcer (ABE) module
User avatar
SeanM
Junior Member
Posts: 44
Joined: Fri Jul 24, 2009 1:42 pm
Location: Upstate, New York USA

ABE Script-blocking

Post by SeanM »

Recently, I noticed that a USER ABE rule seems to have changed behaviour. The ruleset is

Code: Select all

Site */omniture/s_code.js
Accept from *.fnfg.com fnfg.com
Deny
Site */s_code.js
Deny
This ruleset is meant to deny execution of the Omniture "s_code.js" tracking script, while allowing such on a single site ("fnfg.com") (a bank). I recently noticed that the site https://myservices.timewarnercable.com/ had added

Code: Select all

https://myservices.timewarnercable.com/js/omniture/s_code.js
and the error console does not reflect the ABE rule blocking message. I updated the ruleset to

Code: Select all

Site */js/omniture/s_code.js
Accept from *.fnfg.com fnfg.com
Deny
Site */omniture/s_code.js
Accept from *.fnfg.com fnfg.com
Deny
Site */s_code.js
Deny
and the error console reflected

Code: Select all

[ABE] <*/js/omniture/s_code.js> Deny on {GET https://myservices.timewarnercable.com/js/omniture/s_code.js <<< https://myservices.timewarnercable.com/, https://myservices.timewarnercable.com/ - 2}
USER rule:
Site */js/omniture/s_code.js
Deny
which was the desired effect.

Was I incorrect in my understanding of the leading "*/" in the ruleset ? I had understood that "*/s_code.js" would block any URL not specifically allowed, using right-to-left priorities ("s_code.js" would be blocked regardless of the depth of sub-directory nesting. Should that not be the case, my ABE ruleset would need to be updated for the various forms of this code used in different sites.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16) Gecko/20110319 SUSE/3.6.16-1.1 Firefox/3.6.16
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: ABE Script-blocking

Post by al_9x »

NS turns these patterns into RXs, which you can examine (eval the following in error console, substituting your pattern for {pattern}):

Code: Select all

Components.classes["@maone.net/noscript-service;1"].getService().wrappedJSObject.__parent__.eval("new AddressMatcher('{pattern}').rx")
and test:

Code: Select all

Components.classes["@maone.net/noscript-service;1"].getService().wrappedJSObject.__parent__.eval("new AddressMatcher('{pattern}').test('{url}')")
"*/s_code.js" produces "/^[a-z]\w+:\/\/[^\/]*?\/s_code\.js$/"

which shows that when you are specifying a path pattern, you have to match the first / in the path. Not sure this is deliberate, Giorgio?
so "*/js/omniture/s_code.js" will work, and also "*/*/s_code.js"

I don't think (all the nuances of) AddressMatcher behavior is clearly specified in NS docs, so when in doubt you can try to use RXs directly:

Code: Select all

Site ^.*/s_code.js$
Deny
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: ABE Script-blocking

Post by Giorgio Maone »

al_9x wrote: Not sure this is deliberate, Giorgio?
It is, so you can specify an absolute path on any domain.

First aster matches domain only, second aster matches path and anchors the next string to the right, unless another aster is found.
al_9x wrote:so "*/js/omniture/s_code.js" will work, and also "*/*/s_code.js"
**/s_code.js will work as well, and will match any path before s_code.js.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
User avatar
SeanM
Junior Member
Posts: 44
Joined: Fri Jul 24, 2009 1:42 pm
Location: Upstate, New York USA

Re: ABE Script-blocking

Post by SeanM »

Giorgio Maone wrote: **/s_code.js will work as well, and will match any path before s_code.js.
Spot on! That reduces a rather cumbersome ruleset to:

Code: Select all

Site **/s_code.js
Accept from *.fnfg.com fnfg.com
Deny
Should I come upon other sites that need this, a single "Accept" is all that is needed!

Thank you Al and Giorgio !
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16) Gecko/20110319 SUSE/3.6.16-1.1 Firefox/3.6.16
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: ABE Script-blocking

Post by Giorgio Maone »

SeanM wrote:
Giorgio Maone wrote: Spot on! That reduces a rather cumbersome ruleset to:

Code: Select all

Site **/s_code.js
Accept from *.fnfg.com fnfg.com
Deny
You can further reduce it thanks to (*.fnfg.com fnfg.com) = .fnfg.com:

Code: Select all

Site **/s_code.js
Accept from .fnfg.com
Deny
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Post Reply