diff --git a/Dockerfile b/Dockerfile index 84dc800..a161e2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,10 @@ RUN git clone https://github.com/sqlcipher/sqlcipher.git \ RUN wget https://bootstrap.pypa.io/get-pip.py \ && python3 get-pip.py +# RUN git clone -b pyperclip-except https://github.com/gabfl/vault.git \ +# && cd vault \ +# && pip3 install . + RUN pip3 install pyvault -ENTRYPOINT [ "vault" ] \ No newline at end of file +ENTRYPOINT [ "/bin/bash", "-c", "sqlcipher --version && pip3 freeze | grep pyvault && vault" ] \ No newline at end of file diff --git a/README.md b/README.md index 1dca22d..ea9dca4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Vault 2.x requires `sqlcipher` to be installed on your machine. ### MacOS -On MacOS, you can install `sqlcipher`` with [brew](https://brew.sh/): +On MacOS, you can install `sqlcipher` with [brew](https://brew.sh/): ```bash brew install sqlcipher @@ -54,7 +54,7 @@ vault On Ubuntu/Debian, you can install `sqlcipher` with apt: ```bash sudo apt update -sudo apt install -y gcc python3-dev libsqlcipher-dev +sudo apt install -y gcc python3-dev libsqlcipher-dev xclip ``` Then install the vault: @@ -86,7 +86,7 @@ docker run -v ~/.vault:/root/.vault -ti gabfl/vault git clone https://github.com/gabfl/vault && cd vault # Installation -python3 setup.py install +pip3 install . # Run setup vault diff --git a/setup.py b/setup.py index e998afd..21dd228 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='pyvault', - version='2.4.1', + version='2.4.2', description='Python password manager', long_description=long_description, author='Gabriel Bordeaux', diff --git a/src/unittest/views/test_clipboard.py b/src/unittest/views/test_clipboard.py index 819dd14..cf28b3d 100644 --- a/src/unittest/views/test_clipboard.py +++ b/src/unittest/views/test_clipboard.py @@ -33,6 +33,10 @@ def test_is_changed_2(self, patched): clipboard.clipboard_signature = clipboard.get_signature('some string') self.assertTrue(clipboard.is_changed()) + def test_is_changed_3(self): + clipboard.clipboard_signature = '' + self.assertIsNone(clipboard.is_changed()) + def test_getSignature(self): self.assertEqual(clipboard.get_signature( 'some string'), '61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc') @@ -42,6 +46,7 @@ def test_getSignature(self): def test_wait(self, patched, patched2): patched.return_value = 'some string' patched2.return_value = 'some string' + clipboard.clipboard_signature = clipboard.get_signature('some string') # Ensure we have a short wait time global_scope['conf'].update('clipboardTTL', '1') @@ -53,12 +58,19 @@ def test_wait(self, patched, patched2): def test_wait_2(self, patched, patched2): patched.return_value = 'some other string' patched2.return_value = 'some string' + clipboard.clipboard_signature = clipboard.get_signature('some string') # Ensure we have a short wait time global_scope['conf'].update('clipboardTTL', '1') self.assertIsNone(clipboard.wait()) self.assertEqual(clipboard.clipboard_signature, '') + def test_wait_3(self): + # Case when we have no clipboard_signature because + # pyperclip is not available + self.assertEqual(clipboard.clipboard_signature, '') + self.assertIsNone(clipboard.wait()) + @patch.object(pyperclip, 'copy') @patch.object(pyperclip, 'paste') def test_erase(self, patched, patched2): diff --git a/src/views/clipboard.py b/src/views/clipboard.py index 46b4f9a..ee65938 100644 --- a/src/views/clipboard.py +++ b/src/views/clipboard.py @@ -20,7 +20,11 @@ def copy(to_copy, name='password', erase=False): print('* Nothing to copy!') return False - pyperclip.copy(to_copy) + try: + pyperclip.copy(to_copy) + except pyperclip.PyperclipException: + print('* Error: could not find a copy/paste mechanism for your system') + return False if not erase: print('* The %s has been copied to the clipboard.' % (name)) @@ -34,7 +38,8 @@ def is_changed(): Returns `True` if the clipboard content has changed """ - return clipboard_signature != get_signature(pyperclip.paste()) + if clipboard_signature: + return clipboard_signature != get_signature(pyperclip.paste()) def get_signature(item): @@ -51,6 +56,9 @@ def wait(): Wait X seconds and erase the clipboard """ + if not clipboard_signature: + return None + print("* Clipboard will be erased in %s seconds" % (global_scope['conf'].clipboardTTL))