-
Notifications
You must be signed in to change notification settings - Fork 13
feat: WIP! EWM-497 #882
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
base: dev
Are you sure you want to change the base?
feat: WIP! EWM-497 #882
Changes from 103 commits
72f4990
f1b9b02
b3a1d70
5ca8ef5
e66035a
6e7d8d4
79bd483
a3548c1
25c25a6
31120ba
2f72473
94c3618
919840f
0f86c6a
6bae455
2697404
3bda1a1
3afe03e
2476de3
5a2af41
c66c0f4
cd88275
ac52f09
62d8fcc
f079233
a1a069d
a41e7da
6f5867d
d10041d
a95c264
79605a0
abd9d8e
f92622a
df5f04a
1e03aa1
91f96a6
846e0d0
a3d6d3e
6029e8f
f4cd71e
2a81195
6d7d7f2
9dc2253
801b83b
c37c736
e7a0ab3
392b656
8463470
c6127a3
6466591
3f1fb88
94bdf4e
453ab23
a0c2ced
f6bc960
a291b62
9d66f81
3c2c66a
13c9e95
9505ad6
4c67cbc
1950c8b
ac365d5
887f33e
01df710
d9eca64
1cfe8c4
03528a7
14fd2f4
9a507da
6ba30f3
ef6884b
0f89ee9
844a14e
e0738c5
6cdd68f
4c40c7a
a5b4098
848957a
e53a914
2087577
fc7a57c
b64c364
827e8d8
7a15a08
969c9fa
9990c4b
ec1ba7c
474c3d8
4688fd0
b4b12f6
7ec422f
59ab7a8
20c03a4
f196819
08b0d32
e9ed123
e260ac8
f47d1d3
71b428c
e19c49c
3dc14c3
0b737fb
5bce71c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.29.2 | ||
3.29.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"blacklist": [ | ||
"everscan.com", | ||
"octsubridge.io", | ||
"octus-bridge.com", | ||
"protocoloctusbridge.com", | ||
"octlusbridge.com", | ||
"bridge-octus.org", | ||
"internal-meeting.online", | ||
"pancake-ever.com", | ||
"gravixguard.github.io", | ||
"gravixguard.web.app", | ||
"broxus.net", | ||
"chainconnect.app" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>SparX Wallet Phishing Detection</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 20px; | ||
background-color: #f0f0f0; | ||
font-family: Arial, sans-serif; | ||
color: #333; | ||
} | ||
.container { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
background-color: #fff; | ||
border-radius: 4px; | ||
box-shadow: 0 2px 6px rgba(0,0,0,0.1); | ||
padding: 24px; | ||
} | ||
h1 { | ||
margin-top: 0; | ||
font-size: 1.8rem; | ||
} | ||
p { | ||
line-height: 1.6; | ||
margin-bottom: 1em; | ||
} | ||
a { | ||
color: #0066cc; | ||
text-decoration: none; | ||
} | ||
a:hover { | ||
text-decoration: underline; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>SparX Wallet Phishing Detection</h1> | ||
<p> | ||
This domain is currently on the SparX Wallet domain warning list. This means | ||
that based on information available to us, SparX Wallet believes this domain | ||
could currently compromise your security and, as an added safety feature, | ||
SparX Wallet has restricted access to the site. To override this, please read | ||
the rest of this warning for instructions on how to continue at your own risk. | ||
</p> | ||
<p> | ||
There are many reasons sites can appear on our warning list, and our warning | ||
list compiles from other widely used industry lists. Such reasons can include | ||
known fraud or security risks, such as domains that test positive on the | ||
SparX Wallet Phishing Detection. Domains on these warning lists may include | ||
outright malicious websites and legitimate websites that have been compromised | ||
by a malicious actor. | ||
</p> | ||
<p> | ||
To read more about this site please | ||
<a href="https://cryptoscamdb.org/search"> | ||
search for the domain on CryptoScamDB | ||
</a>. | ||
</p> | ||
<p> | ||
Note that this warning list is compiled on a voluntary basis. This list may be | ||
inaccurate or incomplete. Just because a domain does not appear on this list is | ||
not an implicit guarantee of that domain's safety. As always, your transactions | ||
are your own responsibility. If you wish to interact with any domain on our | ||
warning list, you can do so by | ||
<a href="{PHISHING_ORIGINAL_SITE}"> | ||
continuing at your own risk | ||
</a>. | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:app/app/service/app_links/app_links.dart'; | ||
import 'package:app/app/service/resources_service.dart'; | ||
import 'package:app/app/service/storage_service/general_storage_service.dart'; | ||
import 'package:app/feature/browser_v2/data/history_type.dart'; | ||
import 'package:app/feature/browser_v2/domain/service/storages/browser_bookmarks_storage_service.dart'; | ||
|
@@ -9,6 +10,7 @@ import 'package:app/feature/browser_v2/domain/service/storages/browser_history_s | |
import 'package:app/feature/browser_v2/domain/service/storages/browser_permissions_storage_service.dart'; | ||
import 'package:app/feature/browser_v2/domain/service/storages/browser_tabs_storage_service.dart'; | ||
import 'package:app/feature/browser_v2/managers/bookmarks_manager.dart'; | ||
import 'package:app/feature/browser_v2/managers/broser_anti_phishing_manager.dart'; | ||
import 'package:app/feature/browser_v2/managers/browser_auth_manager.dart'; | ||
import 'package:app/feature/browser_v2/managers/favicon_manager.dart'; | ||
import 'package:app/feature/browser_v2/managers/history_manager.dart'; | ||
|
@@ -30,6 +32,7 @@ class BrowserService { | |
this._browserPermissionsStorageService, | ||
this._messengerService, | ||
this._generalStorageService, | ||
this._resourcesService, | ||
); | ||
|
||
final AppLinksService _appLinksService; | ||
|
@@ -39,8 +42,8 @@ class BrowserService { | |
final BrowserTabsStorageService _browserTabsStorageService; | ||
final BrowserPermissionsStorageService _browserPermissionsStorageService; | ||
final GeneralStorageService _generalStorageService; | ||
|
||
final MessengerService _messengerService; | ||
final ResourcesService _resourcesService; | ||
|
||
late final bookmarks = BookmarksManager( | ||
_bookmarksStorageService, | ||
|
@@ -58,6 +61,8 @@ class BrowserService { | |
|
||
final auth = BrowserAuthManager(); | ||
|
||
late final antiPhishing = BrowserAntiPhishingManager(_resourcesService); | ||
|
||
StreamSubscription<BrowserAppLinksData>? _appLinksNavSubs; | ||
|
||
BookmarksManager get bM => bookmarks; | ||
|
@@ -72,11 +77,12 @@ class BrowserService { | |
|
||
BrowserAuthManager get aM => auth; | ||
|
||
void init() { | ||
Future<void> init() async { | ||
bookmarks.init(); | ||
history.init(); | ||
tabs.init(); | ||
permissions.init(); | ||
await antiPhishing.init(); | ||
WidgetsBinding.instance.addPostFrameCallback((_) { | ||
_appLinksNavSubs = | ||
_appLinksService.browserLinksStream.listen(_listenAppLinks); | ||
|
@@ -94,6 +100,7 @@ class BrowserService { | |
void dispose() { | ||
tabs.dispose(); | ||
_appLinksNavSubs?.cancel(); | ||
antiPhishing.dispose(); | ||
} | ||
|
||
void openUrl(Uri uri) { | ||
|
@@ -127,6 +134,30 @@ class BrowserService { | |
} | ||
} | ||
|
||
Future<void> loadPhishingGuard( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А метод же по идее можно сделать приватным? |
||
String path, | ||
) async { | ||
final html = await antiPhishing.getPhishingGuardHtml(path); | ||
return tabs.loadDataOnActiveTab(html); | ||
} | ||
|
||
Future<bool> loadPhishingGuardIfNeed({ | ||
required String path, | ||
required String host, | ||
}) async { | ||
final list = antiPhishing.blackList; | ||
|
||
for (final link in list) { | ||
if (path != link && host != link) { | ||
continue; | ||
} | ||
|
||
unawaited(loadPhishingGuard(path)); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void _listenAppLinks(BrowserAppLinksData event) { | ||
openUrl(event.url); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:app/app/service/resources_service.dart'; | ||
import 'package:app/utils/json/json.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:rxdart/rxdart.dart'; | ||
|
||
class BrowserAntiPhishingManager { | ||
BrowserAntiPhishingManager(this._resourcesService); | ||
|
||
final _blackListSubj = BehaviorSubject<List<String>>.seeded([]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А может будем использовать Set? Тогда проверка на |
||
|
||
List<String> get blackList => _blackListSubj.value; | ||
|
||
final ResourcesService _resourcesService; | ||
|
||
final _log = Logger('BrowserAntiPhishingManager'); | ||
|
||
Future<void> init() { | ||
return loadLinksJson(); | ||
} | ||
|
||
void dispose() { | ||
_blackListSubj.close(); | ||
} | ||
|
||
Future<void> loadLinksJson() async { | ||
try { | ||
final json = await _resourcesService.loadString( | ||
'assets/configs/anti_phishing.json', | ||
); | ||
|
||
final map = await compute<String, Map<String, dynamic>>(_parse, json); | ||
|
||
_blackListSubj.add(castJsonList(map['blacklist'])); | ||
} catch (e, s) { | ||
_log.severe('Load blacklist JSON error', e, s); | ||
} | ||
} | ||
|
||
Future<String> getPhishingGuardHtml(String path) async { | ||
final html = await rootBundle.loadString('assets/html/anti_phishing.html'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А не стоит это закешировать, чтобы в первый раз мы прочитали из файловой системы, а далее html оставался в памяти? |
||
html.replaceFirst('{PHISHING_ORIGINAL_SITE}', path); | ||
return html; | ||
} | ||
|
||
static Map<String, dynamic> _parse(String json) { | ||
return jsonDecode(json) as Map<String, dynamic>; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему не через DI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Будет. Пока еще нет. Нужно CI доделать.