Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3649dcb

Browse filesBrowse files
committed
ENH Add tabular output with -t/--tabular
1 parent 5d3ade8 commit 3649dcb
Copy full SHA for 3649dcb

File tree

Expand file treeCollapse file tree

6 files changed

+38
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+38
-7
lines changed
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#### Changelog
22

3+
##### 0.6.2
4+
- Add `--tabular` output
5+
36
##### 0.6.1
47
- Fix a bug on `--version` affecting primarily Python 3 (@criztovyl)
58

Collapse file

‎firefox_decrypt.py‎

Copy file name to clipboardExpand all lines: firefox_decrypt.py
+19-7Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def internal_version():
7575
return stdout.strip().decode("utf-8")
7676

7777

78-
__version_info__ = (0, 6, 1)
78+
__version_info__ = (0, 6, 2)
7979
__version__ = get_version()
8080

8181

@@ -366,16 +366,23 @@ def decode_entry(self, user, passw):
366366

367367
return user, passw
368368

369-
def decrypt_passwords(self, profile, password, export):
369+
def decrypt_passwords(self, profile, password, export, tabular):
370370
"""
371371
Decrypt requested profile using the provided password and print out all
372372
stored passwords.
373373
"""
374374

375+
def output_line(line):
376+
if PY3:
377+
sys.stdout.write(line)
378+
else:
379+
sys.stdout.write(line.encode("utf8"))
380+
375381
self.initialize_libnss(profile, password)
376382

377383
# Any password in this profile store at all?
378384
got_password = False
385+
header = False
379386

380387
credentials = obtain_credentials(profile)
381388

@@ -407,17 +414,20 @@ def decrypt_passwords(self, profile, password, export):
407414
else:
408415
to_export[address.netloc][user] = passw
409416

417+
elif tabular:
418+
if header:
419+
output_line(u"Website\tUsername\tPassword}\n".format(host, user, passw))
420+
421+
output_line(u"'{0}'\t'{1}'\t'{2}'\n".format(host, user, passw))
422+
410423
else:
411424
output = (
412425
u"\nWebsite: {0}\n".format(host),
413426
u"Username: '{0}'\n".format(user),
414427
u"Password: '{0}'\n".format(passw),
415428
)
416429
for line in output:
417-
if PY3:
418-
sys.stdout.write(line)
419-
else:
420-
sys.stdout.write(line.encode("utf8"))
430+
output_line(line)
421431

422432
credentials.done()
423433
self.NSS.NSS_Shutdown()
@@ -701,6 +711,8 @@ def parse_sys_args():
701711
help="Path to profile folder (default: {0})".format(profile_path))
702712
parser.add_argument("-e", "--export-pass", action="store_true",
703713
help="Export URL, username and password to pass from passwordstore.org")
714+
parser.add_argument("-t", "--tabular", action="store_true",
715+
help="Output in tabular format")
704716
parser.add_argument("-n", "--no-interactive", action="store_true",
705717
help="Disable interactivity.")
706718
parser.add_argument("-c", "--choice", nargs=1,
@@ -760,7 +772,7 @@ def main():
760772
password = ask_password(profile, args.no_interactive)
761773

762774
# And finally decode all passwords
763-
nss.decrypt_passwords(profile, password, args.export_pass)
775+
nss.decrypt_passwords(profile, password, args.export_pass, args.tabular)
764776

765777

766778
if __name__ == "__main__":
Collapse file

‎tests/tabular_46.t‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
. bash_tap_fd.sh
3+
4+
PASSWD=$(get_password)
5+
CMD="$(get_script) --tabular"
6+
TEST="$(get_test_data)/test_profile_firefox_46/"
7+
8+
9+
diff -u <(echo ${PASSWD} | ${CMD} ${TEST} | grep doesntexist || kill $$) <(get_user_data "doesntexist_tabular")
10+
diff -u <(echo ${PASSWD} | ${CMD} ${TEST} | grep onemore || kill $$) <(get_user_data "onemore_tabular")
11+
diff -u <(echo ${PASSWD} | ${CMD} ${TEST} | grep cömplex || kill $$) <(get_user_data "complex_tabular")
12+
13+
# vim: ai sts=4 et sw=4
Collapse file
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'https://github.com' 'cömplex' 'сЮЛОажс$4vz*VçàhxpfCbmwo'
Collapse file
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'https://github.com' 'doesntexist' 'xrbSDzYf94gfk'
Collapse file
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'https://github.com' 'onemore' '}]¢öðæ[{'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.