From 6c9a1a0aa03dcb68e469b097f31fbebff830bde1 Mon Sep 17 00:00:00 2001 From: Wouter van Wijk Date: Fri, 13 Nov 2026 09:30:39 +0100 Subject: [PATCH 1/2] Rebuild the cookie database from a pinned OCD, hide low-data scores, CSP script-src-elem - Cookie database: lib/utils/cookie_db.g.dart is generated by tool/gen_cookie_db.dart from the pinned Open Cookie Database CSV (tool/data). Wildcard comes from OCD's flag, longest prefix wins, hand-curated names live in cookie_overrides.dart. 19 social-platform cookies are classified as social by a documented rule. - Attribution: OCD Apache-2.0 text shown on the app's licenses page, THIRD_PARTY_NOTICES.md. - No score without enough data: Sovereignty needs 50% of the checks verified; Cookie Privacy Lens needs both cookie sources. - CSP: script-src-elem and script-src-attr fallback (CSP3). - Audit report: K10 (quoted ';') was a false finding, RFC 6265 5.2. Co-Authored-By: Claude Sonnet 5.5 --- THIRD_PARTY_NOTICES.md | 21 + .../licenses/open-cookie-database-LICENSE.txt | 201 + docs/audits/2026-11-berekeningen.md | 18 +- lib/main.dart | 14 + lib/screens/about_screen.dart | 15 +- lib/services/derive/cookies_view.dart | 13 +- lib/services/derive/security_audit.dart | 31 +- lib/services/derive/sovereignty_view.dart | 24 +- lib/services/sovereignty_service.dart | 26 +- lib/utils/cookie_db.g.dart | 2678 ++++++++++ lib/utils/cookie_overrides.dart | 691 +++ lib/utils/cookie_utils.dart | 4326 +---------------- lib/widgets/sovereignty_view.dart | 13 +- pubspec.yaml | 1 + test/derive/cookies_view_test.dart | 10 +- test/derive/security_audit_test.dart | 38 + test/derive/sovereignty_view_test.dart | 6 +- test/services/sovereignty_service_test.dart | 64 +- test/utils/cookie_db_test.dart | 139 + test/utils/cookie_utils_test.dart | 14 +- test/widgets/sovereignty_data_test.dart | 13 +- tool/data/OCD_VERSION | 10 + tool/data/open-cookie-database.csv | 2289 +++++++++ tool/gen_cookie_db.dart | 271 ++ 24 files changed, 6574 insertions(+), 4352 deletions(-) create mode 100644 THIRD_PARTY_NOTICES.md create mode 100644 assets/licenses/open-cookie-database-LICENSE.txt create mode 100644 lib/utils/cookie_db.g.dart create mode 100644 lib/utils/cookie_overrides.dart create mode 100644 test/utils/cookie_db_test.dart create mode 100644 tool/data/OCD_VERSION create mode 100644 tool/data/open-cookie-database.csv create mode 100644 tool/gen_cookie_db.dart diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 00000000..39388b54 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,21 @@ +# Third-party notices + +View Source Vibe ships data and depends on packages from other projects. The +licenses of all Dart/Flutter packages are listed in the app (About → Open +source licenses). Data that is bundled in the source tree: + +## Open Cookie Database + +- Used for: cookie names, categories and platforms in + `lib/utils/cookie_db.g.dart` (generated by `tool/gen_cookie_db.dart`). +- Source: by Jack Kwakman + and contributors. +- Version: see `tool/data/OCD_VERSION` (pinned commit; the vendored CSV is + `tool/data/open-cookie-database.csv`, unmodified). +- License: Apache License 2.0, full text in + `assets/licenses/open-cookie-database-LICENSE.txt` (also shown in the app). +- Changes made: the CSV is converted to Dart source, its categories are + mapped to this app's categories (Marketing → advertising, Analytics → + analytics, Functional/Personalization → functional, Security/Necessary → + essential), some cookies of social platforms are classified as `social`, + and entries are added or overridden in `lib/utils/cookie_overrides.dart`. diff --git a/assets/licenses/open-cookie-database-LICENSE.txt b/assets/licenses/open-cookie-database-LICENSE.txt new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/assets/licenses/open-cookie-database-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/audits/2026-11-berekeningen.md b/docs/audits/2026-11-berekeningen.md index a5289964..bc6823be 100644 --- a/docs/audits/2026-11-berekeningen.md +++ b/docs/audits/2026-11-berekeningen.md @@ -60,7 +60,7 @@ Elke bevinding is eerst aangetoond met een falende test (of, waar dat niet kan, | C3 | fout | Wildcard-check ziet alleen `*`, niet `https:`, `http:`, `data:` of `*.domein`. | Google CSP Evaluator | fix | | C4 | fout | Dubbele directive: laatste wint, spec zegt eerste. | CSP Level 3 parsing | fix | | C5 | misleidend | Ontbrekende `frame-ancestors` kost 12 punten ook als X-Frame-Options al beschermt. | — | fix (→ low) | -| C6 | discutabel | `script-src-elem`-fallbackketen niet gemodelleerd. | CSP Level 3 | niet gedaan (laag) | +| C6 | fout | `script-src-elem`/`script-src-attr` genegeerd; alleen `script-src` werd beoordeeld. | CSP Level 3 | fix (follow-up) | | — | ontwerpkeuze | Gewichten 22/12 en drempels 80/50 hebben geen externe norm. | — | besluit | ### 2.3 Certificaat @@ -86,7 +86,7 @@ Elke bevinding is eerst aangetoond met een falende test (of, waar dat niet kan, | K7 | fout | Elke naam met "consent" wordt essential (`consent_ad_id`, `trackingconsent_ads`). | fix | | K8 | fout | Prefix-match: eerste i.p.v. langste wint; 4 specifieke prefixen onbereikbaar (`_gac_gb_`, `_vis_opt_exp_`, …). | fix | | K9 | fout | `Max-Age=0` (= verwijderen) en verlopen/ongeldige `Expires` niet herkend. | fix | -| K10 | laag | Gequote waarden met `;` breken parsing. | niet gedaan | +| K10 | ok | Was een valse bevinding: RFC 6265 §5.2 splitst de Set-Cookie-string bij de eerste `;`, quotes zijn niet speciaal. Huidig gedrag klopt; test legt het vast. | geen fix nodig | | K11 | ontwerpkeuze | `NID`/`IDE` bewust als eigen cookie behandeld (niet-onderscheidende naam). | besluit | | — | ontwerpkeuze | Gewichten 12/7/6/3/6/5/2 en drempels 75/45. | besluit | @@ -146,10 +146,18 @@ Vastgelegd in `test/derive/cross_page_consistency_test.dart`: dezelfde response Neveneffect van V6 (hele woorden): samengestelde hostnamen zoals `googletagmanager`, `googlesyndication`, `cdninstagram`, `akamaihd`, `cloudflareinsights` staan nu expliciet in de patronen (matchten voorheen via substring). Bewust nog wél een match: namen waarin `-` een woordgrens is (`gcp-pharma.nl`, `comodo-pizza.nl`). +### 2.10 Follow-up (na PR #44) +- **C6** opgelost (`script-src-elem`, `script-src-attr`). +- **K10** was geen bug (zie boven). +- **Cookie-database** opnieuw opgebouwd: `tool/gen_cookie_db.dart` genereert `lib/utils/cookie_db.g.dart` uit de gepinde OCD-CSV (`tool/data/`, commit 7786335, 2026-11-06). Wildcard komt uit het OCD-veld (niet meer uit een `_`/`-`-suffix), langste prefix wint, wildcards korter dan 3 tekens matchen exact. Handmatige kennis staat apart in `lib/utils/cookie_overrides.dart` (275 namen die niet in OCD staan). Voor namen in OCD wint OCD; 108 van de 2293 oude namen kregen een andere categorie (o.a. Google `SID`-familie en Facebook `c_user` → advertising). Tien OCD-namen zonder wildcardvlag waar het echte cookie een id achter de naam zet (`Hm_lvt_`) staan in `forcedWildcard`. +- **Social**: 19 cookies via regel (platform in Facebook/Instagram/LinkedIn/Pinterest/TikTok/X en omschrijving over delen/plugin/login, zonder advertentie-woorden); pixel- en advertentiecookies blijven advertising. +- **Licentie-attributie**: Apache-2.0 tekst van OCD in `assets/licenses/`, geregistreerd in de licentiepagina van de app (About → Open source licenses) en in `THIRD_PARTY_NOTICES.md`. De projectlicentie zelf (GPLv3 vs MIT) is nog open. +- **Te weinig data → geen score**: Sovereignty toont geen score of cijfer onder 50% dekking (`SovereigntyReport.minCoverage`); Cookie Privacy Lens toont alleen een score als zowel de Set-Cookie-headers als de browsercookies gelezen zijn. De Security Headers Score en de CSP-score hebben altijd een response nodig en tonen anders al niets. + ## 3. Besluiten voor jou 1. **Gewichten en drempels** van alle vier scores (geen externe norm): houden, of afleiden van Observatory (security) en documenteren. -2. **Cookie-database**: genereren uit gepinde OCD-CSV met wildcard-veld en overrides; categorie "social" vullen of schrappen. -3. **Licenties**: OCD-naamsvermelding (Apache-2.0) toevoegen; GPLv3 vs MIT rechttrekken. +2. ~~Cookie-database~~ gedaan (follow-up). +3. **Licenties**: OCD-naamsvermelding gedaan; GPLv3 vs MIT rechttrekken is open. 4. **SAN** uit het certificaat (DER) parsen, zodat de hostcheck echt klopt. 5. **TLS-CA-check** (V10): adequaat warn / buitenlands fail, of lager gewicht. -6. **Lage dekking**: alleen tonen (zoals nu gefixt) of het cijfer onderdrukken onder een drempel. +6. ~~Lage dekking~~ gedaan: score verborgen onder 50% dekking. diff --git a/lib/main.dart b/lib/main.dart index 970eeee9..a86ab867 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -249,6 +249,20 @@ void main() async { // Initialize Flutter binding before any async operations WidgetsFlutterBinding.ensureInitialized(); + // Third-party data shipped in the app: shown on the licenses page. + LicenseRegistry.addLicense(() async* { + final text = await rootBundle + .loadString('assets/licenses/open-cookie-database-LICENSE.txt'); + yield LicenseEntryWithLineBreaks( + ['Open Cookie Database'], + 'Cookie names, categories and platforms (lib/utils/cookie_db.g.dart) ' + 'are derived from the Open Cookie Database by Jack Kwakman and ' + 'contributors, https://github.com/jkwakman/Open-Cookie-Database. ' + 'Changes: converted to Dart source, categories mapped to this ' + "app's categories, entries added and overridden.\n\n$text", + ); + }); + // Disable InAppWebView debug logging if (!kIsWeb && (Platform.isAndroid || Platform.isIOS || Platform.isMacOS)) { PlatformInAppWebViewController.debugLoggingSettings.enabled = false; diff --git a/lib/screens/about_screen.dart b/lib/screens/about_screen.dart index 919dface..2a215451 100644 --- a/lib/screens/about_screen.dart +++ b/lib/screens/about_screen.dart @@ -229,7 +229,20 @@ class AboutScreen extends StatelessWidget { ), ), - const SizedBox(height: 32), + const SizedBox(height: 16), + + Center( + child: TextButton.icon( + onPressed: () => showLicensePage( + context: context, + applicationName: 'View Source Vibe', + ), + icon: const Icon(Icons.description_outlined), + label: const Text('Open source licenses'), + ), + ), + + const SizedBox(height: 16), // Close Button Center( diff --git a/lib/services/derive/cookies_view.dart b/lib/services/derive/cookies_view.dart index 56c4e1d6..ee1c4cde 100644 --- a/lib/services/derive/cookies_view.dart +++ b/lib/services/derive/cookies_view.dart @@ -252,8 +252,11 @@ Observed deriveCookiesView(PageInspection p, {DateTime? now}) { final weak = count((r) => r.weakSameSite); final notSecure = count((r) => r.missingSecure); + // Only with every source read: cookies set later by JavaScript are not in + // the Set-Cookie headers, and the server's cookies are not all the browser + // holds, so a half-read list says too little to judge. int? score; - if (rows.isNotEmpty || complete) { + if (complete) { score = (100 - advertising * 12 - analytics * 7 - @@ -264,18 +267,14 @@ Observed deriveCookiesView(PageInspection p, {DateTime? now}) { notSecure * 2) .clamp(0, 100); } - final baseVerdict = score == null - ? 'Not judged: no cookies seen and a source is unknown.' + final verdict = score == null + ? 'No score: not enough data (not all cookie sources could be read).' : score >= 75 ? 'Low visible tracking pressure from cookies.' : score >= 45 ? 'Moderate cookie tracking signals detected.' : 'Heavy tracking or weak cookie boundaries detected.'; - final verdict = score != null && !complete - ? '$baseVerdict (partial: not all cookie sources could be read)' - : baseVerdict; - final notes = [ if (advertising > 0) CookieNote(Icons.ad_units_outlined, InsightTone.warn, diff --git a/lib/services/derive/security_audit.dart b/lib/services/derive/security_audit.dart index 84bc4578..246901b1 100644 --- a/lib/services/derive/security_audit.dart +++ b/lib/services/derive/security_audit.dart @@ -184,7 +184,9 @@ SecurityAudit _audit(HttpHop hop) { final cspText = _value(hop, 'content-security-policy'); final csp = cspText == null ? null : _parseCsp(cspText.toLowerCase()); final protectsScripts = csp != null && - (csp.containsKey('default-src') || csp.containsKey('script-src')); + (csp.containsKey('default-src') || + csp.containsKey('script-src') || + csp.containsKey('script-src-elem')); final xfo = _value(hop, 'x-frame-options')?.toLowerCase(); final frames = xfo == 'deny' || xfo == 'sameorigin' || @@ -210,7 +212,7 @@ SecurityAudit _audit(HttpHop hop) { protectsScripts ? 'Content-Security-Policy restricts scripts.' : csp != null - ? 'Content-Security-Policy has no default-src or script-src.' + ? 'Content-Security-Policy has no default-src, script-src or script-src-elem.' : 'Missing Content-Security-Policy.'), SecurityCheck( 'Frames', @@ -276,26 +278,37 @@ List _cspFindings(Map> d, final findings = []; final defaultSrc = d['default-src'] ?? const []; final scriptSrc = d['script-src'] ?? defaultSrc; + // CSP3: