eblin / 1passpwnedcheck

Check your 1password exported passwords (`.1pif` files) against https://haveibeenpwned.com/Passwords in bulk using using a k-Anonymity model
MIT License
15 stars 0 forks source link

SyntaxError #1

Closed lnlyssg closed 6 years ago

lnlyssg commented 6 years ago

HI, just tried to run this (I'm on a Mac running High Sierra) but I'm getting the below complaint of a syntax error with cli.py itself:

 ~/Applications/1passpwnedcheck  master  0m  python cli.py --file=/Users/jim/Desktop/data.1pif
  File "cli.py", line 33
    return print('Please specify a file first.'
               ^
SyntaxError: invalid syntax
eblin commented 6 years ago

@jaytay79 make sure you are running it on python3. In Python 3 the print statement is now a function which is why you are getting that error, seems you are trying to run it on python 2, sierra comes with python 2.7.4 installed by default.

Prerequisites
Make sure you have the following installed

Python 3
pipenv (https://docs.pipenv.org/)

Also after you install pipenv, make sure you run pipenv install to install dependencies, and lastly pipenv shell so it kicks you into a virtual environment with python3 on it, then everything should work fine.

lnlyssg commented 6 years ago

Whoops, sorry @eblin I completely missed the pipenv shell part!

I'm getting slightly further except still have a problem, I am using 1Password 6 if that makes a difference (note I originally pasted the wrong output below, since updated):

(1passpwnedcheck-McuTCN0M) bash-3.2$ python cli.py --file=/Users/jim/Downloads/data.1pif
Traceback (most recent call last):
  File "cli.py", line 123, in <module>
    fire.Fire(PwnedCli)
  File "/Users/jim/.local/share/virtualenvs/1passpwnedcheck-McuTCN0M/lib/python3.6/site-packages/fire/core.py", line 127, in Fire
    component_trace = _Fire(component, args, context, name)
  File "/Users/jim/.local/share/virtualenvs/1passpwnedcheck-McuTCN0M/lib/python3.6/site-packages/fire/core.py", line 366, in _Fire
    component, remaining_args)
  File "/Users/jim/.local/share/virtualenvs/1passpwnedcheck-McuTCN0M/lib/python3.6/site-packages/fire/core.py", line 542, in _CallCallable
    result = fn(*varargs, **kwargs)
  File "cli.py", line 20, in __init__
    self._check_passwords(file)
  File "cli.py", line 36, in _check_passwords
    pif_json = self._pif_to_json(pif_file)
  File "cli.py", line 93, in _pif_to_json
    with open('%s/data.1pif' % path, encoding='utf-8') as pif:
NotADirectoryError: [Errno 20] Not a directory: '/Users/jim/Downloads/data.1pif/data.1pif'
lnlyssg commented 6 years ago

OK I see I need to point to the directory holding the file and not the .1pif file itself - you might want to make that a little clearer in the readme or change the behaviour as it's a little confusing.

eblin commented 6 years ago

I see, weird I am using 1password 6 as well (6.8.7 to be exact), when you export your 1pif, in finder don't you see it as a folder?

For example this is what it would look like:

├── 1passwords.1pif
│   └── data.1pif

Make sure you give the path to the directory not the data.1pif inside of it... Just pushed an update to handle path betters and support ~/Downloads shorthand paths as well.

EDIT: Just saw your reply,

OK I see I need to point to the directory holding the file and not the .1pif file itself - you might want to make that a little clearer in the readme or change the behaviour as it's a little confusing.

Yes correct I'll add something to readme