From acb0fb670439e4eff9bd04a52ce3caea83c1be2e Mon Sep 17 00:00:00 2001 From: omega ui Date: Tue, 9 Jan 2024 17:12:10 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Added=20default=20security=20filter?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/exclusion-config.json | 20 +++++++++++++++++++ .../settings_initialized_state_view.dart | 4 ++-- lib/core/storage/storage.dart | 11 ++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 assets/exclusion-config.json diff --git a/assets/exclusion-config.json b/assets/exclusion-config.json new file mode 100644 index 0000000..72e4ee5 --- /dev/null +++ b/assets/exclusion-config.json @@ -0,0 +1,20 @@ +{ + "exclusions": [ + { + "name": "GitHub Token", + "pattern": "^[a-zA-Z0-9]{40}$" + }, + { + "name": "Gitlab Token", + "pattern": "^[a-zA-Z0-9_-]{20,}$" + }, + { + "name": "Git HTTPS Url", + "pattern": "^https:\\/\\/([^:]+):([^@]+)@([^\\/]+)\\/(.+\/[^.]+)\\.git$" + }, + { + "name": "SSH Key", + "pattern": "^ssh-rsa\\s+[A-Za-z0-9+/]+[=]{0,3}(\\s+[^\\s]+)?\\s*$" + } + ] +} diff --git a/lib/app/settings/presentation/states/settings_initialized_state_view.dart b/lib/app/settings/presentation/states/settings_initialized_state_view.dart index 493b22c..a82ca10 100644 --- a/lib/app/settings/presentation/states/settings_initialized_state_view.dart +++ b/lib/app/settings/presentation/states/settings_initialized_state_view.dart @@ -288,7 +288,7 @@ class _SettingsInitializedStateViewState active: widget.controller.settingsRepo.isForcingXClip(), icon: AppIcons.clipboard, enabled: Platform.environment['WAYLAND_DISPLAY'] != null, - disableCause: "You not using wayland display on your system", + disableCause: "Value of \$WAYLAND_DISPLAY is not set", onChanged: (enabled) { widget.controller.settingsRepo.setForceXClip(enabled); setState(() {}); @@ -615,7 +615,7 @@ class _SettingsInitializedStateViewState fallback: StorageValues.defaultAnimationEnabledKey), ), Text( - "No content filter detected, looks like you also removed the default ones\nPlease not that any password or key you copy will be watched", + "No content filter detected, looks like you also removed the default ones\nPlease note that any password or key you copy will be watched", textAlign: TextAlign.center, style: AppTheme.fontSize(14).makeBold(), ), diff --git a/lib/core/storage/storage.dart b/lib/core/storage/storage.dart index 2507493..ca2bdff 100644 --- a/lib/core/storage/storage.dart +++ b/lib/core/storage/storage.dart @@ -63,6 +63,17 @@ class Storage { ['+x', commandExecutorScript.path], ); } + + // Writing Exclusion Config ... + final exclusionConfig = File( + combineHomePath(['.config', 'cliptopia', 'exclusion-config.json'])); + + if (!exclusionConfig.existsSync()) { + prettyLog(value: "Writing the default exclusion-config ..."); + final contents = + await rootBundle.loadString('assets/exclusion-config.json'); + exclusionConfig.writeAsStringSync(contents, flush: true); + } } static dynamic get(String key, {fallback}) {