Skip to content

A high-performance Android storage analyzer that bypasses MTP using a native C++ daemon, a Rust TCP bridge, and a React Treemap UI.

Rust

Bundle fonts for offline rendering under the local resource policy (#54)

Vishnu Srivatsavaea9742b36182
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7096cbd..d959423 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -195,7 +195,10 @@ jobs:
- name: Test built scan UI with mocked IPC
if: runner.os == 'Linux'
- run: python3 tests/check_scan_ui.py
+ run: |
+ python3 tests/check_scan_ui.py
+ UI_TEST_WINDOW=1024,768 python3 tests/check_scan_ui.py
+ UI_TEST_SCALE=2 python3 tests/check_scan_ui.py
# ── Fix AppImage: guarantee root icon + .DirIcon + sane modes ─────────
# Required for AppImage catalog validation. tauri-bundler 2.11.1 emits a
diff --git a/docs/font-assets.json b/docs/font-assets.json
new file mode 100644
index 0000000..c03e8a7
--- /dev/null
+++ b/docs/font-assets.json
@@ -0,0 +1,80 @@
+[
+ {
+ "file": "inter-cyrillic-ext.woff2",
+ "bytes": 25960,
+ "sha256": "ca157063339ac4ad418f214f3abfed119b0798ab4d377386ce5c9e5a7a435ebd",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7SUc.woff2"
+ },
+ {
+ "file": "inter-cyrillic.woff2",
+ "bytes": 18748,
+ "sha256": "71d5ee93cc1e9f1d520a3a8b66456de18c7879d8df09d57fcd2eaff75fef0075",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7SUc.woff2"
+ },
+ {
+ "file": "inter-greek-ext.woff2",
+ "bytes": 11232,
+ "sha256": "6e9e020a25f9b56d418f2c085b1d3c09725a4da23fe693a5b463064606732190",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7SUc.woff2"
+ },
+ {
+ "file": "inter-greek.woff2",
+ "bytes": 18996,
+ "sha256": "1be3448e292fbf05ffe176fe1e43f135013d50b1e7d324ad1a558f623d3bb6f6",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7SUc.woff2"
+ },
+ {
+ "file": "inter-vietnamese.woff2",
+ "bytes": 10252,
+ "sha256": "5c66f9e07e90c6d4ac4922cc68d60de26c17b1858e677fb5e603fce3952b3ff2",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7SUc.woff2"
+ },
+ {
+ "file": "inter-latin-ext.woff2",
+ "bytes": 85068,
+ "sha256": "34b9c504cab7a73e37b746343a449132e56cf7b5481af2cb81dc74dcff25c956",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7SUc.woff2"
+ },
+ {
+ "file": "inter-latin.woff2",
+ "bytes": 48256,
+ "sha256": "3100e775e8616cd2611beecfa23a4263d7037586789b43f035236a2e6fbd4c62",
+ "source": "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7.woff2"
+ },
+ {
+ "file": "jetbrains-mono-cyrillic-ext.woff2",
+ "bytes": 1640,
+ "sha256": "62213be8a78b42f1e29d1452d91e2f8b3e745572a9dd98d3941e39fa00b37d76",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx3cwhsk.woff2"
+ },
+ {
+ "file": "jetbrains-mono-cyrillic.woff2",
+ "bytes": 8872,
+ "sha256": "e17cfd15fb96909d64095015f958207063a0c07191da3512df7d560a781aebdf",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxTcwhsk.woff2"
+ },
+ {
+ "file": "jetbrains-mono-greek.woff2",
+ "bytes": 6836,
+ "sha256": "0a557721b1f8b36d3f3f84442689a71ca4a744300abcb46a1953f51bfc663b66",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxPcwhsk.woff2"
+ },
+ {
+ "file": "jetbrains-mono-vietnamese.woff2",
+ "bytes": 5888,
+ "sha256": "c89b9cc0bc6262bd4f8d8494b6961601f3aefa829d08c2e3635f4d501d3a47c2",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx_cwhsk.woff2"
+ },
+ {
+ "file": "jetbrains-mono-latin-ext.woff2",
+ "bytes": 11624,
+ "sha256": "db5ff4db83e580426280e9337a58dc57d3a83784a1b03ad80914651594441d52",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx7cwhsk.woff2"
+ },
+ {
+ "file": "jetbrains-mono-latin.woff2",
+ "bytes": 31432,
+ "sha256": "83c005d49d8a6a50474c73a5a36ac0468076e9c4a29da7bdb14995d80560a5be",
+ "source": "https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxDcwg.woff2"
+ }
+]
diff --git a/docs/fonts.md b/docs/fonts.md
new file mode 100644
index 0000000..6f2813a
--- /dev/null
+++ b/docs/fonts.md
@@ -0,0 +1,64 @@
+# Bundled fonts
+
+SocketSweep ships normal-style Inter (weights 300–800) and JetBrains Mono
+(weights 400–500), matching the previous Google Fonts stylesheet. Variable
+WOFF2 subsets cover Latin, extended Latin, Vietnamese, Greek and Cyrillic;
+Inter also includes extended Greek. Keeping these subsets preserves the
+previous stylesheet's coverage for filenames as well as English UI text.
+Characters absent from these families still use the existing system fallback
+stacks, which can differ between platforms. No italic faces are used or shipped.
+
+The files are unmodified Google Fonts distributions downloaded from this
+[CSS request](https://fonts.googleapis.com/css2?family=Inter:[email protected]&family=JetBrains+Mono:[email protected]&display=swap)
+with a modern Chromium user agent. `font-assets.json` records each exact source
+URL, byte count and SHA-256 digest. The SIL Open Font License files come from
+[google/fonts at 66928797f271fed5ee428544e7229685e2d90127](https://github.com/google/fonts/tree/66928797f271fed5ee428544e7229685e2d90127/ofl).
+They are copied into the desktop frontend at `/font-licenses/inter-OFL.txt`
+and `/font-licenses/jetbrainsmono-OFL.txt`, alongside the bundled fonts.
+Neither development nor release builds download fonts.
+
+Vite emits hashed asset URLs from `src/fonts.css`. Its `?no-inline` suffix
+keeps even the smallest font as a separate asset: the production CSP permits
+only `font-src 'self'`, so embedded data fonts would be blocked. The app retains
+`font-display: swap` and its system fallback stacks for the brief initial load.
+Google Fonts links and preconnects are removed; no external font origins or
+new dependencies are needed.
+
+## Asset accounting
+
+Production `dist` file bytes, compared with commit
+`6bfefba9f5cda9b337b4f0badcf1eaa3dd3d8642` using the same installed toolchain:
+
+| Assets | Before | After |
+| --- | ---: | ---: |
+| JavaScript | 516,736 | 516,736 |
+| CSS | 32,112 | 35,495 |
+| WOFF2 fonts | 0 | 284,804 |
+| Font licenses | 0 | 8,776 |
+| All frontend files, including HTML and existing SVGs | 560,055 | 856,716 |
+
+The total increase is 296,661 bytes (about 290 KiB). These are uncompressed
+frontend file sizes, not installer sizes or memory measurements. The previous
+zero font bytes meant fonts were fetched externally or blocked, not free.
+
+## Verification
+
+Run `npm run build`, then `python3 tests/check_scan_ui.py`. The existing built-UI
+fixture runs headless Chromium with mocked IPC, external DNS disabled, and the
+production CSP (with a local report endpoint allowed in `connect-src`). It no
+longer removes remote font links from the page, so regressions cannot be hidden.
+It loads every shipped subset at each declared weight, verifies the faces
+loaded, checks all 13 font URLs stay on the local origin, rejects CSP violations,
+and checks setup alignment and result typography alongside scan UI behavior.
+
+Additional scale checks:
+
+```sh
+UI_TEST_WINDOW=1024,768 python3 tests/check_scan_ui.py
+UI_TEST_SCALE=2 python3 tests/check_scan_ui.py
+```
+
+The default is 1280×1000 at 1×. These are browser fixture checks, not native
+WebKit/WebView or connected-phone tests. Manual native verification uses
+`npm run tauri dev`; disconnect internet access and check setup, results and
+logs. No daemon rebuild is needed for this change.
diff --git a/index.html b/index.html
index 522a1a9..bdd2597 100644
--- a/index.html
+++ b/index.html
@@ -5,9 +5,6 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="SocketSweep — High-performance Android storage analyzer bypassing MTP" />
- <link rel="preconnect" href="https://fonts.googleapis.com" />
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<title>SocketSweep — Android Storage Analyzer</title>
</head>
diff --git a/public/font-licenses/inter-OFL.txt b/public/font-licenses/inter-OFL.txt
new file mode 100644
index 0000000..21f6aff
--- /dev/null
+++ b/public/font-licenses/inter-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/font-licenses/jetbrainsmono-OFL.txt b/public/font-licenses/jetbrainsmono-OFL.txt
new file mode 100644
index 0000000..821a3da
--- /dev/null
+++ b/public/font-licenses/jetbrainsmono-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 5bafdd0..dead010 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -18,7 +18,7 @@
}
],
"security": {
- "csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src ipc: http://ipc.localhost"
+ "csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src ipc: http://ipc.localhost"
}
},
"bundle": {
diff --git a/src/App.css b/src/App.css
index 4072ecc..b797d53 100644
--- a/src/App.css
+++ b/src/App.css
@@ -1,5 +1,6 @@
/* ── Tailwind v4 ─────────────────────────────────────────────────────── */
@import "tailwindcss";
+@import "./fonts.css";
/* ── Design Tokens ───────────────────────────────────────────────────── */
@theme {
diff --git a/src/assets/fonts/inter-cyrillic-ext.woff2 b/src/assets/fonts/inter-cyrillic-ext.woff2
new file mode 100644
index 0000000..de83a9c
Binary files /dev/null and b/src/assets/fonts/inter-cyrillic-ext.woff2 differ
diff --git a/src/assets/fonts/inter-cyrillic.woff2 b/src/assets/fonts/inter-cyrillic.woff2
new file mode 100644
index 0000000..d750914
Binary files /dev/null and b/src/assets/fonts/inter-cyrillic.woff2 differ
diff --git a/src/assets/fonts/inter-greek-ext.woff2 b/src/assets/fonts/inter-greek-ext.woff2
new file mode 100644
index 0000000..6e7141f
Binary files /dev/null and b/src/assets/fonts/inter-greek-ext.woff2 differ
diff --git a/src/assets/fonts/inter-greek.woff2 b/src/assets/fonts/inter-greek.woff2
new file mode 100644
index 0000000..024f077
Binary files /dev/null and b/src/assets/fonts/inter-greek.woff2 differ
diff --git a/src/assets/fonts/inter-latin-ext.woff2 b/src/assets/fonts/inter-latin-ext.woff2
new file mode 100644
index 0000000..479d010
Binary files /dev/null and b/src/assets/fonts/inter-latin-ext.woff2 differ
diff --git a/src/assets/fonts/inter-latin.woff2 b/src/assets/fonts/inter-latin.woff2
new file mode 100644
index 0000000..d15208d
Binary files /dev/null and b/src/assets/fonts/inter-latin.woff2 differ
diff --git a/src/assets/fonts/inter-vietnamese.woff2 b/src/assets/fonts/inter-vietnamese.woff2
new file mode 100644
index 0000000..a40c469
Binary files /dev/null and b/src/assets/fonts/inter-vietnamese.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-cyrillic-ext.woff2 b/src/assets/fonts/jetbrains-mono-cyrillic-ext.woff2
new file mode 100644
index 0000000..289de93
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-cyrillic-ext.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-cyrillic.woff2 b/src/assets/fonts/jetbrains-mono-cyrillic.woff2
new file mode 100644
index 0000000..de39acb
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-cyrillic.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-greek.woff2 b/src/assets/fonts/jetbrains-mono-greek.woff2
new file mode 100644
index 0000000..a53d52d
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-greek.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-latin-ext.woff2 b/src/assets/fonts/jetbrains-mono-latin-ext.woff2
new file mode 100644
index 0000000..82f9668
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-latin-ext.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-latin.woff2 b/src/assets/fonts/jetbrains-mono-latin.woff2
new file mode 100644
index 0000000..4d09cda
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-latin.woff2 differ
diff --git a/src/assets/fonts/jetbrains-mono-vietnamese.woff2 b/src/assets/fonts/jetbrains-mono-vietnamese.woff2
new file mode 100644
index 0000000..e38f553
Binary files /dev/null and b/src/assets/fonts/jetbrains-mono-vietnamese.woff2 differ
diff --git a/src/fonts.css b/src/fonts.css
new file mode 100644
index 0000000..6173ee3
--- /dev/null
+++ b/src/fonts.css
@@ -0,0 +1,119 @@
+/* Bundled Google Fonts WOFF2 subsets; sources and licenses: docs/fonts.md. */
+/* Keep fonts external to CSS: production font-src 'self' blocks data URLs. */
+/* cyrillic-ext */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-cyrillic-ext.woff2?no-inline) format('woff2');
+ unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-cyrillic.woff2?no-inline) format('woff2');
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* greek-ext */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-greek-ext.woff2?no-inline) format('woff2');
+ unicode-range: U+1F00-1FFF;
+}
+/* greek */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-greek.woff2?no-inline) format('woff2');
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
+}
+/* vietnamese */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-vietnamese.woff2?no-inline) format('woff2');
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-latin-ext.woff2?no-inline) format('woff2');
+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ font-weight: 300 800;
+ font-display: swap;
+ src: url(./assets/fonts/inter-latin.woff2?no-inline) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+/* cyrillic-ext */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-cyrillic-ext.woff2?no-inline) format('woff2');
+ unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-cyrillic.woff2?no-inline) format('woff2');
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* greek */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-greek.woff2?no-inline) format('woff2');
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
+}
+/* vietnamese */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-vietnamese.woff2?no-inline) format('woff2');
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-latin-ext.woff2?no-inline) format('woff2');
+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 500;
+ font-display: swap;
+ src: url(./assets/fonts/jetbrains-mono-latin.woff2?no-inline) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
diff --git a/tests/check_scan_ui.py b/tests/check_scan_ui.py
index 7960b70..f19361e 100644
--- a/tests/check_scan_ui.py
+++ b/tests/check_scan_ui.py
@@ -26,8 +26,15 @@ chrome = (sys.argv[1] if len(sys.argv) > 1 else
if not Path(chrome).is_file():
sys.exit('Chrome/Chromium missing; pass its executable as the first argument')
reports = Queue()
+# Keep the production resource policy. Only the fixture's local report endpoint
+# needs an extra connect-src origin; native IPC remains mocked.
+csp = json.loads((REPO / 'src-tauri/tauri.conf.json').read_text())['app']['security']['csp']
+csp = csp.replace('connect-src ', "connect-src 'self' ")
class Handler(SimpleHTTPRequestHandler):
+ def end_headers(self):
+ self.send_header('Content-Security-Policy', csp)
+ super().end_headers()
def log_message(self, *args):
pass
def do_POST(self):
@@ -43,11 +50,13 @@ class Handler(SimpleHTTPRequestHandler):
with tempfile.TemporaryDirectory(prefix='socketsweep-ui-test-') as directory:
work = Path(directory)
shutil.copytree(REPO / 'dist', work / 'site')
+ for name in ('inter-OFL.txt', 'jetbrainsmono-OFL.txt'):
+ source = REPO / 'public/font-licenses' / name
+ bundled = work / 'site/font-licenses' / name
+ assert bundled.read_bytes() == source.read_bytes(), 'Bundled font license differs'
shutil.copy(REPO / 'tests/scan_ui_fixture.js', work / 'site/fixture.js')
index = work / 'site/index.html'
html = index.read_text().replace('<head>', '<head><script src="/fixture.js"></script>')
- # Avoid external font requests during this isolated local fixture.
- html = '\n'.join(line for line in html.splitlines() if 'fonts.google' not in line)
index.write_text(html)
server = ThreadingHTTPServer(('127.0.0.1', 0), partial(Handler, directory=str(work / 'site')))
threading.Thread(target=server.serve_forever, daemon=True).start()
@@ -55,7 +64,10 @@ with tempfile.TemporaryDirectory(prefix='socketsweep-ui-test-') as directory:
with (work / 'chrome.log').open('w+') as log:
process = subprocess.Popen([chrome, '--headless', '--disable-gpu', '--no-first-run',
'--use-mock-keychain', '--password-store=basic', '--enable-logging=stderr',
- '--disable-background-networking', '--disable-extensions', '--window-size=1280,1000',
+ '--disable-background-networking', '--disable-extensions',
+ '--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1',
+ f'--window-size={os.environ.get("UI_TEST_WINDOW", "1280,1000")}',
+ f'--force-device-scale-factor={os.environ.get("UI_TEST_SCALE", "1")}',
f'--user-data-dir={work / "profile"}', f'http://127.0.0.1:{server.server_port}'],
stdout=log, stderr=log, start_new_session=True)
try:
diff --git a/tests/scan_ui_fixture.js b/tests/scan_ui_fixture.js
index a57b10f..58e1fc4 100644
--- a/tests/scan_ui_fixture.js
+++ b/tests/scan_ui_fixture.js
@@ -1,6 +1,8 @@
// Real built frontend, mocked Tauri IPC. No native app, ADB or device calls.
(() => {
const calls = [];
+ const violations = [];
+ document.addEventListener("securitypolicyviolation", event => violations.push(event.blockedURI));
let generation = 1;
let revision = 0;
let unavailable = false;
@@ -107,14 +109,33 @@
const report = (passed, error) => {
const output = document.createElement("pre");
output.id = "scan-test-report";
- output.textContent = JSON.stringify({ passed, error, ipc_calls: calls.length, checks: passed ? ["file label semantics", "complete paging", "late zoom", "Other tile", "stale confirmation", "ID-only deletion", "revision refresh", "partial failure", "read-only", "acknowledged shutdown", "unconfirmed shutdown", "reconnect", "stop action ordering"] : undefined });
+ output.textContent = JSON.stringify({ passed, error, ipc_calls: calls.length, checks: passed ? ["offline fonts under CSP", "setup alignment", "result fonts", "file label semantics", "complete paging", "late zoom", "Other tile", "stale confirmation", "ID-only deletion", "revision refresh", "partial failure", "read-only", "acknowledged shutdown", "unconfirmed shutdown", "reconnect", "stop action ordering"] : undefined });
document.body.append(output);
void fetch("/report", { method: "POST", body: output.textContent });
};
void (async () => {
await waitFor(() => document.querySelector("#btn-connect"), "Setup did not render");
+ check(!document.querySelector('link[href^="http"]'), "External resource link remains");
+ // load() returns actual matching FontFace objects; check() alone can succeed
+ // through fallback even when no face exists. Exercise every shipped subset.
+ for (const family of ["Inter", "JetBrains Mono"]) {
+ const samples = family === "Inter" ? ["SocketSweep → —", "Łódź", "ắ", "Ω", "ἀ", "Я", "Ҁ"] : ["Scan 123 → —", "Łódź", "ắ", "Ω", "Я", "Ҁ"];
+ const weights = family === "Inter" ? [300, 400, 500, 600, 700, 800] : [400, 500];
+ for (const weight of weights) for (const sample of samples) {
+ const faces = await document.fonts.load(`${weight} 16px "${family}"`, sample);
+ check(faces.length > 0 && faces.every(face => face.status === "loaded"), `Font missing: ${family} ${weight} ${sample}`);
+ }
+ }
+ const connect = document.querySelector("#btn-connect");
+ check(getComputedStyle(connect).fontFamily.includes("Inter"), "Setup does not use Inter");
+ const bounds = connect.getBoundingClientRect();
+ check(Math.abs((bounds.left + bounds.right) / 2 - innerWidth / 2) < 2, "Connect button is not centered");
+ check(bounds.top >= 0 && bounds.bottom <= innerHeight, "Connect button is outside the viewport");
document.querySelector("#btn-connect").click();
await waitFor(() => rows().length === 129, "Initial page did not render 128 children");
+ const mono = document.querySelector(".font-mono");
+ check(mono && getComputedStyle(mono).fontFamily.includes("JetBrains Mono"), "Result does not use JetBrains Mono");
+ check(document.documentElement.scrollWidth <= innerWidth, "Results overflow horizontally");
check(document.body.textContent.includes("128 entries on this page of 271"), "Missing full entry count");
check(!rows().find(item => item.textContent.includes("file-0")).querySelector("button:disabled"), "File label became an unavailable control");
const firstNames = rows().map(item => item.textContent);
@@ -198,6 +219,9 @@
check(rows().length === 0, "Unconfirmed stop retained scan results");
}
check(!document.body.textContent.includes("Daemon successfully shut down.") && !document.body.textContent.includes("Daemon was already stopped."), "Unsupported shutdown claim survived");
+ check(violations.length === 0, `CSP blocked resources: ${violations.join(", ")}`);
+ const fonts = performance.getEntriesByType("resource").filter(entry => entry.name.includes(".woff2"));
+ check(fonts.length === 13 && fonts.every(entry => new URL(entry.name).origin === location.origin), "Fonts are missing or fetched off-site");
report(true);
- })().catch(error => report(false, error.stack));
+ })().catch(error => report(false, error.stack ?? String(error)));
})();