Skip to content
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In a nice user interface you can easily view:
- Http Headers
- Robots.txt
- Security Score
- Permissions (what the page may use, hands to frames and stores on your device)
- DOM Tree
- Plain Html

Expand Down Expand Up @@ -77,6 +78,7 @@ Each page opens into a set of tabs:
- **Timeline:** The request timeline of the page load.
- **Probe & Headers:** HTTP details and response headers.
- **Security:** Security headers and TLS details.
- **Permissions:** Permissions policy, access handed to embedded frames, denied permission requests and site storage.

- **🛠️ Everything else**
- **Bundles:** Save and organize favorite sites and snippets.
Expand Down
3 changes: 3 additions & 0 deletions lib/models/app_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ enum AppTab {
privacy(TabGroup.trust, 'Privacy', Icons.privacy_tip_outlined, 'privacy'),
sovereignty(TabGroup.trust, 'Sovereignty', Icons.public, 'sovereignty'),
security(TabGroup.trust, 'Security', Icons.security, 'security'),
permissions(TabGroup.trust, 'Permissions',
Icons.admin_panel_settings_outlined, 'permissions'),
cookies(TabGroup.trust, 'Cookies', Icons.cookie_outlined, 'cookies');

final TabGroup group;
Expand Down Expand Up @@ -66,6 +68,7 @@ List<AppTab> visibleTabsFor({
AppTab.probe ||
AppTab.sovereignty ||
AppTab.security ||
AppTab.permissions ||
AppTab.cookies =>
server,
})
Expand Down
117 changes: 112 additions & 5 deletions lib/models/inspection/browser_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class RenderedDom {
other.shadowRootCount == shadowRootCount;

@override
int get hashCode => Object.hash(
text, unwrappedRawDocument, iframeCount, shadowRootCount);
int get hashCode =>
Object.hash(text, unwrappedRawDocument, iframeCount, shadowRootCount);

/// Parts of the page that [text] does not contain.
List<String> get limitations => [
Expand Down Expand Up @@ -130,8 +130,8 @@ class BrowserCookie {
sameObserved(other.sameSite, sameSite);

@override
int get hashCode => Object.hash(name, value, domain, path, expires, isSecure,
isHttpOnly, sameSite);
int get hashCode => Object.hash(
name, value, domain, path, expires, isSecure, isHttpOnly, sameSite);
}

class StorageItem {
Expand Down Expand Up @@ -230,6 +230,85 @@ class NavigationTiming {
domContentLoaded, loadEvent, protocol, documentTransfer, documentDecoded);
}

/// One iframe as the page declares it.
class FrameInfo {
/// Absolute URL; '' for srcdoc / about:blank frames.
final String src;

/// The raw `allow` attribute, '' when absent.
final String allow;

/// The raw `sandbox` attribute; null = no sandbox attribute.
final String? sandbox;
const FrameInfo({required this.src, this.allow = '', this.sandbox});

@override
bool operator ==(Object other) =>
other is FrameInfo &&
other.src == src &&
other.allow == allow &&
other.sandbox == sandbox;

@override
int get hashCode => Object.hash(src, allow, sandbox);
}

class ServiceWorkerInfo {
final String scope;
final String script;
const ServiceWorkerInfo({required this.scope, required this.script});

@override
bool operator ==(Object other) =>
other is ServiceWorkerInfo &&
other.scope == scope &&
other.script == script;

@override
int get hashCode => Object.hash(scope, script);
}

/// What the site keeps on the device besides cookies and Web Storage.
class SiteStorage {
final Observed<int> usageBytes;
final Observed<int> quotaBytes;
final Observed<List<String>> indexedDbNames;
final Observed<List<String>> cacheNames;
final Observed<List<ServiceWorkerInfo>> serviceWorkers;
const SiteStorage({
required this.usageBytes,
required this.quotaBytes,
required this.indexedDbNames,
required this.cacheNames,
required this.serviceWorkers,
});

@override
bool operator ==(Object other) =>
other is SiteStorage &&
sameObserved(other.usageBytes, usageBytes) &&
sameObserved(other.quotaBytes, quotaBytes) &&
sameObserved(other.indexedDbNames, indexedDbNames) &&
sameObserved(other.cacheNames, cacheNames) &&
sameObserved(other.serviceWorkers, serviceWorkers);

@override
int get hashCode => Object.hash(
usageBytes.runtimeType,
quotaBytes.runtimeType,
indexedDbNames.runtimeType,
cacheNames.runtimeType,
serviceWorkers.runtimeType);
}

const kFramesNotCollected = Unavailable<List<FrameInfo>>(
UnavailableReason.notReportedByPlatform, 'not collected');
const kSiteStorageNotCollected = Unavailable<SiteStorage>(
UnavailableReason.notReportedByPlatform, 'not collected');

const kCapabilityNotCollected = Unavailable<bool>(
UnavailableReason.notReportedByPlatform, 'not collected');

/// Everything the WebView told us about the current page, one section each.
class BrowserSnapshot {
final Uri url;
Expand All @@ -255,6 +334,18 @@ class BrowserSnapshot {
final bool resourcesTruncated;
final int resourcesDropped;

/// The iframes the page declares (at most 200) and how many there are.
final Observed<List<FrameInfo>> frames;
final int frameCount;

/// Quota usage, IndexedDB, Cache Storage and service workers.
final Observed<SiteStorage> siteStorage;

/// Whether the page can ask for camera/microphone and for location at all
/// (navigator.mediaDevices.getUserMedia / navigator.geolocation exist).
final Observed<bool> mediaDevices;
final Observed<bool> geolocation;

/// The raw collector payload (debug export / fixture recording).
final String? rawPayload;

Expand All @@ -271,6 +362,11 @@ class BrowserSnapshot {
this.mainStatus = mainStatusNotReported,
this.resourcesTruncated = false,
this.resourcesDropped = 0,
this.frames = kFramesNotCollected,
this.frameCount = 0,
this.siteStorage = kSiteStorageNotCollected,
this.mediaDevices = kCapabilityNotCollected,
this.geolocation = kCapabilityNotCollected,
this.rawPayload,
});

Expand Down Expand Up @@ -298,7 +394,9 @@ class BrowserSnapshot {

BrowserSnapshot copyWith(
{Observed<List<BrowserCookie>>? cookies,
Observed<int>? mainStatus}) =>
Observed<int>? mainStatus,
Observed<bool>? mediaDevices,
Observed<bool>? geolocation}) =>
BrowserSnapshot(
url: url,
platform: platform,
Expand All @@ -312,6 +410,11 @@ class BrowserSnapshot {
mainStatus: mainStatus ?? this.mainStatus,
resourcesTruncated: resourcesTruncated,
resourcesDropped: resourcesDropped,
frames: frames,
frameCount: frameCount,
siteStorage: siteStorage,
mediaDevices: mediaDevices ?? this.mediaDevices,
geolocation: geolocation ?? this.geolocation,
rawPayload: rawPayload,
);

Expand All @@ -333,6 +436,8 @@ class BrowserSnapshot {
storage: Unavailable(reason, detail),
navigation: Unavailable(reason, detail),
snapshotTimeMs: Unavailable(reason, detail),
frames: Unavailable(reason, detail),
siteStorage: Unavailable(reason, detail),
rawPayload: rawPayload,
);

Expand All @@ -353,6 +458,8 @@ class BrowserSnapshot {
storage: Failed(error),
navigation: Failed(error),
snapshotTimeMs: Failed(error),
frames: Failed(error),
siteStorage: Failed(error),
rawPayload: rawPayload,
);
}
10 changes: 9 additions & 1 deletion lib/models/inspection/page_inspection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'browser_snapshot.dart';
import 'file_snapshot.dart';
import 'observed.dart';
import 'permission_request.dart';
import 'server_snapshot.dart';

/// [PageInspection.freshLoad] before the user asked for one.
Expand Down Expand Up @@ -75,6 +76,9 @@ class PageInspection {
final Observed<Uint8List> liveScreenshot;
final Observed<Uint8List> freshScreenshot;

/// Native permission requests the page made (all denied), oldest first.
final List<PermissionRequestEvent> permissionRequests;

const PageInspection({
required this.generation,
required this.target,
Expand All @@ -90,6 +94,7 @@ class PageInspection {
this.freshEstimates = const {},
this.liveScreenshot = kNoScreenshot,
this.freshScreenshot = kNoScreenshot,
this.permissionRequests = const [],
});

const PageInspection.empty()
Expand All @@ -110,7 +115,8 @@ class PageInspection {
freshLoad = kFreshLoadNotMeasured,
freshEstimates = const {},
liveScreenshot = kNoScreenshot,
freshScreenshot = kNoScreenshot;
freshScreenshot = kNoScreenshot,
permissionRequests = const [];

PageInspection copyWith({
Observed<ServerSnapshot>? server,
Expand All @@ -125,6 +131,7 @@ class PageInspection {
Map<String, Observed<int>>? freshEstimates,
Observed<Uint8List>? liveScreenshot,
Observed<Uint8List>? freshScreenshot,
List<PermissionRequestEvent>? permissionRequests,
}) =>
PageInspection(
generation: generation,
Expand All @@ -143,6 +150,7 @@ class PageInspection {
freshEstimates: freshEstimates ?? this.freshEstimates,
liveScreenshot: liveScreenshot ?? this.liveScreenshot,
freshScreenshot: freshScreenshot ?? this.freshScreenshot,
permissionRequests: permissionRequests ?? this.permissionRequests,
);

bool _has(DataSource s) => switch (s) {
Expand Down
18 changes: 18 additions & 0 deletions lib/models/inspection/permission_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// A native permission request (camera, microphone, location, ...) a page
/// made. The app always denies it; this only records that it was asked.
class PermissionRequestEvent {
/// Who asked, e.g. https://maps.test
final String origin;

/// Lower-case names: 'camera', 'microphone', 'geolocation', ...
final List<String> resources;

/// Time since the last main-frame load start; null when none was seen.
final Duration? sinceLoadStart;

const PermissionRequestEvent({
required this.origin,
required this.resources,
required this.sinceLoadStart,
});
}
4 changes: 4 additions & 0 deletions lib/screens/about_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class AboutScreen extends StatelessWidget {
Icons.timeline,
'Network: request timeline, headers, cookies, probe and security (incl. TLS)'
),
(
Icons.admin_panel_settings_outlined,
'Permissions: what the page may use, hands to embedded frames and stores on your device'
),
(
Icons.folder_open,
'Open local files, share URLs/files/text into the app, URL history'
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:view_source_vibe/widgets/services_view.dart';
import 'package:view_source_vibe/widgets/media_view.dart';
import 'package:view_source_vibe/widgets/privacy_view.dart';
import 'package:view_source_vibe/widgets/probe_views.dart';
import 'package:view_source_vibe/widgets/permissions_view.dart';
import 'package:view_source_vibe/widgets/request_timeline_view.dart';
import 'package:view_source_vibe/widgets/sovereignty_view.dart';
import 'package:view_source_vibe/widgets/dom_tree_view.dart';
Expand Down Expand Up @@ -428,6 +429,7 @@ class HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
AppTab.privacy => page(tab, const PrivacyView()),
AppTab.sovereignty => page(tab, const SovereigntyView()),
AppTab.security => page(tab, const ProbeSecurityView()),
AppTab.permissions => page(tab, const PermissionsView()),
AppTab.cookies => page(tab, const ProbeCookiesView()),
},
];
Expand Down
Loading
Loading