feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,76 @@
|
||||
/// Sanitizes diagnostic values before they reach memory, disk or an export.
|
||||
final class DiagnosticRedactor {
|
||||
static final _privateKey = RegExp(
|
||||
r'^(authorization|cookies?|password|secret|(?:access|refresh|auth)?[_-]?token|credential(?:Id)?|api.?key|prompt|messages|responseBody|requestBody)$',
|
||||
caseSensitive: false,
|
||||
);
|
||||
static final _bearer = RegExp(
|
||||
r'\bBearer\s+[^\s,;"\x27]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
static final _apiKey = RegExp(r'\bsk-[a-zA-Z0-9_-]+');
|
||||
static final _assignment = RegExp(
|
||||
r'\b(api[_-]?key|access[_-]?token|password|secret|authorization)\s*[:=]\s*[^\r\n,;]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
static final _url = RegExp(r'https?://[^\s<>"\x27]+');
|
||||
static final _path = RegExp(
|
||||
r'(?:file://)?/(?:Users|home|private|tmp|var|Volumes|storage|data|mnt|media|sdcard|Documents)/[^\r\n"\x27,;]*|[A-Za-z]:[\\/][^\r\n"\x27,;]*|\\\\[^\r\n"\x27,;]+',
|
||||
);
|
||||
static final _email = RegExp(r'\b[^\s@]+@[^\s@]+\.[a-zA-Z]{2,}\b');
|
||||
|
||||
String text(String value, {int limit = 8192}) {
|
||||
var result = value;
|
||||
// Most metadata consists of identifiers. Avoid expensive pattern scans when
|
||||
// their required marker is absent; matching and redaction stay unchanged.
|
||||
if (result.toLowerCase().contains('bearer')) {
|
||||
result = result.replaceAll(_bearer, 'Bearer [redacted]');
|
||||
}
|
||||
if (result.contains('sk-')) {
|
||||
result = result.replaceAll(_apiKey, '[redacted]');
|
||||
}
|
||||
if (result.contains(':') || result.contains('=')) {
|
||||
result = result.replaceAllMapped(
|
||||
_assignment,
|
||||
(m) => '${m[1]}=[redacted]',
|
||||
);
|
||||
}
|
||||
if (result.contains('http://') || result.contains('https://')) {
|
||||
result = result.replaceAllMapped(_url, (m) {
|
||||
final uri = Uri.tryParse(m[0]!);
|
||||
return uri == null ? '[url]' : '${uri.scheme}://${uri.host}/[redacted]';
|
||||
});
|
||||
}
|
||||
if (result.contains('/') || result.contains(r'\')) {
|
||||
result = result.replaceAll(_path, '[local-path]');
|
||||
}
|
||||
if (result.contains('@')) {
|
||||
result = result.replaceAll(_email, '[email]');
|
||||
}
|
||||
if (result.length > limit) {
|
||||
result = '${result.substring(0, limit)}…[truncated]';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Object? value(Object? input, {int depth = 0}) {
|
||||
if (depth > 8) return '[truncated]';
|
||||
if (input == null || input is bool || input is num) return input;
|
||||
if (input is String) return text(input);
|
||||
if (input is Map) {
|
||||
return <String, Object?>{
|
||||
for (final entry in input.entries.take(64))
|
||||
text(
|
||||
entry.key.toString(),
|
||||
limit: 128,
|
||||
): _privateKey.hasMatch(entry.key.toString())
|
||||
? '[redacted]'
|
||||
: value(entry.value, depth: depth + 1),
|
||||
};
|
||||
}
|
||||
if (input is Iterable) {
|
||||
return input.take(2048).map((v) => value(v, depth: depth + 1)).toList();
|
||||
}
|
||||
return text(input.toString());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user