Browse Source

log more debugging info when unable to decode protected value.

pull/3/head
Herbert Poul 4 years ago
parent
commit
68be3c5ef6
  1. 8
      lib/src/internal/extension_utils.dart
  2. 16
      lib/src/kdbx_format.dart

8
lib/src/internal/extension_utils.dart

@ -21,6 +21,14 @@ extension XmlElementExt on xml.XmlElement {
return findElements(nodeName).single.text; return findElements(nodeName).single.text;
} }
Iterable<xml.XmlElement> breadcrumbs() {
final ret = parentElement?.let((p) => p.breadcrumbs()) ?? [];
return [this].followedBy(ret);
}
String breadcrumbsNames() =>
breadcrumbs().map((e) => e.name.local).join(' / ');
/// If an element child with the given name already exists, /// If an element child with the given name already exists,
/// it will be removed and the given element will be added. /// it will be removed and the given element will be added.
/// otherwise it will be only added. /// otherwise it will be only added.

16
lib/src/kdbx_format.dart

@ -773,11 +773,27 @@ class KdbxFormat {
for (final el in document for (final el in document
.findAllElements(KdbxXml.NODE_VALUE) .findAllElements(KdbxXml.NODE_VALUE)
.where((el) => el.getAttributeBool(KdbxXml.ATTR_PROTECTED))) { .where((el) => el.getAttributeBool(KdbxXml.ATTR_PROTECTED))) {
try {
final pw = gen.decryptBase64(el.text.trim()); final pw = gen.decryptBase64(el.text.trim());
if (pw == null) { if (pw == null) {
continue; continue;
} }
KdbxFile.protectedValues[el] = ProtectedValue.fromString(pw); KdbxFile.protectedValues[el] = ProtectedValue.fromString(pw);
} catch (e, stackTrace) {
final stringKey =
el.parentElement.singleElement(KdbxXml.NODE_KEY)?.text;
final uuid = el.parentElement?.parentElement
?.singleElement(KdbxXml.NODE_UUID)
?.text;
_logger.severe(
'Error while decoding protected value in '
'{${el.breadcrumbsNames()}} of key'
' {$stringKey} of entry {$uuid}.',
e,
stackTrace);
rethrow;
}
} }
final keePassFile = document.findElements('KeePassFile').single; final keePassFile = document.findElements('KeePassFile').single;

Loading…
Cancel
Save