pws 1.0.0.pre.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -5
- data/features/add.feature +3 -3
- data/features/create.feature +1 -0
- data/features/generate.feature +2 -3
- data/features/in-out.feature +5 -5
- data/features/master.feature +4 -5
- data/features/misc.feature +6 -4
- data/features/rename.feature +4 -4
- data/features/resave.feature +12 -12
- data/features/step_definitions/pws_steps.rb +2 -2
- data/features/support/env.rb +6 -2
- data/features/update-generate.feature +118 -0
- data/features/update.feature +3 -4
- data/lib/pws/format/1.0.rb +1 -1
- data/lib/pws/runner.rb +50 -9
- data/lib/pws/version.rb +1 -1
- data/lib/pws.rb +33 -17
- data/pws.gemspec +1 -1
- metadata +7 -6
data/README.md
CHANGED
@@ -2,7 +2,6 @@ pws [![Build status](http://travis-ci.org/janlelis/pws.png)](http://travis-ci.or
|
|
2
2
|
===
|
3
3
|
pws is a command-line password safe/manager written in Ruby.
|
4
4
|
|
5
|
-
*ATTENTION* Refactoring in progress / The latest stable version is 0.9.2
|
6
5
|
|
7
6
|
Usage
|
8
7
|
---
|
@@ -16,12 +15,11 @@ You can install pws with
|
|
16
15
|
|
17
16
|
Run `$ pws --help` for usage information.
|
18
17
|
|
18
|
+
On linux, please make sure you've got `xclip` or `xsel` installed (clipboard).
|
19
19
|
|
20
|
-
1.0 / Updating from 0.9
|
21
|
-
---
|
22
|
-
You can try out the newest version with:
|
23
|
-
`$ gem install pws --pre`
|
24
20
|
|
21
|
+
Updating from 0.9
|
22
|
+
---
|
25
23
|
The 0.9 password files are not compatible with that version, however, you can convert your safe with:
|
26
24
|
`$ pws resave --in 0.9 --out 1.0`
|
27
25
|
|
@@ -33,6 +31,7 @@ Trust the code by reading the source! It's originally based on [this tutorial](h
|
|
33
31
|
|
34
32
|
Contributions by
|
35
33
|
---
|
34
|
+
* [namelessjon](https://github.com/namelessjon)
|
36
35
|
* [brianewing](https://github.com/brianewing/)
|
37
36
|
* [dquimper](https://github.com/dquimper/)
|
38
37
|
* [grapz](https://github.com/grapz/)
|
data/features/add.feature
CHANGED
@@ -44,14 +44,14 @@ Feature: Add
|
|
44
44
|
Then the output should contain "Master password:"
|
45
45
|
And the output should contain "NO ACCESS"
|
46
46
|
|
47
|
-
@slow-hack
|
47
|
+
@very-slow-hack
|
48
48
|
Scenario: Set a new password for "github", this also sets the timestamp
|
49
49
|
Given A safe exists with master password "my_master_password"
|
50
50
|
When I run `pws ls` interactively
|
51
51
|
And I type "my_master_password"
|
52
|
-
Then the output
|
52
|
+
Then the output should not contain the current date
|
53
53
|
When I run `pws add github github_password` interactively
|
54
54
|
And I type "my_master_password"
|
55
55
|
And I run `pws show` interactively
|
56
56
|
And I type "my_master_password"
|
57
|
-
Then the output
|
57
|
+
Then the output should contain the current date
|
data/features/create.feature
CHANGED
data/features/generate.feature
CHANGED
@@ -23,7 +23,6 @@ Feature: Generate
|
|
23
23
|
And the output should contain "The password for github is now available in your clipboard for 1 second"
|
24
24
|
|
25
25
|
@wait-11s
|
26
|
-
@slow-hack
|
27
26
|
Scenario: Generate a new password for "github", PWS_SECONDS set to 5, gets passed to the get as keep-in-clipboard time
|
28
27
|
Given A safe exists with master password "my_master_password"
|
29
28
|
When I set env variable "PWS_SECONDS" to "5"
|
@@ -54,7 +53,7 @@ Feature: Generate
|
|
54
53
|
And the clipboard should match /^.{64}$/
|
55
54
|
|
56
55
|
@slow-hack
|
57
|
-
Scenario: Generate a new password for "github", default length of
|
56
|
+
Scenario: Generate a new password for "github", default length of PWS_LENGTH
|
58
57
|
Given A safe exists with master password "my_master_password"
|
59
58
|
When I set env variable "PWS_LENGTH" to "15"
|
60
59
|
And I run `pws generate github 0` interactively
|
@@ -85,7 +84,7 @@ Feature: Generate
|
|
85
84
|
And the clipboard should match ^[!\"\#$%&'()*+,\-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~]+$
|
86
85
|
|
87
86
|
@slow-hack
|
88
|
-
Scenario: Generate a new password for "github", the default char pool
|
87
|
+
Scenario: Generate a new password for "github", the default char pool PWS_CHARPOOL
|
89
88
|
Given A safe exists with master password "my_master_password"
|
90
89
|
When I set env variable "PWS_CHARPOOL" to "a"
|
91
90
|
When I run `pws generate github 0` interactively
|
data/features/in-out.feature
CHANGED
@@ -37,13 +37,13 @@ Feature: --in and --out options
|
|
37
37
|
Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
|
38
38
|
When I run `pws resave --in 0.9 --out 1.0` interactively
|
39
39
|
And I type "password"
|
40
|
-
Then the output
|
41
|
-
Then the output
|
40
|
+
Then the output should contain "Master password:"
|
41
|
+
Then the output should contain "resaved"
|
42
42
|
When I run `pws` interactively
|
43
43
|
And I type "password"
|
44
|
-
Then the output
|
45
|
-
Then the output
|
46
|
-
Then the output
|
44
|
+
Then the output should contain "Master password:"
|
45
|
+
Then the output should contain "Entries"
|
46
|
+
Then the output should contain "github"
|
47
47
|
|
48
48
|
Scenario: Trying to convert to 0.9, but --out 0.9 is not supported
|
49
49
|
Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
|
data/features/master.feature
CHANGED
@@ -16,8 +16,8 @@ Feature: Master
|
|
16
16
|
And the output should contain "The master password has been changed"
|
17
17
|
When I run `pws` interactively
|
18
18
|
And I type "my_master_password"
|
19
|
-
And the output
|
20
|
-
And the output
|
19
|
+
And the output should contain "Master password"
|
20
|
+
And the output should contain "NO ACCESS"
|
21
21
|
|
22
22
|
Scenario: Try to change the master password (but password confirmation is wrong)
|
23
23
|
Given A safe exists with master password "my_master_password"
|
@@ -30,7 +30,6 @@ Feature: Master
|
|
30
30
|
And the output should contain "again"
|
31
31
|
And the output should contain "don't match"
|
32
32
|
|
33
|
-
@slow-hack
|
34
33
|
Scenario: Change the master password, already passing it as command line parameter (not recommended)
|
35
34
|
Given A safe exists with master password "my_master_password"
|
36
35
|
When I run `pws master my_new_master_password` interactively
|
@@ -49,8 +48,8 @@ Feature: Master
|
|
49
48
|
And the output should contain "The master password has been changed"
|
50
49
|
When I run `pws` interactively
|
51
50
|
And I type ""
|
52
|
-
Then the output
|
53
|
-
And the output
|
51
|
+
Then the output should contain "Master password:"
|
52
|
+
And the output should contain "There aren't any passwords stored"
|
54
53
|
|
55
54
|
Scenario: Try to change the master password (but enter the old one wrong)
|
56
55
|
Given A safe exists with master password "my_master_password"
|
data/features/misc.feature
CHANGED
@@ -3,15 +3,17 @@ Feature: Misc
|
|
3
3
|
As a user
|
4
4
|
I want ensure the password safe behaves nicely
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
|
6
|
+
Scenario: I am calling with too few arguments
|
7
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
|
9
8
|
When I run `pws get` interactively
|
10
9
|
And I type "my_master_password"
|
11
10
|
And the output should contain "Wrong number of arguments"
|
11
|
+
|
12
|
+
Scenario: I am calling with too many arguments
|
13
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
|
12
14
|
When I run `pws get github with far too many args` interactively
|
13
15
|
And I type "my_master_password"
|
14
|
-
And the output
|
16
|
+
And the output should contain "Wrong number of arguments"
|
15
17
|
|
16
18
|
Scenario: I am calling a task that does not exist
|
17
19
|
Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
|
data/features/rename.feature
CHANGED
@@ -3,7 +3,7 @@ Feature: Rename
|
|
3
3
|
As a user
|
4
4
|
I want to rename passwords in my password safe
|
5
5
|
|
6
|
-
@slow-hack
|
6
|
+
@very-slow-hack
|
7
7
|
Scenario: Rename the password entry "github" to "gh"
|
8
8
|
Given A safe exists with master password "my_master_password" and a key "github" with password "github_password"
|
9
9
|
When I run `pws rename github gh` interactively
|
@@ -12,9 +12,9 @@ Feature: Rename
|
|
12
12
|
And the output should contain "The password entry github has been renamed to gh"
|
13
13
|
When I run `pws show` interactively
|
14
14
|
And I type "my_master_password"
|
15
|
-
Then the output
|
16
|
-
And the output
|
17
|
-
And the output
|
15
|
+
Then the output should contain "Master password:"
|
16
|
+
And the output should contain "Entries"
|
17
|
+
And the output should contain "gh"
|
18
18
|
And the output from "pws show" should not contain "github"
|
19
19
|
|
20
20
|
Scenario: Try to rename the password entry "github" to "gh" (but github does not exist)
|
data/features/resave.feature
CHANGED
@@ -11,27 +11,27 @@ Feature: Resave
|
|
11
11
|
| entries | 678 |
|
12
12
|
When I run `pws resave` interactively
|
13
13
|
And I type "my_master_password"
|
14
|
-
Then the output
|
14
|
+
Then the output should contain "resaved"
|
15
15
|
When I run `pws` interactively
|
16
16
|
And I type "my_master_password"
|
17
|
-
And the output
|
18
|
-
And the output
|
19
|
-
And the output
|
17
|
+
And the output should contain "some"
|
18
|
+
And the output should contain "password"
|
19
|
+
And the output should contain "entries"
|
20
20
|
|
21
21
|
@slow-hack
|
22
22
|
Scenario: Useful for converting when used together with --in and --out options
|
23
23
|
Given A "0.9" safe exists with master password "password" and a key "github" with password "123456"
|
24
24
|
When I run `pws show` interactively
|
25
25
|
And I type "password"
|
26
|
-
Then the output
|
27
|
-
Then the output
|
28
|
-
Then the output
|
26
|
+
Then the output should contain "Master password:"
|
27
|
+
Then the output should contain "NO ACCESS"
|
28
|
+
Then the output should contain "convert"
|
29
29
|
When I run `pws resave --in 0.9 --out 1.0` interactively
|
30
30
|
And I type "password"
|
31
|
-
Then the output
|
32
|
-
Then the output
|
31
|
+
Then the output should contain "Master password:"
|
32
|
+
Then the output should contain "resaved"
|
33
33
|
When I run `pws` interactively
|
34
34
|
And I type "password"
|
35
|
-
Then the output
|
36
|
-
Then the output
|
37
|
-
Then the output
|
35
|
+
Then the output should contain "Master password:"
|
36
|
+
Then the output should contain "Entries"
|
37
|
+
Then the output should contain "github"
|
@@ -60,11 +60,11 @@ Then /^the clipboard should match ([^\/].+)$/ do |expected|
|
|
60
60
|
assert_matching_output(expected, Clipboard.paste)
|
61
61
|
end
|
62
62
|
|
63
|
-
Then /^the output should contain the current date$/ do
|
63
|
+
Then /^the output should contain the current date$/ do
|
64
64
|
assert_partial_output(Time.now.strftime('%y-%m-%d'), all_output)
|
65
65
|
end
|
66
66
|
|
67
|
-
Then /^the output should not contain the current date$/ do
|
67
|
+
Then /^the output should not contain the current date$/ do
|
68
68
|
assert_no_partial_output(Time.now.strftime('%y-%m-%d'), all_output)
|
69
69
|
end
|
70
70
|
|
data/features/support/env.rb
CHANGED
@@ -34,9 +34,13 @@ end
|
|
34
34
|
# Hacks
|
35
35
|
|
36
36
|
Before('@slow-hack') do
|
37
|
-
@aruba_io_wait_seconds =
|
37
|
+
@aruba_io_wait_seconds = 3
|
38
|
+
end
|
39
|
+
|
40
|
+
Before('@very-slow-hack') do
|
41
|
+
@aruba_io_wait_seconds = 7
|
38
42
|
end
|
39
43
|
|
40
44
|
Before('@wait-11s') do
|
41
|
-
@aruba_timeout_seconds =
|
45
|
+
@aruba_timeout_seconds = 15
|
42
46
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
Feature: Update
|
2
|
+
In order to keep my privacy
|
3
|
+
As a user
|
4
|
+
I want to update a password entry and generate the new password
|
5
|
+
|
6
|
+
@wait-11s
|
7
|
+
Scenario: Generate a new password for "github" and get it
|
8
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
9
|
+
When I run `pws update-gen github` interactively
|
10
|
+
And I type "my_master_password"
|
11
|
+
Then the output should contain "Master password:"
|
12
|
+
And the output should contain "The password for github has been updated"
|
13
|
+
And the output should contain "The password for github is now available in your clipboard for 10 seconds"
|
14
|
+
|
15
|
+
Scenario: Try to update-gen the password for "github" (but it does not exist)
|
16
|
+
Given A safe exists with master password "my_master_password"
|
17
|
+
When I run `pws update-gen github` interactively
|
18
|
+
And I type "my_master_password"
|
19
|
+
Then the output should contain "Master password:"
|
20
|
+
And the output should contain "There is no password stored for github, so you cannot update it!"
|
21
|
+
|
22
|
+
Scenario: Try to update-gen the password for "github" (but the master password is wrong)
|
23
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
24
|
+
When I run `pws update-gen github` interactively
|
25
|
+
And I type "my_master_password_wrong"
|
26
|
+
Then the output should contain "Master password:"
|
27
|
+
And the output should contain "NO ACCESS"
|
28
|
+
|
29
|
+
@wait-11s
|
30
|
+
Scenario: Generate a new password for "github" and get it
|
31
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
32
|
+
When I run `pws update-gen github` interactively
|
33
|
+
And I type "my_master_password"
|
34
|
+
Then the output should contain "Master password:"
|
35
|
+
And the output should contain "The password for github has been updated"
|
36
|
+
And the output should contain "The password for github is now available in your clipboard for 10 seconds"
|
37
|
+
|
38
|
+
@slow-hack
|
39
|
+
Scenario: Generate a new password for "github", second parameter gets passed to the get as keep-in-clipboard time
|
40
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
41
|
+
When I run `pws update-gen github 1` interactively
|
42
|
+
And I type "my_master_password"
|
43
|
+
Then the output should contain "Master password:"
|
44
|
+
And the output should contain "The password for github has been updated"
|
45
|
+
And the output should contain "The password for github is now available in your clipboard for 1 second"
|
46
|
+
|
47
|
+
@wait-11s
|
48
|
+
@slow-hack
|
49
|
+
Scenario: Generate a new password for "github", PWS_SECONDS set to 5, gets passed to the get as keep-in-clipboard time
|
50
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
51
|
+
When I set env variable "PWS_SECONDS" to "5"
|
52
|
+
And I run `pws update-gen github` interactively
|
53
|
+
And I type "my_master_password"
|
54
|
+
Then the output should contain "Master password:"
|
55
|
+
And the output should contain "The password for github has been updated"
|
56
|
+
And the output should contain "The password for github is now available in your clipboard for 5 seconds"
|
57
|
+
|
58
|
+
@slow-hack
|
59
|
+
Scenario: Generate a new password for "github", third parameter defines password length
|
60
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
61
|
+
When I run `pws update-gen github 0 10` interactively
|
62
|
+
And I type "my_master_password"
|
63
|
+
Then the output should contain "Master password:"
|
64
|
+
And the output should contain "The password for github has been updated"
|
65
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
66
|
+
And the clipboard should match /^.{10}$/
|
67
|
+
|
68
|
+
@slow-hack
|
69
|
+
Scenario: Generate a new password for "github", default length is 64
|
70
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
71
|
+
When I run `pws update-gen github 0` interactively
|
72
|
+
And I type "my_master_password"
|
73
|
+
Then the output should contain "Master password:"
|
74
|
+
And the output should contain "The password for github has been updated"
|
75
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
76
|
+
And the clipboard should match /^.{64}$/
|
77
|
+
|
78
|
+
@slow-hack
|
79
|
+
Scenario: Generate a new password for "github", default length of PWS_LENGTH
|
80
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
81
|
+
When I set env variable "PWS_LENGTH" to "15"
|
82
|
+
And I run `pws update-gen github 0` interactively
|
83
|
+
And I type "my_master_password"
|
84
|
+
Then the output should contain "Master password:"
|
85
|
+
And the output should contain "The password for github has been updated"
|
86
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
87
|
+
And the clipboard should match /^.{15}$/
|
88
|
+
|
89
|
+
@slow-hack
|
90
|
+
Scenario: Generate a new password for "github", fourth parameter defines a char pool used for generation
|
91
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
92
|
+
When I run `pws update-gen github 0 10 a` interactively
|
93
|
+
And I type "my_master_password"
|
94
|
+
Then the output should contain "Master password:"
|
95
|
+
And the output should contain "The password for github has been updated"
|
96
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
97
|
+
And the clipboard should match /^a{10}$/
|
98
|
+
|
99
|
+
@slow-hack
|
100
|
+
Scenario: Generate a new password for "github", the default char pool is !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
101
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
102
|
+
When I run `pws update-gen github 0` interactively
|
103
|
+
And I type "my_master_password"
|
104
|
+
Then the output should contain "Master password:"
|
105
|
+
And the output should contain "The password for github has been updated"
|
106
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
107
|
+
And the clipboard should match ^[!\"\#$%&'()*+,\-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~]+$
|
108
|
+
|
109
|
+
@slow-hack
|
110
|
+
Scenario: Generate a new password for "github", the default char pool PWS_CHARPOOL
|
111
|
+
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
112
|
+
When I set env variable "PWS_CHARPOOL" to "a"
|
113
|
+
When I run `pws update-gen github 0` interactively
|
114
|
+
And I type "my_master_password"
|
115
|
+
Then the output should contain "Master password:"
|
116
|
+
And the output should contain "The password for github has been updated"
|
117
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
118
|
+
And the clipboard should match ^a{64}$
|
data/features/update.feature
CHANGED
@@ -3,7 +3,6 @@ Feature: Update
|
|
3
3
|
As a user
|
4
4
|
I want to update a password entry
|
5
5
|
|
6
|
-
@slow-hack
|
7
6
|
Scenario: Set a new password for "github"
|
8
7
|
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password"
|
9
8
|
When I run `pws update github` interactively
|
@@ -45,16 +44,16 @@ Feature: Update
|
|
45
44
|
Then the output should contain "Master password:"
|
46
45
|
And the output should contain "NO ACCESS"
|
47
46
|
|
48
|
-
@slow-hack
|
47
|
+
@very-slow-hack
|
49
48
|
Scenario: Set a new password for "github", this also sets the timestamp
|
50
49
|
Given A safe exists with master password "my_master_password" and a key "github" with password "old_password" and timestamp "42424242"
|
51
50
|
When I run `pws ls` interactively
|
52
51
|
And I type "my_master_password"
|
53
|
-
Then the output
|
52
|
+
Then the output should not contain the current date
|
54
53
|
When I run `pws update github github_password` interactively
|
55
54
|
And I type "my_master_password"
|
56
55
|
And I run `pws show` interactively
|
57
56
|
And I type "my_master_password"
|
58
|
-
Then the output
|
57
|
+
Then the output should contain the current date
|
59
58
|
|
60
59
|
|
data/lib/pws/format/1.0.rb
CHANGED
data/lib/pws/runner.rb
CHANGED
@@ -35,7 +35,7 @@ module PWS::Runner
|
|
35
35
|
[action || :show, arguments, options]
|
36
36
|
end
|
37
37
|
|
38
|
-
# makes the Ruby safe
|
38
|
+
# makes the Ruby safe usable from the cli
|
39
39
|
def run(action, arguments, options)
|
40
40
|
case action
|
41
41
|
when :v, :version
|
@@ -45,27 +45,27 @@ module PWS::Runner
|
|
45
45
|
|
46
46
|
#{Paint["Usage", :underline]}
|
47
47
|
|
48
|
-
#{Paint['pws', :bold]} [-namespace] action [arguments]
|
48
|
+
#{Paint['pws', :bold]} [-namespace] action [arguments] [--options]
|
49
49
|
|
50
50
|
#{Paint["Info", :underline]}
|
51
51
|
|
52
52
|
pws allows you to manage passwords in encryted password files (safes). It
|
53
53
|
operates on the file specified in the environment variable PWS or on "~/.pws".
|
54
|
-
|
55
|
-
filename, e.g. `pws -work show`
|
54
|
+
Using a single dash, you can set a namespace that will be appended to the
|
55
|
+
filename, e.g. `pws -work show` will operate on "~/.pws-work".
|
56
56
|
|
57
|
-
#{Paint["Available
|
57
|
+
#{Paint["Available Actions", :underline]}
|
58
58
|
|
59
59
|
#{Paint['ls', :bold]} / list / show / status ( pattern = nil )
|
60
60
|
Lists all available password entries. Optionally takes a regex filter.
|
61
61
|
|
62
|
-
#{Paint['add', :bold]} / set / store / create ( name, password = nil )
|
63
|
-
Stores a new password entry. The second argument can be the password, but
|
64
|
-
it's recommended to not pass it, but enter it interactively.
|
65
|
-
|
66
62
|
#{Paint['get', :bold]} / entry / copy / password / for ( name, seconds = 10 )
|
67
63
|
Copies the password for <name> to the clipboard. The second argument specifies,
|
68
64
|
how long the password is kept in the clipboard (0 = no deletion).
|
65
|
+
|
66
|
+
#{Paint['add', :bold]} / set / store / create ( name, password = nil )
|
67
|
+
Stores a new password entry. The second argument can be the password, but
|
68
|
+
it's recommended to not pass it, but enter it interactively.
|
69
69
|
|
70
70
|
#{Paint['gen', :bold]} / generate ( name, seconds = 10, length = 64, char_pool )
|
71
71
|
Generates a new password for <name> and then copies it to the clipboard, like
|
@@ -73,6 +73,12 @@ module PWS::Runner
|
|
73
73
|
argument sets the password length. The fourth argument allows you to pass a
|
74
74
|
character pool that is used for generating the passwords.
|
75
75
|
|
76
|
+
#{Paint['update', :bold]} / update-add ( name, password = nil )
|
77
|
+
Updates an existing password entry.
|
78
|
+
|
79
|
+
#{Paint['update-gen', :bold]} / update-generate( name, seconds = 10, length = 64, char_pool )
|
80
|
+
Updates an existing password entry using the generate method.
|
81
|
+
|
76
82
|
#{Paint['rm', :bold]} / remove / del / delete ( name )
|
77
83
|
Removes a password entry.
|
78
84
|
|
@@ -82,12 +88,47 @@ module PWS::Runner
|
|
82
88
|
#{Paint['master', :bold]} ( password = nil )
|
83
89
|
Changes the master password.
|
84
90
|
|
91
|
+
#{Paint['resave', :bold]} / convert
|
92
|
+
Just save the safe. Useful for converting the file format.
|
93
|
+
|
85
94
|
#{Paint['v', :bold]} / version
|
86
95
|
Displays version and website.
|
87
96
|
|
88
97
|
#{Paint['help', :bold]} / actions / commands
|
89
98
|
Displays this help.
|
99
|
+
|
100
|
+
#{Paint["Available Options", :underline]}
|
101
|
+
|
102
|
+
#{Paint['--in', :bold]}
|
103
|
+
Specifies the password file input format. Neccessary to convert 0.9 safes.
|
104
|
+
Supported values: 0.9 1.0
|
105
|
+
|
106
|
+
#{Paint['--out', :bold]}
|
107
|
+
Specifies the password file output format. Ignored for non-writing actions,
|
108
|
+
e.g. get. Defaults to the current version.
|
109
|
+
Supported values: 1.0
|
110
|
+
|
111
|
+
#{Paint['--filename', :bold]}
|
112
|
+
Path to the password safe to use. Overrides usual path and any namespaces.
|
90
113
|
|
114
|
+
#{Paint['--iterations', :bold]}
|
115
|
+
Sets the number of sha iterations used to transform your password into the
|
116
|
+
encryption key (pbkdf2). A higher number takes longer to compute, but makes
|
117
|
+
it harder for attacker to bruteforce your password.
|
118
|
+
|
119
|
+
#{Paint['--seconds', :bold]}, #{Paint['--length', :bold]}, #{Paint['--charpool', :bold]}
|
120
|
+
Preset options for specific actions.
|
121
|
+
|
122
|
+
#{Paint["ENV Variables", :underline]}
|
123
|
+
|
124
|
+
You can use environment variables to customize the default settings of pws.
|
125
|
+
Except for PWS (info at top), the following variables can be used:
|
126
|
+
|
127
|
+
PWS_SECONDS
|
128
|
+
PWS_LENGTH
|
129
|
+
PWS_CHARPOOL
|
130
|
+
PWS_ITERATIONS
|
131
|
+
|
91
132
|
HELP
|
92
133
|
else # redirect to safe
|
93
134
|
if PWS.public_instance_methods(false).include?(action)
|
data/lib/pws/version.rb
CHANGED
data/lib/pws.rb
CHANGED
@@ -94,7 +94,7 @@ class PWS
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
alias :'update-add' :update
|
98
98
|
|
99
99
|
# Gets the password entry and copies it to the clipboard. The second parameter is the time in seconds it stays there
|
100
100
|
def get(key, seconds = @options[:seconds])
|
@@ -130,17 +130,23 @@ class PWS
|
|
130
130
|
length = @options[:length],
|
131
131
|
charpool = @options[:charpool]
|
132
132
|
)
|
133
|
-
|
134
|
-
new_pw = (1..length.to_i).map{
|
135
|
-
charpool[SecureRandom.random_number(charpool_size)]
|
136
|
-
}.join
|
137
|
-
|
138
|
-
if add(key, new_pw)
|
139
|
-
get(key, seconds)
|
140
|
-
end
|
133
|
+
get(key, seconds) if add(key, generator(length, charpool))
|
141
134
|
end
|
142
135
|
alias_for :generate, :gen
|
143
136
|
|
137
|
+
# Updates a password entry with a freshly generated random password
|
138
|
+
def update_generate(
|
139
|
+
key,
|
140
|
+
seconds = @options[:seconds],
|
141
|
+
length = @options[:length],
|
142
|
+
charpool = @options[:charpool]
|
143
|
+
)
|
144
|
+
get(key, seconds) if update(key, generator(length, charpool))
|
145
|
+
end
|
146
|
+
alias :'update-generate' :update_generate
|
147
|
+
alias :'update_gen' :update_generate
|
148
|
+
alias :'update-gen' :update_generate
|
149
|
+
|
144
150
|
# Removes a specific password entry
|
145
151
|
def remove(key)
|
146
152
|
if @data.delete key
|
@@ -191,6 +197,7 @@ class PWS
|
|
191
197
|
pa %[The password file has been resaved], :green
|
192
198
|
return true
|
193
199
|
end
|
200
|
+
alias_for :resave, :convert
|
194
201
|
|
195
202
|
# Prevents accidental displaying, e.g. in irb
|
196
203
|
def to_s
|
@@ -202,12 +209,13 @@ class PWS
|
|
202
209
|
|
203
210
|
def collect_options(options = {})
|
204
211
|
@options = options
|
205
|
-
@options[:filename]
|
206
|
-
@options[:seconds]
|
207
|
-
@options[:length]
|
208
|
-
@options[:charpool]
|
209
|
-
@options[:in]
|
210
|
-
@options[:out]
|
212
|
+
@options[:filename] ||= ENV["PWS"] || '~/.pws'
|
213
|
+
@options[:seconds] ||= ENV['PWS_SECONDS'] || 10
|
214
|
+
@options[:length] ||= ENV['PWS_LENGTH'] || 64
|
215
|
+
@options[:charpool] ||= ENV['PWS_CHARPOOL'] || (33..126).map(&:chr).join
|
216
|
+
@options[:in] ||= ENV['PWS_FORMAT'] || VERSION
|
217
|
+
@options[:out] ||= ENV['PWS_FORMAT'] || VERSION
|
218
|
+
@options[:iterations] ||= ENV['PWS_ITERATIONS'] || 75_000
|
211
219
|
end
|
212
220
|
|
213
221
|
# Checks if the file is accessible or create a new one
|
@@ -237,7 +245,7 @@ class PWS
|
|
237
245
|
@data,
|
238
246
|
password: @password,
|
239
247
|
format: @options[:out],
|
240
|
-
iterations: @options[:iterations],
|
248
|
+
iterations: @options[:iterations],
|
241
249
|
)
|
242
250
|
File.open(@filename, 'w'){ |f| f.write(encrypted_data) }
|
243
251
|
end
|
@@ -268,8 +276,16 @@ class PWS
|
|
268
276
|
|
269
277
|
password
|
270
278
|
end
|
279
|
+
|
280
|
+
# Generate a random password, maybe put in its own class sometime
|
281
|
+
def generator(length, charpool)
|
282
|
+
charpool_size = charpool.size
|
283
|
+
(1..length.to_i).map{
|
284
|
+
charpool[SecureRandom.random_number(charpool_size)]
|
285
|
+
}.join
|
286
|
+
end
|
271
287
|
end
|
272
288
|
|
273
|
-
# Command line
|
289
|
+
# Command line behavior in pws/runner.rb
|
274
290
|
|
275
291
|
# J-_-L
|
data/pws.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jan Lelis
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clipboard
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- bin/pws
|
208
208
|
- features/in-out.feature
|
209
209
|
- features/update.feature
|
210
|
+
- features/update-generate.feature
|
210
211
|
- features/show.feature
|
211
212
|
- features/misc.feature
|
212
213
|
- features/get.feature
|
@@ -238,13 +239,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
239
|
requirements:
|
239
240
|
- - ! '>='
|
240
241
|
- !ruby/object:Gem::Version
|
241
|
-
version:
|
242
|
+
version: 1.9.2
|
242
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
244
|
none: false
|
244
245
|
requirements:
|
245
|
-
- - ! '
|
246
|
+
- - ! '>='
|
246
247
|
- !ruby/object:Gem::Version
|
247
|
-
version:
|
248
|
+
version: '0'
|
248
249
|
requirements: []
|
249
250
|
rubyforge_project:
|
250
251
|
rubygems_version: 1.8.23
|