From af4e01c238b88ac296edfbf300a180e956da7d4b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 31 Dec 2018 12:39:59 -0500 Subject: [PATCH] avast passwords csv importer --- src/importers/avastCsvImporter.ts | 28 ++++++++++++++++++++++++++++ src/services/import.service.ts | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 src/importers/avastCsvImporter.ts diff --git a/src/importers/avastCsvImporter.ts b/src/importers/avastCsvImporter.ts new file mode 100644 index 0000000000..a1eb16574f --- /dev/null +++ b/src/importers/avastCsvImporter.ts @@ -0,0 +1,28 @@ +import { BaseImporter } from './baseImporter'; +import { Importer } from './importer'; + +import { ImportResult } from '../models/domain/importResult'; + +export class AvastCsvImporter extends BaseImporter implements Importer { + parse(data: string): ImportResult { + const result = new ImportResult(); + const results = this.parseCsv(data, true); + if (results == null) { + result.success = false; + return result; + } + + results.forEach((value) => { + const cipher = this.initLoginCipher(); + cipher.name = this.getValueOrDefault(value.name); + cipher.login.uris = this.makeUriArray(value.web); + cipher.login.password = this.getValueOrDefault(value.password); + cipher.login.username = this.getValueOrDefault(value.login); + this.cleanupCipher(cipher); + result.ciphers.push(cipher); + }); + + result.success = true; + return result; + } +} diff --git a/src/services/import.service.ts b/src/services/import.service.ts index ca32707987..fef62131d8 100644 --- a/src/services/import.service.ts +++ b/src/services/import.service.ts @@ -20,6 +20,7 @@ import { KvpRequest } from '../models/request/kvpRequest'; import { CipherView } from '../models/view/cipherView'; import { AscendoCsvImporter } from '../importers/ascendoCsvImporter'; +import { AvastCsvImporter } from '../importers/avastCsvImporter'; import { AviraCsvImporter } from '../importers/aviraCsvImporter'; import { BitwardenCsvImporter } from '../importers/bitwardenCsvImporter'; import { BitwardenJsonImporter } from '../importers/bitwardenJsonImporter'; @@ -101,6 +102,7 @@ export class ImportService implements ImportServiceAbstraction { { id: 'passwordagentcsv', name: 'Password Agent (csv)' }, { id: 'passpackcsv', name: 'Passpack (csv)' }, { id: 'passmanjson', name: 'Passman (json)' }, + { id: 'avastcsv', name: 'Avast Passwords (csv)' }, ]; constructor(private cipherService: CipherService, private folderService: FolderService, @@ -223,6 +225,8 @@ export class ImportService implements ImportServiceAbstraction { return new PasspackCsvImporter(); case 'passmanjson': return new PassmanJsonImporter(); + case 'avastcsv': + return new AvastCsvImporter(); default: return null; }