Skip to content
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

Added trusted flag to the filters registry #562

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/index.js"
"program": "${workspaceFolder}/scripts/compose.js"
},
{
"type": "pwa-node",
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The files `/assets/filters.json` and `/assets/filters-dev.json` must not be edit
- `environment` - either `dev` or `prod`. Only `prod` lists are available in AdGuard DNS.
- `disabled` - if set to `true`, the blocklist won't be updated.
- `tags` — a list of [tags](#tags)
- `trusted` - a flag that allows using `$dnsrewrite` rules for this filter. If the filter is not trusted, `$dnsrewrite` rules will be removed from the compiled filter.

<details>
<summary>Metadata example</summary>
Expand All @@ -86,7 +87,8 @@ The files `/assets/filters.json` and `/assets/filters-dev.json` must not be edit
"expires": "4 days",
"displayNumber": 3,
"environment": "prod",
"tags": []
"tags": [],
"trusted": true
}
```

Expand Down
3 changes: 2 additions & 1 deletion filters/general/filter_1_DnsFilter/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"environment": "prod",
"tags": [
"purpose:general"
]
],
"trusted": true
}
3 changes: 2 additions & 1 deletion filters/general/filter_59_DnsPopupsFilter/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"environment": "prod",
"tags": [
"purpose:general"
]
],
"trusted": true
}
9 changes: 8 additions & 1 deletion hostlists-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,18 @@ async function build(filtersDir, tagsDir, localesDir, assetsDir, groupsDir) {
revision.setVersionCandidate();
revision.setTimeUpdatedCandidate();

const hostlistCompiled = await hostlistCompiler({
let hostlistCompiled = await hostlistCompiler({
...hostlistConfiguration,
version: revision.getVersionCandidate(),
});

if (!metadata.trusted) {
// Remove $dnsrewrite rules if the filter is not trusted.
hostlistCompiled = hostlistCompiled.filter((line) => {
return !line.includes('dnsrewrite=');
});
}

const hash = calculateRevisionHash(hostlistCompiled);

// Rewrites the filter if it's actually changed.
Expand Down
Loading