From a2637c9df724bba08773afaa2322657854ba7c61 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 5 May 2019 23:43:42 +0100 Subject: [PATCH 1/9] Publish code coverage report with GitLab Pages. --- .gitlab-ci.yml | 18 ++++++++++++++++++ Makefile | 1 + 2 files changed, 19 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fbfecdd..748f2f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ stages: - lint - test + - deploy bash: stage: lint @@ -51,6 +52,10 @@ archlinux: image: archlinux/base before_script: - pacman -Syu --noconfirm --noprogressbar make python-pip which grep pass + artifacts: + expire_in: 2 days + paths: + - htmlcov/ <<: *script ubuntu: @@ -76,3 +81,16 @@ fedora: - dnf -y install make gpg pass python3-pip grep which --setopt=install_weak_deps=False <<: *script <<: *only + +pages: + stage: deploy + dependencies: + - archlinux + script: + - mv htmlcov/ public/ + artifacts: + expire_in: 2 days + paths: + - public + only: + - master diff --git a/Makefile b/Makefile index d083212..4ed0c54 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ T = $(sort $(wildcard tests/test_*.sh)) tests: @python3 setup.py green -vvv --run-coverage --termcolor --processes $(shell nproc) + @coverage html @make tests_bash tests_bash: $(T) From c4aefefdf8079f0be0169a635183448d89366062 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 5 May 2019 23:57:18 +0100 Subject: [PATCH 2/9] Add coverage website link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbe37e7..65867a9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Pipeline Status - + Code Coverage From 789cb4a80c9bfc3586317d65a8897d4b95dfafad Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 18 May 2019 20:09:49 +0100 Subject: [PATCH 3/9] CI: Also test the install. --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 748f2f4..a2f57e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,11 @@ sast: stage: test script: - pip3 install green coverage defusedxml + - make - make tests + - make install + - cd ~ + - pass import --help .only: &only only: From f10eea7cbc9c532a4d32ce6949cd88117cf25365 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 18 May 2019 20:11:45 +0100 Subject: [PATCH 4/9] Ensure the python prefix is always the one from the distribution #67 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4ed0c54..5697e64 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ install: @install -v -m 0755 "$(PROG).bash" "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/$(PROG).bash" @install -v -m 0644 "pass-$(PROG).1" "$(DESTDIR)$(MANDIR)/man1/pass-$(PROG).1" @install -v -m 0644 "completion/pass-$(PROG).bash" "$(DESTDIR)$(BASHCOMPDIR)/pass-$(PROG)" - @python3 setup.py install --root="$(DESTDIR)" --prefix="$(PREFIX)" --optimize=1 --skip-build + @python3 setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build @echo @echo "pass-$(PROG) is installed succesfully" @echo From 9e20cda8222865bbd0d85e22e9f11dfeef9d6411 Mon Sep 17 00:00:00 2001 From: Ara Hayrabedian Date: Sun, 28 Apr 2019 00:32:11 +0200 Subject: [PATCH 5/9] add in encryptr support. establish arbitrary card fields. add in tests for card types --- pass_import.py | 49 ++++++++++++++++++++++++++++++++++++++ tests/db/card/encryptr.csv | 2 ++ tests/db/encryptr.csv | 16 +++++++++++++ tests/test_importers.py | 31 +++++++++++++++++++++--- 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 tests/db/card/encryptr.csv create mode 100644 tests/db/encryptr.csv diff --git a/pass_import.py b/pass_import.py index 65ad829..0df89f9 100644 --- a/pass_import.py +++ b/pass_import.py @@ -42,6 +42,7 @@ 'chrome': ['Chrome', 'https://support.google.com/chrome'], 'chromesqlite': ['ChromeSQLite', 'https://support.google.com/chrome'], 'dashlane': ['Dashlane', 'https://www.dashlane.com/'], + 'encryptr': ['Encryptr', 'https://spideroak.com/encryptr/'], 'enpass': ['Enpass', 'https://www.enpass.io/'], 'enpass6': ['Enpass6', 'https://www.enpass.io/'], 'fpm': ['FigaroPM', 'http://fpm.sourceforge.net/'], @@ -737,6 +738,54 @@ class Dashlane(PasswordManagerCSV): 'url': 'url', 'comments': 'comments'} +class Encryptr(PasswordManagerCSV): + # Looking at how Encryptr processes exports here (method getCsvFields): + # /~https://github.com/SpiderOak/Encryptr/blob/master/src/views/MainView.js#L163 + # and entry types contained here: + # /~https://github.com/SpiderOak/Encryptr/tree/master/src/models/types + # we conclude: + # Every record has metadata: "Entry Type","Label" + # Every record happens to have, independently: "Notes" + # Password type has: "Username","Password", "Site URL" + # General type has: "Text" + # Credit card type has: "Type", "Name on card", "Card Number", "CVV", "Expiry" + # encryptr dynamically generates CSVs based on available entry types, + # and supports credit cards. + # all told, we have, in no particular order as it's dynamic: + # "Entry Type","Label", "Notes", "Username", "Password", "Site URL", + # "Text", "Type", "Name on card", "Card Number", "CVV", "Expiry" + + # and now let's map it all. Ignoring Entry Type. + keyslist = [ + 'title', 'password', 'login', 'url', 'comments', 'text', + 'card-type', 'card-name-on-card', 'card-number', 'card-cvv', + 'card-expiry' + ] + keys = { + 'title': 'Label', + 'password': 'Password', + 'login': 'Username', + 'url': 'Site URL', + 'comments': 'Notes', + 'text': 'Text', # do we want to consider this + # a password since it was the + # "secret" for general type? + 'card-type': "Type", + 'card-name-on-card': "Name on card", + 'card-number': "Card Number", + 'card-cvv': "CVV", + 'card-expiry': "Expiry" + } + + # since it's dynamically generated, there is no guarantee + # that all keys are there (e.g, no credit cards, no keys related to it.) + # so we only check for those that are there with at least one entry. + def _checkformat(self, fieldnames): + for csvkey in ("Entry Type", "Label", "Notes"): + if csvkey not in fieldnames: + raise FormatError() + + class Enpass(PasswordManagerCSV): format = '"Title","Field","Value","Field","Value",.........,"Note"' keys = {'title': 'Title', 'password': 'Password', 'login': 'Username', diff --git a/tests/db/card/encryptr.csv b/tests/db/card/encryptr.csv new file mode 100644 index 0000000..d7ba81d --- /dev/null +++ b/tests/db/card/encryptr.csv @@ -0,0 +1,2 @@ +Entry Type,Label,Password,Username,Site URL,Notes,Text,Type,Name on card,Card Number,CVV,Expiry +Credit Card,Goliath National Bank,,,,note here,,Visatron,J Smith,5012345678900000,123,22/01 diff --git a/tests/db/encryptr.csv b/tests/db/encryptr.csv new file mode 100644 index 0000000..6d34458 --- /dev/null +++ b/tests/db/encryptr.csv @@ -0,0 +1,16 @@ +Entry Type,Label,Password,Username,Site URL,Notes,Text,Type,Name on card,Card Number,CVV,Expiry +Password,mastodon.social,D_H8X%T]7>f}7|:U!Zs,jsdkyvbwjn,www.ovh.com/manager/web/,,,,,,, +Password,ovh.com,"3Z-VW!i,j(&!zRGPu(hFe]s'(",bynbyjhqjz,www.ovh.com/manager/web/,,,,,,, +Password,aib,"ws5T@;_UB[Q|P!8'`~z%XC'JHFUbf#IX _E0}:HF,[{ei0hBg14",dpbx@fner.ws,onlinebanking.aib.ie,462916,,,,,, +Password,dpbx@afoqwdr.tx,9KVHnx:.S_S;cF`=CE@e\p{v6,dpbx,afoqwdr.tx,,,,,,, +Password,dpbx@klivak.xb,"2cUqe}e9}>IVZf)Ye>3C8ZN,r",dpbx,,This is a garbage address,,,,,, +Password,dpbx@mnyfymt.ws,rPCkmNkhIa>{izt3C3F823!Go,dpbx,mail.mnyfymt.ws,,,,,,, +Password,dpbx@fner.ws,mt}h'hSUCY;SU;;A!l[8y3O:8,dpbx,,For financial purpose only!,,,,,, +Password,space title,]stDKo{%pk,vkeelpbu,nhysdo.wg,,,,,,, +Password,empty entry,,,,,,,,,, +Password,empty password,,vkeelpbu,nhysdo.wg,,,,,,, +General,note,,,,,"This is a multiline note entry. Cube shank petroleum guacamole dart mower +acutely slashing upper cringing lunchbox tapioca wrongful unbeaten sift.",,,,, diff --git a/tests/test_importers.py b/tests/test_importers.py index 57307c3..6680733 100755 --- a/tests/test_importers.py +++ b/tests/test_importers.py @@ -69,6 +69,15 @@ Odict([('title', 'eduroam'), ('password', 'X3 Date: Sun, 28 Apr 2019 10:35:28 +0200 Subject: [PATCH 6/9] fix up codacy issues --- tests/test_importers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_importers.py b/tests/test_importers.py index 6680733..e21699c 100755 --- a/tests/test_importers.py +++ b/tests/test_importers.py @@ -154,14 +154,14 @@ def test_importers_networkmanager(self): self.assertImport(keys, importer.data, REF_WIFI) def test_importers_card(self): - keys = ['title', 'card-type', 'card-name-on-card', 'card-number', 'card-cvv', 'card-expiry'] - testpath = os.path.join(self.db, 'card') + keys = ['title', 'card-type', 'card-name-on-card', + 'card-number', 'card-cvv', 'card-expiry'] for manager in self.CARD_IMPORTERS: with self.subTest(manager): importer = self._class(manager) # however, it's in a different folder test_filename, encoding = self._path(manager, folder="card") - with open(test_filename, 'r', encoding='utf-8') as file: + with open(test_filename, 'r', encoding=encoding) as file: importer.parse(file) self.assertImport(keys, importer.data, REF_CARD) From 6eea58b233e15174ea3653da7a56ea4ea435e524 Mon Sep 17 00:00:00 2001 From: Ara Hayrabedian Date: Sun, 19 May 2019 14:22:44 +0200 Subject: [PATCH 7/9] update readme/manpage with encryptr support information --- README.md | 2 ++ pass-import.1 | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 65867a9..b10eedb 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Pass import handles duplicates and is compatible with [browserpass][bp]. | [buttercup][buttercup] | *File > Export > Export File to CSV* | `pass import buttercup file.csv` | | [chrome][chrome] | *See this [guide][export-chrome]* | `pass import chrome file.csv` | | [chromesqlite][chrome] | *See this [guide][export-chrome]* | `pass import chrome file.csv` | +| [encryptr][encryptr] | *See this [encryptr issue](/~https://github.com/SpiderOak/Encryptr/issues/295#issuecomment-322449705)* | `pass import encryptr file.csv` | | [enpass][enpass] | *File > Export > As CSV* | `pass import enpass file.csv` | | [enpass6][enpass] | *Menu > File > Export > As JSON* | `pass import enpass6 file.json` | | [dashlane][dashlane] | *File > Export > Unsecured Archive in CSV* | `pass import dashlane file.csv` | @@ -271,6 +272,7 @@ Feedback, contributors, pull requests are all very welcome. Please read the [buttercup]: https://buttercup.pw/ [chrome]: https://support.google.com/chrome [dashlane]: https://www.dashlane.com/ +[encryptr]: https://spideroak.com/encryptr/ [enpass]: https://www.enpass.io/ [fpm]: http://fpm.sourceforge.net/ [gorilla]: /~https://github.com/zdia/gorilla/wiki diff --git a/pass-import.1 b/pass-import.1 index b9ec480..932a490 100644 --- a/pass-import.1 +++ b/pass-import.1 @@ -196,6 +196,16 @@ Export: File > Export > Unsecured Archive in CSV Command: pass import dashlane file.csv +.TP +\fBencryptr\fP +Website: \fIhttps://spideroak.com/encryptr/\fP + +Export: Compile from source and follow instructions here: + +\fI/~https://github.com/SpiderOak/Encryptr/issues/295#issuecomment-322449705\fP + +Command: pass import encryptr file.csv + .TP \fBenpass\fP Website: \fIhttps://www-enpass.io/\fP From b753e647d40e7c12f8e9db7cb61ed20e34ded517 Mon Sep 17 00:00:00 2001 From: Ara Hayrabedian Date: Sun, 19 May 2019 14:31:24 +0200 Subject: [PATCH 8/9] standardize how we read keys in encryptr importer --- pass_import.py | 14 +++----------- tests/test_importers.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/pass_import.py b/pass_import.py index 0df89f9..38cb3a8 100644 --- a/pass_import.py +++ b/pass_import.py @@ -756,11 +756,6 @@ class Encryptr(PasswordManagerCSV): # "Text", "Type", "Name on card", "Card Number", "CVV", "Expiry" # and now let's map it all. Ignoring Entry Type. - keyslist = [ - 'title', 'password', 'login', 'url', 'comments', 'text', - 'card-type', 'card-name-on-card', 'card-number', 'card-cvv', - 'card-expiry' - ] keys = { 'title': 'Label', 'password': 'Password', @@ -770,17 +765,14 @@ class Encryptr(PasswordManagerCSV): 'text': 'Text', # do we want to consider this # a password since it was the # "secret" for general type? - 'card-type': "Type", - 'card-name-on-card': "Name on card", - 'card-number': "Card Number", - 'card-cvv': "CVV", - 'card-expiry': "Expiry" + 'group': 'Entry Type', } # since it's dynamically generated, there is no guarantee # that all keys are there (e.g, no credit cards, no keys related to it.) # so we only check for those that are there with at least one entry. - def _checkformat(self, fieldnames): + @classmethod + def _checkformat(cls, fieldnames): for csvkey in ("Entry Type", "Label", "Notes"): if csvkey not in fieldnames: raise FormatError() diff --git a/tests/test_importers.py b/tests/test_importers.py index e21699c..20ebfe9 100755 --- a/tests/test_importers.py +++ b/tests/test_importers.py @@ -71,11 +71,11 @@ REF_CARD = [ Odict([('title', "Goliath National Bank"), - ('card-type', "Visatron"), - ('card-name-on-card', "J Smith"), - ('card-number', "5012345678900000"), - ('card-cvv', "123"), - ('card-expiry', "22/01")]), + ('Type', "Visatron"), + ('Name on card', "J Smith"), + ('Card Number', "5012345678900000"), + ('CVV', "123"), + ('Expiry', "22/01")]), ] @@ -128,12 +128,11 @@ def _class(manager): class TestImporters(TestBaseImporters): - CARD_IMPORTERS = ['encryptr',] def test_importers(self): """Testing: importer parse method using real data.""" keys = ['title', 'password', 'login', 'ssid'] - ignore = ['networkmanager', 'card'] + ignore = ['networkmanager'] for manager in pass_import.importers: if manager in ignore: continue @@ -154,9 +153,10 @@ def test_importers_networkmanager(self): self.assertImport(keys, importer.data, REF_WIFI) def test_importers_card(self): - keys = ['title', 'card-type', 'card-name-on-card', - 'card-number', 'card-cvv', 'card-expiry'] - for manager in self.CARD_IMPORTERS: + card_managers = ['encryptr',] + keys = ['title', 'Type', 'Name on card', + 'Card Number', 'CVV', 'Expiry'] + for manager in card_managers: with self.subTest(manager): importer = self._class(manager) # however, it's in a different folder From f269cbad8cf289e2c4f4e321f80e10dc991fabda Mon Sep 17 00:00:00 2001 From: Ara Hayrabedian Date: Sun, 19 May 2019 15:12:26 +0200 Subject: [PATCH 9/9] remove ordering requirement from tests as encryptr exports are non-deterministic --- tests/test_importers.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_importers.py b/tests/test_importers.py index 20ebfe9..58bacca 100755 --- a/tests/test_importers.py +++ b/tests/test_importers.py @@ -70,12 +70,14 @@ ('password', 'X3