Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-11624] Fixed SecureSafe csv import fail #10875

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

macronym
Copy link

@macronym macronym commented Sep 4, 2024

🎟️ Tracking

#10786

📔 Objective

SecureSafe exports csvs in a format where headers can be in non-English form and where every value is surrounded by slashes (Ex: /Titel/ vs. Title). This was causing the import to fail when trying to reference value.Title. I replaced the headers with those described in SecureSafe's website so the import succeeds and removed any surrounding slashes from the values since those are unintended.

https://help.securesafe.com/exporting-passwords

📸 Screenshots

image
image

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@macronym macronym requested a review from a team as a code owner September 4, 2024 04:11
@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal Community PR board for review.
ID: PM-11624

@bitwarden-bot bitwarden-bot changed the title Fixed SecureSafe csv import fail [PM-11624] Fixed SecureSafe csv import fail Sep 4, 2024
@djsmith85 djsmith85 linked an issue Sep 4, 2024 that may be closed by this pull request
1 task
@djsmith85
Copy link
Contributor

@macronym Thank you for your contribution 🚀. I haven't had any time yet to investigate further, but assuming the surrounding slashes on column headers are present on all SecureSafe exports, this seems to address the issue.

This PR does not solve the original issue with translated column headers. Examples are currently present in German and French but there might be more.

@djsmith85 djsmith85 self-assigned this Sep 4, 2024
@macronym
Copy link
Author

macronym commented Sep 4, 2024

Ah, my apologies. So I need to also translate column headers to the English headers. I will continue to look for a solution later today.

* Replace headers with english form
* Remove slashes surrounding the values if present
* Added test
@macronym
Copy link
Author

macronym commented Sep 5, 2024

Hey @djsmith85 I believe I have written an improved solution that accounts for translated headers. Do I have to reissue another pull request or just push to the same branch I was working on before?

@djsmith85
Copy link
Contributor

Same branch is fine

@macronym
Copy link
Author

macronym commented Sep 7, 2024

Same branch is fine

How do I get it reviewed?

@djsmith85 djsmith85 self-requested a review September 9, 2024 14:29
Comment on lines +15 to +32
// SecureSafe currently exports values in multiple languages. - 09/05/2024
// New headers are used to ensure import success.
const newHeaders = ["Title", "Username", "Password", "URL", "Comment"];

// SecureSafe can surround values in slashes. - 09/05/2024
// This removes any surrounding slashes from the values.
const headers = Object.keys(results[0]);
const remappedResults = results.map((row) => {
const remappedRow: any = {};
newHeaders.forEach((header, index) => {
let value = row[headers[index]];
if (typeof value === "string" && value.startsWith("/") && value.endsWith("/")) {
value = value.slice(1, -1);
}
remappedRow[header] = value;
});
return remappedRow;
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the headers always come in the same order, can we simply refer to them by index instead of by name? I would imagine it'd be more reliable than trying to translate the source language

@Tyrrrz Tyrrrz self-assigned this Oct 4, 2024
@djsmith85 djsmith85 removed their assignment Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SecureSafe: Import Fail
4 participants