diff --git a/Ink Canvas/Helpers/TelemetryUploader.cs b/Ink Canvas/Helpers/TelemetryUploader.cs
index 025b2466..3c5c8ff3 100644
--- a/Ink Canvas/Helpers/TelemetryUploader.cs
+++ b/Ink Canvas/Helpers/TelemetryUploader.cs
@@ -1,21 +1,47 @@
-using Sentry;
+using Sentry;
using System;
-using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Reflection;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Ink_Canvas.Helpers
{
- ///
- /// 遥测上传:根据用户设置,通过 Sentry 上传 usage_stats 和 Crashes 目录的摘要信息。
- ///
internal static class TelemetryUploader
{
- ///
- /// 根据当前设置决定是否上传遥测数据。
- /// 在主窗口加载完成后调用一次即可。
- ///
+ private static readonly Regex EmailRegex = new Regex(
+ @"(?i)\b[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}\b",
+ RegexOptions.Compiled);
+
+ private static readonly Regex PhoneRegex = new Regex(
+ @"\b1[3-9]\d{9}\b",
+ RegexOptions.Compiled);
+
+ private static readonly Regex IPv4Regex = new Regex(
+ @"\b(?:\d{1,3}\.){3}\d{1,3}\b",
+ RegexOptions.Compiled);
+
+ private static readonly Regex WindowsPathRegex = new Regex(
+ @"\b[A-Za-z]:\\[^\s<>|]+\b",
+ RegexOptions.Compiled);
+
+ private static readonly Regex UncPathRegex = new Regex(
+ @"\\\\[^\s]+",
+ RegexOptions.Compiled);
+
+ private static readonly Regex KeyValueSecretRegex = new Regex(
+ @"(?i)(\b(?:access[_-]?token|refresh[_-]?token|token|password|passwd|pwd|secret|authorization)\b\s*[:=]\s*)([^\s,;]+)",
+ RegexOptions.Compiled);
+
+ private static readonly Regex JsonSecretRegex = new Regex(
+ "(?i)(\"(?:access_token|refresh_token|token|password|passwd|pwd|secret|authorization)\"\\s*:\\s*\")([^\"]*)(\")",
+ RegexOptions.Compiled);
+
+ private static readonly Regex UrlSecretRegex = new Regex(
+ @"(?i)([?&](?:access_token|token|password|pwd|secret)=)[^&\s]+",
+ RegexOptions.Compiled);
+
public static Task UploadTelemetryIfNeededAsync()
{
return Task.Run(() =>
@@ -31,10 +57,9 @@ namespace Ink_Canvas.Helpers
var level = settings.Startup.TelemetryUploadLevel;
if (level == TelemetryUploadLevel.None)
{
- return; // 用户未开启
+ return;
}
- // 获取并校验设备ID
string deviceId = DeviceIdentifier.GetDeviceId();
if (string.IsNullOrWhiteSpace(deviceId) || deviceId.Length < 5)
{
@@ -42,65 +67,20 @@ namespace Ink_Canvas.Helpers
return;
}
- // 可选:Crashes 目录下的崩溃日志
- List