Skip to content

Commit

Permalink
Merge pull request #62 from canadaduane/no-undefined-entry-meta
Browse files Browse the repository at this point in the history
Guard against undefined meta values in entries
  • Loading branch information
perry-mitchell authored Dec 12, 2021
2 parents 70cfc04 + 353e66b commit 2782c39
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions source/tools/1passwordEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,30 @@ function onePasswordItemToEntry(rawItem) {
}
});
} else if (ENTRY_CREDITCARD.test(rawItem.typeName)) {
entry.username = rawItem.secureContents.ccnum;
entry.password = rawItem.secureContents.cvv;
entry.meta.type = rawItem.secureContents.type;
entry.meta.cardholder = rawItem.secureContents.cardholder;
entry.meta["expiry-year"] = rawItem.secureContents.expiry_yy;
entry.meta["expiry-month"] = rawItem.secureContents.expiry_mm;
entry.meta["validfrom-year"] = rawItem.secureContents.validFrom_yy;
entry.meta["validfrom-month"] = rawItem.secureContents.validFrom_mm;
if (rawItem.secureContents.ccnum) {
entry.username = rawItem.secureContents.ccnum;
}
if (rawItem.secureContents.cvv) {
entry.password = rawItem.secureContents.cvv;
}
if (rawItem.secureContents.type) {
entry.meta.type = rawItem.secureContents.type;
}
if (rawItem.secureContents.cardholder) {
entry.meta.cardholder = rawItem.secureContents.cardholder;
}
if (rawItem.secureContents.expiry_yy) {
entry.meta["expiry-year"] = rawItem.secureContents.expiry_yy;
}
if (rawItem.secureContents.expiry_mm) {
entry.meta["expiry-month"] = rawItem.secureContents.expiry_mm;
}
if (rawItem.secureContents.validFrom_yy) {
entry.meta["validfrom-year"] = rawItem.secureContents.validFrom_yy;
}
if (rawItem.secureContents.validFrom_mm) {
entry.meta["validfrom-month"] = rawItem.secureContents.validFrom_mm;
}
} else if (ENTRY_PASSWORD.test(rawItem.typeName)) {
entry.password = rawItem.secureContents.password;
} else if (ENTRY_LICENSE.test(rawItem.typeName)) {
Expand All @@ -60,19 +76,26 @@ function onePasswordItemToEntry(rawItem) {
} else if (ENTRY_EMAIL_V2.test(rawItem.typeName)) {
entry.username = rawItem.secureContents.pop_username;
entry.password = rawItem.secureContents.pop_password;
entry.meta["POP Server"] = rawItem.secureContents.pop_server;
if (rawItem.secureContents.pop_server) {
entry.meta["POP Server"] = rawItem.secureContents.pop_server;
}
} else if (ENTRY_SSN.test(rawItem.typeName)) {
entry.password = rawItem.secureContents.number;
if (rawItem.secureContents.name) {
entry.meta.Name = rawItem.secureContents.name;
}
} else if (ENTRY_ROUTER.test(rawItem)) {
entry.username = entry.meta.Network =
rawItem.secureContents.network_name ||
rawItem.secureContents.network_name;
entry.username = rawItem.secureContents.network_name;
entry.password = rawItem.secureContents.password;
entry.meta.Security = rawItem.secureContents.wireless_security;
entry.meta.Server = rawItem.secureContents.server;
if (rawItem.secureContents.network_name) {
entry.meta.Network = rawItem.secureContents.network_name;
}
if (rawItem.secureContents.wireless_security) {
entry.meta.Security = rawItem.secureContents.wireless_security;
}
if (rawItem.secureContents.server) {
entry.meta.Server = rawItem.secureContents.server;
}
} else {
return null;
}
Expand Down

0 comments on commit 2782c39

Please sign in to comment.