1. Overview
The PasswordImporter.cpp file is a Browser password-import implementation in BastionGuard.
Reads browser-exported CSV files, handles UTF-8 BOM and CRLF input, detects Chrome/Edge, Firefox, or Safari layouts, parses quoted CSV fields, and maps rows into normalized credentials.
The documentation below is generated from the supplied source and covers its API surface, runtime responsibilities, data flow, filesystem or command interactions, concurrency model, and security considerations.
2. Source Inventory
- Original path:
password_manager/PasswordImporter.cpp - Language: C++
- Source type:
.cpp - Line count: 304
- SHA-256:
dec589a8fbde832bc17b7d28ea251bd73f35b8a8a4b38e6df00501cb877cfe2b
3. Dependencies
The file declares the following compile-time dependencies:
Project
PasswordImporter.hpp
C/C++ Runtime
fstreamsstreamalgorithmregex
4. Types and Public Contract
No standalone class, structure, or enumeration is declared directly in this file.
5. API and Method Inventory
The following functions or methods are implemented in this file:
PasswordImporter::importFromFile(const std::string& path, std::string& errorMsg)– Loads a browser CSV export and dispatches it to the matching parser.PasswordImporter::detectFormat(const std::string& header)– Identifies the browser CSV layout from its header.PasswordImporter::parseChrome(const std::vector<std::string>& lines)– Parses Chrome/Edge CSV rows.PasswordImporter::parseFirefox(const std::vector<std::string>& lines)– Parses Firefox CSV rows.PasswordImporter::parseSafari(const std::vector<std::string>& lines)– Parses Safari CSV rows.PasswordImporter::splitCsvLine(const std::string& line)– Splits a CSV row while honoring quoted fields.PasswordImporter::unquoteCsv(const std::string& f)– Removes CSV quoting and unescapes doubled quotes.PasswordImporter::domainFromUrl(const std::string& url)– Extracts a normalized host name for display purposes.
6. Functional Architecture
Supported Export Layouts
- Chrome and Edge:
name,url,username,password-style columns. - Firefox: detects headers containing
httpRealmorformActionOriginand imports URL, username, and password. - Safari: detects title/notes or OTP-related columns and imports optional notes.
CSV Handling
- Removes an initial UTF-8 BOM and trailing carriage returns.
- Supports quoted fields, commas inside quoted fields, and doubled-quote escaping.
- Skips rows with neither URL nor username.
- Derives a display name from the hostname when no explicit title is available.
7. Operational Flow
- Select and read a browser-exported CSV file.
- Normalize encoding and line endings, then detect the browser format.
- Parse rows while honoring CSV quoting rules.
- Preview normalized credentials and convert them into vault entries.
- Emit or store the bulk records and report completion.
8. Filesystem and External Command Surface
No hard-coded absolute filesystem path is declared directly in this file.
Commands or Security Primitives Referenced
sh
9. Concurrency and Lifecycle
The file contains no explicit worker-thread or callback-lifetime mechanism.
10. Security Considerations
- Password metadata and encrypted secrets are separated, reducing accidental exposure through the index file.
- Cleartext passwords exist in process memory while the vault is unlocked and during import/export workflows.
- CSV import and export files are unencrypted and must be handled as sensitive data.
- Background callbacks must not outlive their owning GTK objects.
11. Implementation Considerations
- The implementation should remain synchronized with the matching header declarations.
12. Licensing and Branding
The source is distributed under the GNU General Public License version 3.
The source header identifies BastionGuard™ as a trademark and states that the name and branding are not licensed under the GPL.
The software is provided without warranty, including implied warranties of merchantability or fitness for a particular purpose.
