From f38c582d6521427c644b84b62c961cdc47dbdf58 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Tue, 21 Jan 2025 23:20:41 +0100 Subject: [PATCH 01/37] Add top level properties --- .../json/DeclarativeNetRequestRuleset.json | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/schemas/json/DeclarativeNetRequestRuleset.json diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json new file mode 100644 index 00000000000..dfd35e77504 --- /dev/null +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "array", + "items": { + "required": [ + "id" + ], + "properties": { + "id": { + "type": "number", + "description": "An ID that uniquely identifies a rule within a ruleset. Mandatory and should be >= 1" + }, + "priority": { + "type": "number", + "description": "The rule priority. When specified, it should be >= 1. Defaults to 1. See Matching precedence for details on how priority affects which rules are applied.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#matching_precedence", + "default": 1, + "minimum": 1 + }, + "condition": { + "type": "object", + "description": "The condition under which this rule is triggered." + }, + "action": { + "type": "object", + "description": "The action to take when the rule is matched. Rules can do one of these things:\nblock a network request.\nredirect a network request.\nmodify headers from a network request.\nprevent another matching rule from being applied.\n\nNote: A redirect action does not redirect the request, and the request continues as usual when:\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of redirect.regexSubstitution is not a valid URL)." + } + } + } +} From d7b99f755d124ce7318deeaeae89f552c755c64b Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:11:55 +0100 Subject: [PATCH 02/37] Add top level description --- src/schemas/json/DeclarativeNetRequestRuleset.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index dfd35e77504..2aacaa9fa4c 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", + "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", "items": { "required": [ "id" From 9572c0ebde63691e04b484a3b164bce59091465e Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:15:58 +0100 Subject: [PATCH 03/37] Add maximum --- src/schemas/json/DeclarativeNetRequestRuleset.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 2aacaa9fa4c..0a92dc4448b 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -1,7 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", - "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", + "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nItem number limited by MAX_NUMBER_OF_STATIC_RULESETS https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/MAX_NUMBER_OF_STATIC_RULESETS\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", + "maxItems": 50, "items": { "required": [ "id" From 0934961e3d423423ed803ca05a78b7250a074717 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:20:20 +0100 Subject: [PATCH 04/37] Add domainType property --- src/schemas/json/DeclarativeNetRequestRuleset.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 0a92dc4448b..1b8f932b800 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -20,7 +20,16 @@ }, "condition": { "type": "object", - "description": "The condition under which this rule is triggered." + "description": "The condition under which this rule is triggered.", + "properties": { + "domainType": { + "type": "string", + "description": "Specifies whether the network request is first-party or third-party. The request is considered first-party if it's for the same domain as the document or subdocument that initiates the request. Otherwise, it's considered third-party.", + "enum": [ + "first-party", + "third-party" + ] + }, }, "action": { "type": "object", From 3991a892cf0349655241ec55f595bac5c463361b Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:25:23 +0100 Subject: [PATCH 05/37] Add domains definition --- src/schemas/json/DeclarativeNetRequestRuleset.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 1b8f932b800..9df59747603 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -3,6 +3,15 @@ "type": "array", "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nItem number limited by MAX_NUMBER_OF_STATIC_RULESETS https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/MAX_NUMBER_OF_STATIC_RULESETS\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", "maxItems": 50, + "definitions": { + "domains": { + "type": "array", + "items": { + "type": "string", + "description": "Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:\n\nSub-domains such as \"a.example.com\" are allowed.\nThe entries must consist of only lowercase ASCII characters.\nUse Punycode encoding for internationalized domains.\nIPv4 addresses must be represented as 4 numbers separated by a dot.\nIPv6 addresses should be represented in their canonical form, wrapped in square brackets.\n\nTo programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#canonical_domain" + } + } + }, "items": { "required": [ "id" From b86490b9ff06099962e7704d902730e40d94cd98 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:33:44 +0100 Subject: [PATCH 06/37] Create canonical domain regex --- src/schemas/json/DeclarativeNetRequestRuleset.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 9df59747603..4393a12b335 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -8,6 +8,8 @@ "type": "array", "items": { "type": "string", + "pattern": "^(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)|(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,63}|((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}|\\[(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\\])$", + "$comment": "https://regexr.com/8b9gm", "description": "Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:\n\nSub-domains such as \"a.example.com\" are allowed.\nThe entries must consist of only lowercase ASCII characters.\nUse Punycode encoding for internationalized domains.\nIPv4 addresses must be represented as 4 numbers separated by a dot.\nIPv6 addresses should be represented in their canonical form, wrapped in square brackets.\n\nTo programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#canonical_domain" } } From 8ffe2ddece0d310d1c71eb8c62cb003e292d0def Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:39:04 +0100 Subject: [PATCH 07/37] Add domains related properties --- src/schemas/json/DeclarativeNetRequestRuleset.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 4393a12b335..90287916fa2 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -41,6 +41,19 @@ "third-party" ] }, + "domains": { + "$ref": "#/definitions/domains", + "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains." + }, + "excludeDomains": { + "$ref": "#/definitions/domains", + "description": "Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains." + }, + "excludedInitiatorDomains": { + "$ref": "#/definitions/domains", + "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. A canonical domain should be used. This matches against the request initiator and not the request URL." + } + } }, "action": { "type": "object", From e7e9a89e71168a7ceb3a89fcba156cfc27e58e11 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:43:03 +0100 Subject: [PATCH 08/37] Add docs links --- src/schemas/json/DeclarativeNetRequestRuleset.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 90287916fa2..d2d13a40c65 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -43,15 +43,16 @@ }, "domains": { "$ref": "#/definitions/domains", - "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains." + "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domains" }, "excludeDomains": { "$ref": "#/definitions/domains", - "description": "Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains." + "description": "Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludeddomains" + }, }, "excludedInitiatorDomains": { "$ref": "#/definitions/domains", - "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. A canonical domain should be used. This matches against the request initiator and not the request URL." + "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. A canonical domain should be used. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedinitiatordomains" } } }, From 5d6622786fc170cc37fb910efeda95c964ed59e6 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:43:10 +0100 Subject: [PATCH 09/37] Add missing property --- src/schemas/json/DeclarativeNetRequestRuleset.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index d2d13a40c65..0796731e497 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -49,6 +49,9 @@ "$ref": "#/definitions/domains", "description": "Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludeddomains" }, + "initiatorDomains": { + "$ref": "#/definitions/domains", + "description": "The rule only matches network requests originating from this list of domains. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed. A canonical domain should be used. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#initiatordomains" }, "excludedInitiatorDomains": { "$ref": "#/definitions/domains", From 6356bb4cf41eb74712b06907d89426a066743a61 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:47:38 +0100 Subject: [PATCH 10/37] generalize stringArray --- .../json/DeclarativeNetRequestRuleset.json | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 0796731e497..98ff3ce1496 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -4,10 +4,15 @@ "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nItem number limited by MAX_NUMBER_OF_STATIC_RULESETS https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/MAX_NUMBER_OF_STATIC_RULESETS\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", "maxItems": 50, "definitions": { - "domains": { + "stringArray": { "type": "array", "items": { - "type": "string", + "type": "string" + } + }, + "canonicalDomain": { + "$ref": "#/definitions/stringArray", + "items": { "pattern": "^(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)|(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,63}|((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}|\\[(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\\])$", "$comment": "https://regexr.com/8b9gm", "description": "Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:\n\nSub-domains such as \"a.example.com\" are allowed.\nThe entries must consist of only lowercase ASCII characters.\nUse Punycode encoding for internationalized domains.\nIPv4 addresses must be represented as 4 numbers separated by a dot.\nIPv6 addresses should be represented in their canonical form, wrapped in square brackets.\n\nTo programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#canonical_domain" @@ -42,20 +47,32 @@ ] }, "domains": { - "$ref": "#/definitions/domains", + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domains" }, "excludeDomains": { - "$ref": "#/definitions/domains", + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, "description": "Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludeddomains" }, "initiatorDomains": { - "$ref": "#/definitions/domains", - "description": "The rule only matches network requests originating from this list of domains. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed. A canonical domain should be used. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#initiatordomains" + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, + "description": "The rule only matches network requests originating from this list of domains. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#initiatordomains" }, "excludedInitiatorDomains": { - "$ref": "#/definitions/domains", - "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. A canonical domain should be used. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedinitiatordomains" + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, + "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedinitiatordomains" } } }, From bb05f21211783724f004e0f66b85b68e4ecb23f8 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:48:32 +0100 Subject: [PATCH 11/37] Add missing sentence and link --- src/schemas/json/DeclarativeNetRequestRuleset.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 98ff3ce1496..64ddb9bf7de 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -40,7 +40,7 @@ "properties": { "domainType": { "type": "string", - "description": "Specifies whether the network request is first-party or third-party. The request is considered first-party if it's for the same domain as the document or subdocument that initiates the request. Otherwise, it's considered third-party.", + "description": "Specifies whether the network request is first-party or third-party. The request is considered first-party if it's for the same domain as the document or subdocument that initiates the request. Otherwise, it's considered third-party. If omitted, all requests are accepted.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domaintype", "enum": [ "first-party", "third-party" From 7ae389f40c270304a902c640a6a89ca35f22c1bb Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:48:40 +0100 Subject: [PATCH 12/37] Mark explicitly as deprecated --- src/schemas/json/DeclarativeNetRequestRuleset.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 64ddb9bf7de..103dca1b87e 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -47,6 +47,7 @@ ] }, "domains": { + "deprecated": true, "$ref": "#/definitions/stringArray", "items": { "$ref": "#/definitions/canonicalDomain" @@ -54,6 +55,7 @@ "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domains" }, "excludeDomains": { + "deprecated": true, "$ref": "#/definitions/stringArray", "items": { "$ref": "#/definitions/canonicalDomain" From 2b380653dc95943fdd2d1999337a0392a68b5d3e Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:51:07 +0100 Subject: [PATCH 13/37] fix typo --- src/schemas/json/DeclarativeNetRequestRuleset.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 103dca1b87e..0339c9ab777 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -54,7 +54,7 @@ }, "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domains" }, - "excludeDomains": { + "excludedDomains": { "deprecated": true, "$ref": "#/definitions/stringArray", "items": { From 6124f1b2929beabff383f236e32fa4a3db5ea463 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:51:39 +0100 Subject: [PATCH 14/37] add more properties --- src/schemas/json/DeclarativeNetRequestRuleset.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 0339c9ab777..58f79b927ab 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -75,6 +75,18 @@ "$ref": "#/definitions/canonicalDomain" }, "description": "The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. This matches against the request initiator and not the request URL.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedinitiatordomains" + }, + "isUrlFilterCaseSensitive": { + "type": "boolean", + "description": "Whether the urlFilter or regexFilter (whichever is specified) is case sensitive. While there is consensus on defaulting to false across browsers in WECG issue 269, the value used to be true in (older) versions of Chrome and Safari. See Browser compatibility for details.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#isurlfiltercasesensitive", + "default": false + }, + "requestDomains": { + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, + "description": "The rule only matches network requests when the domain matches one from this list. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#requestdomains" } } }, From 68c6055b5542564fd64e8e0e34be2a084729acd8 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:56:05 +0100 Subject: [PATCH 15/37] Define requestMethod --- .../json/DeclarativeNetRequestRuleset.json | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 58f79b927ab..6ab77ab3c4b 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -17,6 +17,50 @@ "$comment": "https://regexr.com/8b9gm", "description": "Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:\n\nSub-domains such as \"a.example.com\" are allowed.\nThe entries must consist of only lowercase ASCII characters.\nUse Punycode encoding for internationalized domains.\nIPv4 addresses must be represented as 4 numbers separated by a dot.\nIPv6 addresses should be represented in their canonical form, wrapped in square brackets.\n\nTo programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#canonical_domain" } + }, + "requestMethod": { + "$comment": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods", + "oneOf": [ + { + "const": "GET", + "description": "The GET method requests a representation of the specified resource. Requests using GET should only retrieve data and should not contain a request content.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET" + }, + { + "const": "HEAD", + "description": "The HEAD method asks for a response identical to a GET request, but without a response body.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD" + }, + { + "const": "POST", + "description": "The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST" + }, + { + "const": "PUT", + "description": "The PUT method replaces all current representations of the target resource with the request content.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT" + }, + { + "const": "DELETE", + "description": "The DELETE method deletes the specified resource.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE" + }, + { + "const": "CONNECT", + "description": "The CONNECT method establishes a tunnel to the server identified by the target resource.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT" + }, + { + "const": "OPTIONS", + "description": "The OPTIONS method describes the communication options for the target resource.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS" + }, + { + "const": "TRACE", + "description": "The TRACE method performs a message loop-back test along the path to the target resource.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE" + }, + { + "const": "PATCH", + "description": "The PATCH method applies partial modifications to a resource.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH" + } + ] + }, + "headerInfo": { + "type": "object" } }, "items": { From 368a6dd3f36f5899ea3f7efa60d59b6a47622008 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:02:53 +0100 Subject: [PATCH 16/37] Add exclusive properties --- .../json/DeclarativeNetRequestRuleset.json | 83 +++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 6ab77ab3c4b..218b4ff237d 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -132,12 +132,85 @@ }, "description": "The rule only matches network requests when the domain matches one from this list. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#requestdomains" } - } - }, - "action": { - "type": "object", - "description": "The action to take when the rule is matched. Rules can do one of these things:\nblock a network request.\nredirect a network request.\nmodify headers from a network request.\nprevent another matching rule from being applied.\n\nNote: A redirect action does not redirect the request, and the request continues as usual when:\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of redirect.regexSubstitution is not a valid URL)." + }, + "allOf": [ + { + "oneOf": [ + { + "properties": { + "regexFilter": { + "type": "string", + "description": "Regular expression to match against the network request URL. Note that:\n\nThe supported format is not stable and varies across browsers, see \"Regular expressions in DNR API (regexFilter)\" in WECG issue 344 for details.\nThe regexFilter must be composed of only ASCII characters. This is matched against a URL where the host is encoded in the punycode format (in case of internationalized domains) and any other non-ascii characters are percent-encoded in UTF-8.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#regexfilter" + } + } + }, + { + "properties": { + "urlFilter": { + "description": "The pattern that is matched against the network request URL. Supported constructs:\n\n* : Wildcard: Matches any number of characters.\n| : Left or right anchor: If used at either end of the pattern, specifies the beginning or end of the URL respectively.\n|| : Domain name anchor: If used at the beginning of the pattern, specifies the start of a (sub-)domain of the URL.\n^ : Separator character: This matches anything except a letter, a digit, or one of _, -, ., or %. The last ^ may also match the end of the URL instead of a separator character.\n\nurlFilter is composed of the following parts: (optional left/domain name anchor) + pattern + (optional right anchor). If omitted, all URLs are matched. An empty string is not allowed. A pattern beginning with ||* is not allowed. Use * instead. Note that:\nThe urlFilter must be composed of only ASCII characters. This is matched against a URL where the host is encoded in the punycode format (in case of internationalized domains) and any other non-ASCII characters are percent-encoded in UTF-8. For example, when the request URL is http://abc.рф?q=ф, the urlFilter is matched against the URL http://abc.xn--p1ai/?q=%D1%84.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#urlfilter" + } + } + } + ] + }, + { + "oneOf": [ + { + "properties": { + "requestMethods": { + "$ref": "#/definitions/stringArray", + "description": "List of HTTP request methods that the rule matches. An empty list is not allowed. Specifying a requestMethods rule condition also excludes non-HTTP(s) requests, whereas specifying excludedRequestMethods does not.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#requestmethods", + "items": { + "$ref": "#/definitions/requestMethod" + } + } + } + }, + { + "properties": { + "excludedRequestMethods": { + "$ref": "#/definitions/stringArray", + "description": "List of request methods that the rule does not match on. Only one of requestMethods and excludedRequestMethods should be specified. If neither of them is specified, all request methods are matched.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedrequestmethods", + "items": { + "$ref": "#/definitions/requestMethod" + } + } + } + } + ] + }, + { + "oneOf": [ + { + "properties": { + "resourceTypes": { + "type": "array", + "description": "List of resource types that the rule matches with. An empty list is not allowed. This must be specified for \"allowAllRequests\" rules and may only include the \"sub_frame\" and \"main_frame\" resource types.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#resourcetypes", + "items": { + "$ref": "#/definitions/resourceType" + } + } + } + }, + { + "properties": { + "excludedResourceTypes": { + "type": "array", + "description": "List of resource types that the rule does not match on. Only one of resourceTypes and excludedResourceTypes should be specified. If neither of them is specified, all resource types except \"main_frame\" are blocked.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedresourcetypes", + "items": { + "$ref": "#/definitions/resourceType" + } + } + } + } + ] + } + ] } + }, + "action": { + "type": "object", + "description": "The action to take when the rule is matched. Rules can do one of these things:\nblock a network request.\nredirect a network request.\nmodify headers from a network request.\nprevent another matching rule from being applied.\n\nNote: A redirect action does not redirect the request, and the request continues as usual when:\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of redirect.regexSubstitution is not a valid URL)." } } } From 760c74495998b38815354ad9e7fac8a69e8652ff Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:07:41 +0100 Subject: [PATCH 17/37] Add remaining properties --- .../json/DeclarativeNetRequestRuleset.json | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 218b4ff237d..2a119a19f76 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -61,6 +61,19 @@ }, "headerInfo": { "type": "object" + }, + "tabId": { + "oneOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "const": -1, + "$comment": "Value found in https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json#151", + "description": "tabs.TAB_ID_NONE\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/TAB_ID_NONE" + } + ] } }, "items": { @@ -131,6 +144,41 @@ "$ref": "#/definitions/canonicalDomain" }, "description": "The rule only matches network requests when the domain matches one from this list. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#requestdomains" + }, + "excludedRequestDomains": { + "$ref": "#/definitions/stringArray", + "items": { + "$ref": "#/definitions/canonicalDomain" + }, + "description": "The rule does not match network requests when the domains matches one from this list. If the list is empty or omitted, no domains are excluded. This takes precedence over requestDomains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedrequestdomains" + }, + "responseHeaders": { + "$ref": "#/definitions/stringArray", + "description": "The rule matches if the request matches any response header condition in this list (if specified).\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#responseheaders", + "items": { + "$ref": "#/definitions/headerInfo" + } + }, + "excludedResponseHeaders": { + "$ref": "#/definitions/stringArray", + "description": "he rule does not match if the request matches any response header condition in this list (if specified). If both excludedResponseHeaders and responseHeaders are specified, then the excludedResponseHeaders property takes precedence.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#responseheaders", + "items": { + "$ref": "#/definitions/headerInfo" + } + }, + "tabIds": { + "type": "array", + "description": "List of tabs.Tab.id that the rule should match. An ID of tabs.TAB_ID_NONE matches requests that don't originate from a tab. An empty list is not allowed. Only supported for session-scoped rules.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#tabids", + "items": { + "$ref": "#/definitions/tabId" + } + }, + "excludedTabIds": { + "type": "array", + "description": "List of tabs.Tab.id that the rule should not match. An ID of tabs.TAB_ID_NONE excludes requests that do not originate from a tab. Only supported for session-scoped rules.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#excludedtabids", + "items": { + "$ref": "#/definitions/tabId" + } } }, "allOf": [ From f82cf2b0dfabce60f52c9bce3bbc09426ca22a9c Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:12:56 +0100 Subject: [PATCH 18/37] Specify HeaderInfo --- .../json/DeclarativeNetRequestRuleset.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 2a119a19f76..50c67f1cec5 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -60,7 +60,23 @@ ] }, "headerInfo": { - "type": "object" + "type": "object", + "description": "The response header to match for the request, declared in the rule.condition.excludedResponseHeaders array or rule.condition.responseHeaders array. If specified, the array must be non-empty.\nWhen used in the condition responseHeaders, the rule matches if the request matches this response header condition. When used in the condition excludedResponseHeaders, the rule does not match if the request matches this response header condition.\nEach object describes one header to match or exclude. To check multiple headers, multiple objects can be specified in these arrays, or across multiple rules.\n\nNote: Matching by headers is a relatively new feature. Make sure to feature-detect its availability before relying on it. While some browsers ignore the complete rule when an unrecognized condition is present, Chrome 121 until 127 applied the whole rule while ignoring theresponseHeaders condition. This could result in matching more requests than intended, see Chromium issue 347186592.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo", + "required": ["header"], + "properties": { + "header": { + "type": "string", + "description": "The name of the header. This condition matches on the name only if both values and excludedValues are not specified.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo#header" + }, + "values": { + "$ref": "#/definitions/stringArray", + "description": "If specified, this condition matches if the header's value matches at least one pattern in this list. This supports case-insensitive header value matching plus the following constructs:\n\n'*' : Matches any number of characters.\n'?' : Matches zero or one character(s).\n'*' and '?' can be escaped with a backslash, e.g. '\\*' and '\\?'.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo#values" + }, + "excludedValues": { + "$ref": "#/definitions/stringArray", + "description": "If specified, this condition is not matched if the header exists but its value contains at least one element in this list. This uses the same glob pattern syntax as values. If values and excludedValues are both matched, then excludedValues takes precedence.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo#excludedValues" + } + } }, "tabId": { "oneOf": [ From 71e0802ab6cc87abf698a6125cb16718892c62d8 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:20:55 +0100 Subject: [PATCH 19/37] formatting --- src/schemas/json/DeclarativeNetRequestRuleset.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index 50c67f1cec5..df3f672d46a 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -62,7 +62,9 @@ "headerInfo": { "type": "object", "description": "The response header to match for the request, declared in the rule.condition.excludedResponseHeaders array or rule.condition.responseHeaders array. If specified, the array must be non-empty.\nWhen used in the condition responseHeaders, the rule matches if the request matches this response header condition. When used in the condition excludedResponseHeaders, the rule does not match if the request matches this response header condition.\nEach object describes one header to match or exclude. To check multiple headers, multiple objects can be specified in these arrays, or across multiple rules.\n\nNote: Matching by headers is a relatively new feature. Make sure to feature-detect its availability before relying on it. While some browsers ignore the complete rule when an unrecognized condition is present, Chrome 121 until 127 applied the whole rule while ignoring theresponseHeaders condition. This could result in matching more requests than intended, see Chromium issue 347186592.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo", - "required": ["header"], + "required": [ + "header" + ], "properties": { "header": { "type": "string", @@ -277,4 +279,4 @@ "description": "The action to take when the rule is matched. Rules can do one of these things:\nblock a network request.\nredirect a network request.\nmodify headers from a network request.\nprevent another matching rule from being applied.\n\nNote: A redirect action does not redirect the request, and the request continues as usual when:\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of redirect.regexSubstitution is not a valid URL)." } } -} +} \ No newline at end of file From d5407693d22df9270293aca2afdd2cbf7d1de6bf Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:03:58 +0100 Subject: [PATCH 20/37] Add action --- .../json/DeclarativeNetRequestRuleset.json | 149 +++++++++++++++++- 1 file changed, 145 insertions(+), 4 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index df3f672d46a..dc7a063115e 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -272,11 +272,152 @@ ] } ] + }, + "action": { + "type": "object", + "description": "Details of the action to take if a rule is matched, as the action property of a declarativeNetRequest.Rule.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleAction", + "required": [ + "type" + ], + "if": { + "properties": { + "type": { + "const": "redirect" + } + } + }, + "then": { + "properties": { + "redirect": { + "description": "Details describing how a redirect should be performed.\nNote: A redirect action does not redirect the request, and the request continues as usual when:\n\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of regexSubstitution is not a valid URL).\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect", + "properties": { + "extensionPath": { + "type": "string", + "description": "The path relative to the extension directory. Should start with '/'. The initiator of the request can only follow the redirect when the resource is listed in web_accessible_resources.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect#extensionPath" + }, + "regexSubstitution": { + "type": "string", + "description": " The substitution pattern for rules that specify a regexFilter. The first match of regexFilter within the URL is replaced with this pattern. Within regexSubstitution, backslash-escaped digits (\\1 to \\9) are used to insert the corresponding capture groups. \\0 refers to the entire matching text.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect#regexSubstitution" + }, + "transform": { + "type": "object", + "description": "Details describing a URL transformation to perform for a redirect rule.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect#transform", + "properties": { + "fragment": { + "type": "string", + "description": "The new fragment for the request. Should be either empty, in which case the existing fragment is cleared; or should begin with '#'.'\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#fragment", + "pattern": "^$|^#.*$", + "$comment": "https://regexr.com/8b9io" + }, + "host": { + "type": "string", + "description": "The new host name for the request.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#host" + }, + "password": { + "type": "string", + "description": "The new password for the request.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#password" + }, + "path": { + "type": "string", + "description": "The new path for the request. If empty, the existing path is cleared.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#path" + }, + "port": { + "type": "string", + "description": "The new port for the request. If empty, the existing port is cleared.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#port" + }, + "scheme": { + "description": "The new scheme for the request. Allowed values are \"http\", \"https\", and the scheme of the extension, for example, \"moz-extension\" in Firefox or \"chrome-extension\" in Chrome. When the extension scheme is used, the host must be specified to generate a meaningful redirection target.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#scheme", + "$comment": "TODO: Require host when extension scheme is used.", + "oneOf": [ + { + "const": "http" + }, + { + "const": "https" + }, + { + "const": "moz-extension" + }, + { + "const": "chrome-extension" + }, + { + "type": "string", + "$comment": "allow for other extension schemes" + } + ] + }, + "username": { + "type": "string", + "description": "The new username for the request.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#username" + } + } + }, + "url": { + "type": "string", + "description": "The redirect URL. Redirects to JavaScript URLs are not allowed.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect#url" + } + }, + "oneOf": [ + { + "properties": { + "query": { + "type": "string", + "description": "The new query for the request. Should be either empty, in which case the existing query is cleared; or should begin with '?'.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#query", + "pattern": "^$|^\\?(?:[^&]*&)*$", + "$comment": "https://regexr.com/8b9j4" + } + } + }, + { + "properties": { + "queryTransform": { + "description": "An object describing how to add, remove, or replace query key-value pairs.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#queryTransform", + "type": "object", + "properties": { + "addOrReplaceParams": { + "description": "An array of objects describing the list of query key-value pairs to be added or replaced.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#adddorreplaceparams", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "The key to add or replace in the query.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#key" + }, + "replaceOnly": { + "oneOf": [ + { + "const": true, + "description": "The query key is replaced only if it's already present.https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#replaceonly" + }, + { + "const": false, + "description": "The key is also added if it's missing.https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#replaceonly" + } + ], + "default": false + }, + "value": { + "type": "string", + "description": "The value value.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#value", + "$comment": "The value value??" + } + } + } + }, + "removeParams": { + "$ref": "#/definitions/stringArray", + "description": "The list of query keys to be removed.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#removeparams" + } + } + } + } + } + ] + } + } + } } - }, - "action": { - "type": "object", - "description": "The action to take when the rule is matched. Rules can do one of these things:\nblock a network request.\nredirect a network request.\nmodify headers from a network request.\nprevent another matching rule from being applied.\n\nNote: A redirect action does not redirect the request, and the request continues as usual when:\nthe action does not change the request.\nthe redirect URL is invalid (e.g., the value of redirect.regexSubstitution is not a valid URL)." } } } \ No newline at end of file From 0b6228e7b25a0ecc25f6efba48cbc4794bb5a92c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:11:46 +0000 Subject: [PATCH 21/37] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../json/DeclarativeNetRequestRuleset.json | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/DeclarativeNetRequestRuleset.json index dc7a063115e..449f1ea5f7c 100644 --- a/src/schemas/json/DeclarativeNetRequestRuleset.json +++ b/src/schemas/json/DeclarativeNetRequestRuleset.json @@ -13,8 +13,8 @@ "canonicalDomain": { "$ref": "#/definitions/stringArray", "items": { - "pattern": "^(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)|(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,63}|((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}|\\[(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\\])$", "$comment": "https://regexr.com/8b9gm", + "pattern": "^(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)|(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,63}|((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}|\\[(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\\])$", "description": "Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:\n\nSub-domains such as \"a.example.com\" are allowed.\nThe entries must consist of only lowercase ASCII characters.\nUse Punycode encoding for internationalized domains.\nIPv4 addresses must be represented as 4 numbers separated by a dot.\nIPv6 addresses should be represented in their canonical form, wrapped in square brackets.\n\nTo programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#canonical_domain" } }, @@ -62,9 +62,7 @@ "headerInfo": { "type": "object", "description": "The response header to match for the request, declared in the rule.condition.excludedResponseHeaders array or rule.condition.responseHeaders array. If specified, the array must be non-empty.\nWhen used in the condition responseHeaders, the rule matches if the request matches this response header condition. When used in the condition excludedResponseHeaders, the rule does not match if the request matches this response header condition.\nEach object describes one header to match or exclude. To check multiple headers, multiple objects can be specified in these arrays, or across multiple rules.\n\nNote: Matching by headers is a relatively new feature. Make sure to feature-detect its availability before relying on it. While some browsers ignore the complete rule when an unrecognized condition is present, Chrome 121 until 127 applied the whole rule while ignoring theresponseHeaders condition. This could result in matching more requests than intended, see Chromium issue 347186592.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/HeaderInfo", - "required": [ - "header" - ], + "required": ["header"], "properties": { "header": { "type": "string", @@ -87,17 +85,15 @@ "minimum": 0 }, { - "const": -1, "$comment": "Value found in https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json#151", + "const": -1, "description": "tabs.TAB_ID_NONE\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/TAB_ID_NONE" } ] } }, "items": { - "required": [ - "id" - ], + "required": ["id"], "properties": { "id": { "type": "number", @@ -116,22 +112,19 @@ "domainType": { "type": "string", "description": "Specifies whether the network request is first-party or third-party. The request is considered first-party if it's for the same domain as the document or subdocument that initiates the request. Otherwise, it's considered third-party. If omitted, all requests are accepted.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domaintype", - "enum": [ - "first-party", - "third-party" - ] + "enum": ["first-party", "third-party"] }, "domains": { - "deprecated": true, "$ref": "#/definitions/stringArray", + "deprecated": true, "items": { "$ref": "#/definitions/canonicalDomain" }, "description": "Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition#domains" }, "excludedDomains": { - "deprecated": true, "$ref": "#/definitions/stringArray", + "deprecated": true, "items": { "$ref": "#/definitions/canonicalDomain" }, @@ -276,9 +269,7 @@ "action": { "type": "object", "description": "Details of the action to take if a rule is matched, as the action property of a declarativeNetRequest.Rule.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleAction", - "required": [ - "type" - ], + "required": ["type"], "if": { "properties": { "type": { @@ -304,10 +295,10 @@ "description": "Details describing a URL transformation to perform for a redirect rule.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/Redirect#transform", "properties": { "fragment": { + "$comment": "https://regexr.com/8b9io", "type": "string", "description": "The new fragment for the request. Should be either empty, in which case the existing fragment is cleared; or should begin with '#'.'\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#fragment", - "pattern": "^$|^#.*$", - "$comment": "https://regexr.com/8b9io" + "pattern": "^$|^#.*$" }, "host": { "type": "string", @@ -326,8 +317,8 @@ "description": "The new port for the request. If empty, the existing port is cleared.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#port" }, "scheme": { - "description": "The new scheme for the request. Allowed values are \"http\", \"https\", and the scheme of the extension, for example, \"moz-extension\" in Firefox or \"chrome-extension\" in Chrome. When the extension scheme is used, the host must be specified to generate a meaningful redirection target.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#scheme", "$comment": "TODO: Require host when extension scheme is used.", + "description": "The new scheme for the request. Allowed values are \"http\", \"https\", and the scheme of the extension, for example, \"moz-extension\" in Firefox or \"chrome-extension\" in Chrome. When the extension scheme is used, the host must be specified to generate a meaningful redirection target.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#scheme", "oneOf": [ { "const": "http" @@ -342,8 +333,8 @@ "const": "chrome-extension" }, { - "type": "string", - "$comment": "allow for other extension schemes" + "$comment": "allow for other extension schemes", + "type": "string" } ] }, @@ -362,10 +353,10 @@ { "properties": { "query": { + "$comment": "https://regexr.com/8b9j4", "type": "string", "description": "The new query for the request. Should be either empty, in which case the existing query is cleared; or should begin with '?'.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#query", - "pattern": "^$|^\\?(?:[^&]*&)*$", - "$comment": "https://regexr.com/8b9j4" + "pattern": "^$|^\\?(?:[^&]*&)*$" } } }, @@ -398,9 +389,9 @@ "default": false }, "value": { + "$comment": "The value value??", "type": "string", - "description": "The value value.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#value", - "$comment": "The value value??" + "description": "The value value.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform#value" } } } @@ -420,4 +411,4 @@ } } } -} \ No newline at end of file +} From 2ab60aa7022b2df0a6b0eeda604a925a6d8e9a0c Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:16:15 +0100 Subject: [PATCH 22/37] rename to fit convention --- ...uestRuleset.json => declarative-net-request-ruleset.json.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/schemas/json/{DeclarativeNetRequestRuleset.json => declarative-net-request-ruleset.json.json} (100%) diff --git a/src/schemas/json/DeclarativeNetRequestRuleset.json b/src/schemas/json/declarative-net-request-ruleset.json.json similarity index 100% rename from src/schemas/json/DeclarativeNetRequestRuleset.json rename to src/schemas/json/declarative-net-request-ruleset.json.json From 25a040cbb9a10f29e2386b07871c0d76ed6138a3 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:20:22 +0100 Subject: [PATCH 23/37] bruh moment --- ...est-ruleset.json.json => declarative-net-request-ruleset.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/schemas/json/{declarative-net-request-ruleset.json.json => declarative-net-request-ruleset.json} (100%) diff --git a/src/schemas/json/declarative-net-request-ruleset.json.json b/src/schemas/json/declarative-net-request-ruleset.json similarity index 100% rename from src/schemas/json/declarative-net-request-ruleset.json.json rename to src/schemas/json/declarative-net-request-ruleset.json From 078d2822d26776e642cce526773c25ab4968a99a Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:20:34 +0100 Subject: [PATCH 24/37] add id --- src/schemas/json/declarative-net-request-ruleset.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schemas/json/declarative-net-request-ruleset.json b/src/schemas/json/declarative-net-request-ruleset.json index 449f1ea5f7c..a577df9fbe1 100644 --- a/src/schemas/json/declarative-net-request-ruleset.json +++ b/src/schemas/json/declarative-net-request-ruleset.json @@ -1,5 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://json.schemastore.org/declarative-net-request-ruleset.json", "type": "array", "description": "A Collection of rules defined with the \"declarative_net_request\" manifest key and stored in the extension. An extension can enable and disable static rulesets using updateEnabledRulesets. The set of enabled static rulesets is persisted across sessions but not across extension updates. The static rulesets enabled on extension installation and update are determined by the content of the \"declarative_net_request\" manifest key.\n\nItem number limited by MAX_NUMBER_OF_STATIC_RULESETS https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/MAX_NUMBER_OF_STATIC_RULESETS\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rulesets", "maxItems": 50, From 4f18bbdebb7dc9075965217fa6b081cd89ca784f Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:23:51 +0100 Subject: [PATCH 25/37] add to catalog --- src/api/json/catalog.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/json/catalog.json b/src/api/json/catalog.json index f8bf2a0c800..78d1bc065b5 100644 --- a/src/api/json/catalog.json +++ b/src/api/json/catalog.json @@ -1131,6 +1131,11 @@ "fileMatch": ["**/*dbt*/{macros,models,seeds,snapshots}/**/*.{yaml,yml}"], "url": "https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_yml_files-latest.json" }, + { + "name": "declarativeNetRequest Ruleset", + "description": "Static ruleset for the JavaScript declarativeNetRequest API", + "url": "https://json.schemastore.org/declarative-net-request-ruleset.json" + }, { "name": "Dein Config", "description": "Dein.vim, a Vim/Neovim plugin manager", From eac427144a35bffc138dfa853741eef2bf00a0f8 Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:33:53 +0100 Subject: [PATCH 26/37] Add missing type declaration --- src/schemas/json/declarative-net-request-ruleset.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schemas/json/declarative-net-request-ruleset.json b/src/schemas/json/declarative-net-request-ruleset.json index a577df9fbe1..24ca3119960 100644 --- a/src/schemas/json/declarative-net-request-ruleset.json +++ b/src/schemas/json/declarative-net-request-ruleset.json @@ -94,6 +94,7 @@ } }, "items": { + "type": "object", "required": ["id"], "properties": { "id": { From 3f8d6ace5b517098b8a24839864a8079e82ddc9d Mon Sep 17 00:00:00 2001 From: Moritz Tim W <90388353+moritztim@users.noreply.github.com> Date: Wed, 22 Jan 2025 04:46:28 +0100 Subject: [PATCH 27/37] define resourceType --- .../json/declarative-net-request-ruleset.json | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/schemas/json/declarative-net-request-ruleset.json b/src/schemas/json/declarative-net-request-ruleset.json index 24ca3119960..7d38501963d 100644 --- a/src/schemas/json/declarative-net-request-ruleset.json +++ b/src/schemas/json/declarative-net-request-ruleset.json @@ -60,6 +60,99 @@ } ] }, + "resourceType": { + "$comment": "https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType", + "oneOf": [ + { + "const": "beacon", + "description": "Requests sent through the Beacon API.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#beacon" + }, + { + "const": "csp_report", + "description": "Requests sent to the report-uri given in the Content-Security-Policy header, when an attempt to violate the policy is detected.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#csp_report" + }, + { + "const": "font", + "description": "Web fonts loaded for a @font-face CSS rule.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#font" + }, + { + "const": "image", + "description": "Resources loaded to be rendered as image, except for imageset on browsers that support that type (see browser compatibility below).\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#image" + }, + { + "const": "imageset", + "description": "Images loaded by a element or given in an element's srcset attribute.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#imageset" + }, + { + "const": "main_frame", + "description": "Top-level documents loaded into a tab.\n\nhttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/ResourceType#main_frame" + }, + { + "const": "media", + "description": "Resources loaded by a