-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend "abort-*" scriptlets -- allow to check the stack trace #82
Comments
I had thought about the ability to use the stack information in the past for an abort scriptlet such as However having to add yet another parameter to many existing scriptlets is concerning. I now have this feeling that scriptlet syntax should have been resembling more procedural cosmetic filter syntax: a string of one or more condition operators leading to an action, example (don't mind the syntax too much, I came up with it as I wrote, just the overall idea):
This way to add a new condition requiring testing the stack would be merely adding a new simple and well defined condition operator (match against the stack) without having to change the syntax of existing scriptlet operators and without overloading them with ever more parameters. |
That would require massive refactoring and I'd better do that later. But generally, I think that the idea is really bright. Here are some thoughts on this. Currently, there are two important scriptlets groups:
The algorithm, in general, may look like this:
Here are some of the existing scriptlets written this way (don't mind the naming, I am coming up with this right now):
This approach makes adding new matching criteria really easy. Just a couple of examples that can be useful: Some scriptlets that cannot be categorized as "function", "property" or "matcher" will be categorized as "actions", and it should still be possible to apply some "matchers" to them. For instance:
|
Yes, there is great potential with this approach, for both sides, code maintainers (because we don't have to keep complicating scriplet units) and filter crafters (because of freedom to compose complex scriptlets).
Just to add to this, I was made aware of a case where
I think the best approach is to just slowly introduce a new syntax without refactoring the old one. Eventually the old one will be deprecated in some distant future. |
Regarding Could be like this:
|
I moved the initial spec description to #83 I agree that this new version may be introduced alongside the old scriptlets, and I'd like us (AG) to start working on it after we finish with v1.3. Also, I think it'd be convenient for everyone if we use the similar syntax for this type of rules in both uBO and AdGuard. Let's work on the spec together. If you're okay with this, I'll write up a more detailed spec in the coming days, and we can discuss the details. |
Yes, having filter list maintenance efforts easily shared across blockers with normalized syntax benefits everybody. |
This new scriplet has become necessary as a countermeasure to new bypass mechanisms by some websites, as discussed with filter list maintainers. Also related discussion: AdguardTeam/Scriptlets#82 Scriptlet: abort-on-stack-trace Alias: aost Argument 1: The property to trap in order to launch the stack trace matching code, ex. Math.random Argument 2: The string (needle) to match against the stack trace. If the empty string, always match. There is a special string which can be used to match inline script context, <inline-script>. Argument 3: Whether to log, and if so how: Empty string: do not log 1: log stack trace for all access to trapped property 2: log stack trace for defused access to trapped property 3: log stack trace for non-defused access to trapped property
This new scriplet has become necessary as a countermeasure to new bypass mechanisms by some websites, as discussed with filter list maintainers. Also related discussion: AdguardTeam/Scriptlets#82 Scriptlet: abort-on-stack-trace Alias: aost Argument 1: The property to trap in order to launch the stack trace matching code, ex. Math.random Argument 2: The string (needle) to match against the stack trace. If the empty string, always match. There is a special string which can be used to match inline script context, <inline-script>. Argument 3: Whether to log, and if so how: Empty string: do not log 1: log stack trace for all access to trapped property 2: log stack trace for defused access to trapped property 3: log stack trace for non-defused access to trapped property
…to master * commit 'a4baba50327fad7fe03a174d345001bcbe9d0ad3': delete comments edit readme fix building of scriptlets as cjs module slightly fix rollup add scriptlets as a cjs module refix gitignore get redirects.js back add convertAdgToUbo method and few tests for it make convert methods return array fix convertAbpToAdg, delete comments, up version add convertion (to adg), parsing and rule validation methods edit scriptlets validation method description fix scriptlet validation method in order to get 'name' as a string add validate interface for scriptlets
"abort-*" scriptlets are the source of numerous issues for several reasons, and I suppose the main one is that they don't allow filter maintainers to narrow them down to some specific part of the code we're trying to abort.
I suggest adding one more optional argument to the "abort-*" scriptlets so that we could use the current stack trace as a condition.
For example, here's how it would look like in the case of
abort-on-property-read
:stack
(optional) - string or regular expression that must match the current function call stack trace. Please find the stack trace example below.Here's a simple code snippet that shows how we should get the stack trace:
Here's an example of the stack trace:
For instance, if you want to abort the property read that happens in
test.js
only, you can add a rule like this:Additionally, we should extend
debug-on-property-read
anddebug-on-property-write
:stack
argument there too@AdguardTeam/filters-maintainers thoughts? Would you like
The text was updated successfully, but these errors were encountered: