ShayBox / OnePasswordConverter

Convert 1Password .1pux to Bitwarden .csv
MIT License
8 stars 0 forks source link

Error running script #2

Open guslanzetta1 opened 2 years ago

guslanzetta1 commented 2 years ago

Got the following error:

gus@GUS-DESK:~/OnePasswordConverter-master$ 1passconv -f /home/gus/1pass/export.data
Processing account: Gus Lanzetta
Processing folder: Personal
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 56, in main
    favorite = item["favIndex"]
KeyError: 'favIndex'
ShayBox commented 2 years ago

Could you add -v and see what item it's getting caught at, and send that item with all your info redacted and/or changed completely

guslanzetta1 commented 2 years ago

@ShayBox not sure what I'm doing wrong, but -v is not working apparently

guslanzetta1 commented 2 years ago
gus@GUS-DESK:~/OnePasswordConverter-master$ 1passconv -v -f /home/gus/1pass/export.data
Processing account: Gus Lanzetta
Processing folder: Personal
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 56, in main
    favorite = item["favIndex"]
KeyError: 'favIndex'
gus@GUS-DESK:~/OnePasswordConverter-master$ 1passconv -v -f /home/gus/1pass/export.data -v
Processing account: Gus Lanzetta
Processing folder: Personal
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 56, in main
    favorite = item["favIndex"]
KeyError: 'favIndex'
gus@GUS-DESK:~/OnePasswordConverter-master$ 1passconv -f /home/gus/1pass/export.data -v
Processing account: Gus Lanzetta
Processing folder: Personal
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 56, in main
    favorite = item["favIndex"]
KeyError: 'favIndex'
ShayBox commented 2 years ago

I pushed a change to the script, try updating

guslanzetta1 commented 2 years ago

Tks!

guslanzetta1 commented 2 years ago

Still getting the error after building and installing the new version:

Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 56, in main
    favorite = item["favIndex"]
KeyError: 'favIndex'
ShayBox commented 2 years ago

Okay, I pushed another change, and fixed verbose

guslanzetta1 commented 2 years ago

Ok, still getting the error, but verbose output worked:

gus@GUS-DESK:~/Downloads/OnePasswordConverter-master$ 1passconv -v
Which file? [export.data]: /home/gus/1pass/export.data
Processing account: Gus Lanzetta
Processing folder: Personal
{'item': {'uuid': '2q734jqnja5v36f2ofdqtbbomq', 'favIndex': 0, 'createdAt': 1573491365, 'updatedAt': 1573491385, 'trashed': False, 'categoryUuid': '001', 'details': {'loginFields': [{'value': '40217801811', 'id': '', 'name': 'username', 'fieldType': 'T', 'designation': 'username'}, {'value': 'REDACTED', 'id': '', 'name': 'password', 'fieldType': 'P', 'designation': 'password'}], 'notesPlain': '', 'sections': [], 'passwordHistory': []}, 'overview': {'subtitle': '40217801811', 'title': 'Tudo Azul', 'url': '', 'ps': 46, 'pbe': 0.0, 'pgrng': False}}}
WARNING! This is a verbose output!
There may be private information in this output!
Remove any sensitive information before sharing!
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 68, in main
    overview = item["overview"]
KeyError: 'overview'
ShayBox commented 2 years ago

Ah, I think I figured it out, I used hasattr instead of in, it should work now :crossed_fingers:

EDIT: I knew 1Password sometimes nested the item inside an item based on docs but my client doesn't do that so I couldn't test for it. https://github.com/ShayBox/OnePasswordConverter/blob/6940a34664e186e8afc7e07c5ba9adb2b78ff7c1/onepasswordconverter/main.py#L51-L53

guslanzetta1 commented 2 years ago

Tks, gonna test the new code.

guslanzetta1 commented 2 years ago

Still the same error:

gus@GUS-DESK:~/Downloads/OnePasswordConverter-master$ 1passconv -v
Which file? [export.data]: /home/gus/1pass/export.data/
Error: '/home/gus/1pass/export.data/': Not a directory
Which file? [export.data]: /home/gus/1pass/export.data
Processing account: Gus Lanzetta
Processing folder: Personal
{'item': {'uuid': '2q734jqnja5v36f2ofdqtbbomq', 'favIndex': 0, 'createdAt': 1573491365, 'updatedAt': 1573491385, 'trashed': False, 'categoryUuid': '001', 'details': {'loginFields': [{'value': '40217801811', 'id': '', 'name': 'username', 'fieldType': 'T', 'designation': 'username'}, {'value': 'REDACTED', 'id': '', 'name': 'password', 'fieldType': 'P', 'designation': 'password'}], 'notesPlain': '', 'sections': [], 'passwordHistory': []}, 'overview': {'subtitle': '40217801811', 'title': 'Tudo Azul', 'url': '', 'ps': 46, 'pbe': 0.0, 'pgrng': False}}}
WARNING! This is a verbose output!
There may be private information in this output!
Remove any sensitive information before sharing!
Traceback (most recent call last):
  File "/home/gus/.local/bin/1passconv", line 8, in <module>
    sys.exit(main())
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gus/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/gus/.local/lib/python3.8/site-packages/onepasswordconverter/main.py", line 68, in main
    overview = item["overview"]
KeyError: 'overview'
ShayBox commented 2 years ago

I tested the item from your log and it exports, are you sure you updated to the latest commit?

EDIT: You can turn off verbose so you don't have to keep redacting the same information

guslanzetta1 commented 2 years ago

I've downloaded the new code again (this newest one) and it still gives me 0.2.0 as the version number (same as my other two downloads from earlier today) is that correct? gus@GUS-DESK:~/Downloads/OnePasswordConverter-master$ poetry build Building OnePasswordConverter (0.2.0)

guslanzetta1 commented 2 years ago

Also the new zip did not come with a dist folder apparently https://imgur.com/a/xW24xQQ

ShayBox commented 2 years ago

Yes, I haven't been updating the version number, and dist is generated when you poetry build.

is there any way you could go into your export.data and find the item you've been redacting, and send me that item (redacted ofc), and what platform are you using 1password on (Linux nvm), and what version (found in settings)

guslanzetta1 commented 2 years ago

Here's the item from the json. I'm using Ubuntu 20.10.

{
    "accounts": [
        {
            "attrs": {
                "accountName": "REDACTED",
                "name": "REDACTED",
                "avatar": "",
                "email": "REDACTED",
                "uuid": "REDACTED",
                "domain": "REDACTED"
            },
            "vaults": [
                {
                    "attrs": {
                        "uuid": "REDACTED",
                        "desc": "GYkuBJsjEZmMUuiP",
                        "avatar": "",
                        "name": "Personal",
                        "type": "P"
                    },
                    "items": [
                        {
                            "item": {
                                "uuid": "2q734jqnja5v36f2ofdqtbbomq",
                                "favIndex": 0,
                                "createdAt": 1573491365,
                                "updatedAt": 1573491385,
                                "trashed": false,
                                "categoryUuid": "001",
                                "details": {
                                    "loginFields": [
                                        {
                                            "value": "40217801811",
                                            "id": "",
                                            "name": "username",
                                            "fieldType": "T",
                                            "designation": "username"
                                        },
                                        {
                                            "value": "REDACTED",
                                            "id": "",
                                            "name": "password",
                                            "fieldType": "P",
                                            "designation": "password"
                                        }
                                    ],
                                    "notesPlain": "",
                                    "sections": [],
                                    "passwordHistory": []
                                },
                                "overview": {
                                    "subtitle": "40217801811",
                                    "title": "Tudo Azul",
                                    "url": "",
                                    "ps": 46,
                                    "pbe": 0.0,
                                    "pgrng": false
                                }
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
ShayBox commented 2 years ago

Okay, I believe I finally figured out the whole problem.
Python can't have duplicated keys in dictionaries but javascript can, and the json exported is from electron, and sometimes has a nested object with duplicated keys.
I fix the duplicated keys by appending the index to duplicates, and fix the nested object by iterating over the objects values.

guslanzetta1 commented 2 years ago

Awesome gonna test it.

guslanzetta1 commented 2 years ago

Oops thought it worked. It created a CSV file, but it stops right after that first entry that was given us trouble before.

ShayBox commented 2 years ago

What's the error message this time, the same overview keyerror?
EDIT: I just don't get what 1password is doing to cause such drastic export data differences between two computers, their codebase must be a huge mess and probably why you can't import 1pux yet.

guslanzetta1 commented 2 years ago

What's the error message this time, the same overview keyerror? EDIT: I just don't get what 1password is doing to cause such drastic export data differences between two computers, their codebase must be a huge mess and probably why you can't import 1pux yet.

Yep, the JSON itself looks weird as hell and different entries are structured completely different than others like there's no standard. Thanks for all your effort though. I've started just copying all my stuff to BitWarden manually little by little.