Skip to content

Commit 1d24bf7

Browse files
committed
Harden privacy, strengthen extension, clean up project structure
Browser: - WebView2 security: disable password autosave, autofill, status bar, swipe nav; enable reputation checking - Add GPC (Sec-GPC: 1), Upgrade-Insecure-Requests headers on all requests - Inject navigator.globalPrivacyControl = true into every page - Strip third-party cookies proactively via CookieManager API - Add Chromium privacy flags: disable background networking, domain reliability, sync, metrics, breakpad - Improved cosmetic filter: 80+ ad patterns, throttled MutationObserver Chrome extension: - Ad-defuser: added 30+ tracker neutralizations (TikTok, Reddit, Quora, Segment, Heap, Mixpanel, Amplitude, Hotjar, FullStory, Clarity, etc.) - Ad-defuser: sendBeacon/fetch/XHR interception blocks tracking endpoints - Popup: full dark mode support via CSS variables + prefers-color-scheme - Cosmetic CSS: reorganized, deduplicated, added new ad network selectors Project organization: - Remove root duplicates: docs/, scripts/, website/, assets/, data/ - Remove duplicate markdown files (canonical copies in wpf-browser/) - Remove orphaned package-lock.json and random images - Update PROJECT_STRUCTURE.md with clean canonical layout Made-with: Cursor
1 parent 1ff26d3 commit 1d24bf7

58 files changed

Lines changed: 1125 additions & 3645 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Changelog
2+
3+
## 2026-02-16 — Comprehensive Code Review & Fix
4+
5+
### Bug Fixes
6+
7+
**Security**
8+
- **UpdateService.cs**: Verified all 3 high-severity security bugs are already mitigated (path traversal via `IsSafeVersion`, file overwrite via `ProcessPath` validation, injection via `ArgumentList.Add`). Added `try-catch` around `ZipFile.ExtractToDirectory` with descriptive error messages. Added diagnostic logging to apply-update failure path.
9+
10+
**Crash Prevention**
11+
- **ForensicEngine.cs**: Fixed `NullReferenceException` in `ExtractIdentifiers()` and `AnalyzeDataFlow()` when `RequestHeaders` or `ResponseHeaders` are null. Both methods now use null-coalesced header dictionaries.
12+
- **ProtectionEngine.cs**: `LoadBlocklist()` no longer clears the in-memory blocklist on JSON parse failure. Empty blocklist files trigger regeneration of defaults. Outer catch falls back to loading defaults instead of clearing state.
13+
- **BoolToVisibilityConverter.cs**: Fixed `CS1003`/`CS1525` syntax error caused by `bool?` pattern in switch expression.
14+
- **ThreatSimulation.cs**: Fixed `CS8618` warning — `ProtectionGrade` now initialized to `""`. Fixed `CS8604` nullable warnings in `CountAllTrackingCookies` calls.
15+
16+
**Build Errors (pre-existing)**
17+
- **DebugLogger.cs**: Fixed `CS0119``Debug.WriteLine` now fully qualified as `System.Diagnostics.Debug.WriteLine` to avoid conflict with the class's own `Debug()` method.
18+
- **ExportSchema.cs**: Fixed `CS8852``SessionMetrics` changed from `init` to `set` to allow assignment after construction.
19+
- **SystemThemeDetector.cs**: Fixed `CS8625` nullable warning — `new object[]` changed to `new object?[]` for null sender parameter.
20+
21+
### Performance Improvements
22+
23+
- **ProtectionEngine.cs**: `GetDefaultBlocklistEntries()` deduplication changed from O(n²) `list.Any()` scan to O(1) `HashSet<string>.Add()` lookup. Significant improvement for 800+ domain blocklist.
24+
- **PrivacyEngine.cs**: `DetectTrackerFull()` rewritten from linear `foreach` over `TrackerLookup` dictionary to O(1) `TryGetValue` with domain suffix walking. Eliminates full dictionary iteration per request.
25+
26+
### Security Hardening
27+
28+
- **ChromeExtensionExport.cs**: Added input validation (`ValidateInputs`) for `extensionDir` and `domains` parameters. Added `SanitizeDomain()` that strips control characters, validates against a safe domain regex pattern, and enforces 253-char DNS limit. All exported domains are now sanitized before being written to JS or JSON files.
29+
- **MainWindow.xaml.cs**: Cleaned up `LooksLikeUrl()` to no longer match `file:` scheme or arbitrary `://` protocols. Only `http://` and `https://` are recognized as URLs; the existing `IsAllowedNavigationScheme()` guard remains as defense-in-depth.
30+
- **MainWindow.xaml.cs**: Fixed null-forgiving operator (`tab!.Title`) in `Star_Click` — replaced with safe null-coalescing access.
31+
32+
### Resource Cleanup
33+
34+
- **MainWindow.xaml.cs**: `MainWindow_Closing` now stops `_uiTimer` and disposes all tab WebView2 instances on window close, preventing timer callbacks and WebView2 events from firing after shutdown.
35+
36+
### UI / Theme Consistency
37+
38+
- **MainWindow.xaml**: Replaced 6 hardcoded color values with theme-aware `DynamicResource` references:
39+
- `#D93025` (4 instances) → `{DynamicResource DangerBrush}`
40+
- `#188038` (1 instance) → `{DynamicResource SuccessBrush}`
41+
- `#9AA0A6` / `#202124` (address suggestions) → `{DynamicResource TextMuted}` / `{DynamicResource TextPrimary}`
42+
- Removed unused `HeaderGradient` brush definition (dead code).
43+
- All colors now properly adapt to Light, Dark, Light.Large, and Dark.Large themes.
44+
45+
### Chrome Extension
46+
47+
- **manifest.json**: Removed invalid `"permissions"` entry from the permissions array (Chrome ignores it but it's technically incorrect).
48+
- **cosmetic.js**: Fixed mode change handling — cosmetic hiding now re-injects CSS when mode switches from `off` back to `blockKnown` or `aggressive`. Previously, users had to reload the page.
49+
- **background.js**: Added `console.warn` logging to `updateBadge` catch block for diagnostic visibility.
50+
51+
### Error Logging
52+
53+
Added diagnostic `Debug.WriteLine` logging to previously silent catch blocks:
54+
- **MainWindow.xaml.cs**: `LoadSettings`, `ApplySettingsFromJson`, `AddHostObjectToScript` (settings and history bridges)
55+
- **ProtectionEngine.cs**: `LoadBlocklist` (parse failure and outer catch), `GetDefaultBlocklistEntries` (PrivacyEngine enrichment failure)
56+
- **UpdateService.cs**: `TryHandleApplyUpdate` failure
57+
58+
### Documentation
59+
60+
- **BUGS_LIST.md**: Updated all 10 entries with current fix status. High-severity items 1-3 marked as already mitigated. Medium items 4-6 marked as fixed/safe. Lower items 7-10 documented as known/low-risk.
61+
- **CHANGELOG.md**: Created this file documenting all changes.
62+
63+
### Files Changed
64+
65+
| File | Changes |
66+
|------|---------|
67+
| `wpf-browser/ForensicEngine.cs` | Null-safe header access in `ExtractIdentifiers` and `AnalyzeDataFlow` |
68+
| `wpf-browser/ProtectionEngine.cs` | HashSet dedup, blocklist error handling, logging |
69+
| `wpf-browser/PrivacyEngine.cs` | O(1) tracker lookup with suffix walking |
70+
| `wpf-browser/ChromeExtensionExport.cs` | Input validation, domain sanitization |
71+
| `wpf-browser/UpdateService.cs` | Zip extraction error handling, logging |
72+
| `wpf-browser/MainWindow.xaml.cs` | Timer cleanup, LooksLikeUrl fix, Star_Click null safety, logging |
73+
| `wpf-browser/MainWindow.xaml` | Theme-consistent colors, dead code removal |
74+
| `wpf-browser/ThreatSimulation.cs` | Nullable warnings fixed |
75+
| `wpf-browser/SystemThemeDetector.cs` | Nullable warning fixed |
76+
| `wpf-browser/NetworkInterceptor/BoolToVisibilityConverter.cs` | Switch expression syntax fix |
77+
| `wpf-browser/NetworkInterceptor/DebugLogger.cs` | Fully qualified Debug.WriteLine |
78+
| `wpf-browser/NetworkInterceptor/ExportSchema.cs` | init → set for SessionMetrics |
79+
| `wpf-browser/BUGS_LIST.md` | Updated with fix status |
80+
| `chrome-extension/manifest.json` | Removed invalid permission |
81+
| `chrome-extension/cosmetic.js` | Re-injection on mode change |
82+
| `chrome-extension/background.js` | Badge error logging |

IMPROVEMENTS.md

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)