1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-03-20 21:34:35 +00:00

Compare commits

...

172 commits

Author SHA1 Message Date
be526c297f fix: update LICENSE with good copyright 2017-12-07 14:15:51 +01:00
fe7a03ba52 feat: change license GPL2.0 to Apache2.0 2017-11-19 23:03:16 +01:00
a11777cade feat: add keepass 2017-11-19 22:36:54 +01:00
6a2d5da9fb feat: update gem dependencies 2017-11-19 20:11:39 +01:00
30ca80f6db fix shebang 2017-11-19 18:27:48 +01:00
ed09f55ce2 chore: update README 2017-11-19 13:54:17 +01:00
2de66a4eaf fix syntax for all rescue 2017-11-19 13:49:42 +01:00
b0905f18f1 fix: remove output for test_import 2017-10-03 13:09:27 +02:00
8fddbd01be fix: minor change in dockerfile 2017-10-03 13:07:53 +02:00
348db7cfd0 feat: update travis.yml 2017-10-01 20:32:56 +02:00
afd6585acc fix: remove outputs in tests 2017-10-01 20:31:43 +02:00
2abad3695f fix no show wallet in other folder 2017-10-01 20:01:35 +02:00
ef0a908144 feat: add docker for local tests 2017-10-01 18:26:26 +02:00
ce02022ac7 feat: update rubocop to 0.50.0 2017-09-24 12:44:22 +02:00
dd02776baa feat: add import old version of mpw 2017-09-17 23:02:02 +02:00
8b5c7ae581 feat: major change the url storage 2017-09-17 20:58:01 +02:00
cf5b7e0142 fix travis tests 2017-09-17 16:25:05 +02:00
42629c61b3 feat: add test for import 2017-09-04 21:59:24 +02:00
2a647afb10 fix: force system on travis 2017-09-03 10:48:07 +02:00
e2b4557981 feat: add import gorilla file 2017-09-03 10:10:31 +02:00
b2a38ccd4e update version to 4.2.2 2017-08-15 21:13:34 +02:00
8aeb7f5224 feat: alway use absolute path for wallet path 2017-08-12 01:19:52 +02:00
0195771c76 feat: minor improvement add_form interface 2017-08-10 23:41:20 +02:00
65db261c00 feat: minor improve get_item interface 2017-08-10 23:23:06 +02:00
948db2e905 feat: minor improve clipboard interface 2017-08-10 22:45:03 +02:00
d185509113 fix bug in otp generator 2017-07-30 22:30:15 +02:00
11de55ccb7 update Gemfile to fix rubocop version 2017-06-06 23:06:25 +02:00
767343e368 update version 4.2.0 2017-06-06 22:58:48 +02:00
a46e51a6f1 Merge pull request from fbonely/patch-1
Update translations EN
2017-05-23 20:13:52 +02:00
fbonely
6ea40e5420 Update translations EN 2017-05-23 19:49:20 +02:00
a2c2711ddc add gem test-unit for development 2017-05-23 19:33:05 +02:00
b83b27832e feat: no ask password if not necessary 2017-05-22 21:25:56 +02:00
1fcac965e9 fix comments 2017-05-22 20:32:27 +02:00
dcb286ec09 add gem for development 2017-05-22 20:32:06 +02:00
ab459f954d feat: add copy url 2017-05-21 18:00:43 +02:00
5f29f7b6e8 add test cli for copy mode 2017-05-21 17:31:48 +02:00
90486d1e93 update README 2017-05-20 15:42:28 +02:00
6541931b79 enable text editor if threre isn't nothing value who has been set 2017-05-20 15:30:19 +02:00
efff66b12e add test cli for export and import 2017-05-20 14:12:51 +02:00
811c576aae fix password generator 2017-05-20 12:03:57 +02:00
01831c1f2b add test cli for genpwd 2017-05-20 11:31:37 +02:00
3b9ff8c15c add test cli for wallet options 2017-05-20 08:17:39 +02:00
7c36986141 feat: show wallet list by default 2017-05-19 22:28:15 +02:00
8e4fb1c91b fix show config 2017-05-19 22:12:12 +02:00
62318fe077 add test cli for config 2017-05-19 22:12:09 +02:00
Adrien Waksberg
5f7cb6e0cc add search test in cli 2017-05-13 19:49:52 +02:00
Adrien Waksberg
ca2e0d9e47 test: update fixture 2017-05-13 19:49:52 +02:00
f41a9e68d3 fix syntax for all tests 2017-05-13 19:49:52 +02:00
Adrien Waksberg
72c213b7b7 test: use dynamic translation 2017-05-13 01:04:56 +02:00
f150feec10 fix syntax for all tests 2017-05-11 22:46:59 +02:00
977266def8 add new test 2017-05-11 20:35:23 +02:00
Adrien Waksberg
09e451bf3b use ligth_black for port and protocol 2017-05-09 13:56:52 +02:00
192a14ea96 Merge branch 'format-url' of github.com:nishiki/manage-password into format-url 2017-05-08 09:45:20 +02:00
a13fcd147f feat: replace host by url in table 2017-05-08 09:45:01 +02:00
646f096aac update ruby version for test 2017-05-07 19:29:22 +02:00
6a3f2ca007 add first tests for cli 2017-05-07 19:19:45 +02:00
f91531b856 feat: replace host by url in table 2017-05-06 09:09:17 +02:00
a7a165bca9 feat: comment the code with yard 2017-05-03 22:53:56 +02:00
96380d3d93 update version 4.1.1 2017-05-03 20:39:32 +02:00
9ad8eba901 fix: remove unused method 2017-05-03 19:54:21 +02:00
83fe41921c update version 4.1 2017-04-22 10:25:19 +02:00
02996b5904 gemspec: add minimal ruby version 2017-04-20 23:26:40 +02:00
b2b9437431 change copyright year 2017-04-20 23:22:56 +02:00
0fdefdf433 feat: add options to edit or update an item 2017-04-13 22:35:57 +02:00
77bca426bc add information in print config 2017-04-09 11:02:07 +02:00
3f9d7eff33 feat: add print configuration 2017-04-09 10:08:25 +02:00
b65595d0b7 minor refacto 2017-04-09 08:47:07 +02:00
388dc439b6 fix argument in config setup 2017-04-08 17:39:51 +02:00
18ba8967d9 add test for wallet_paths 2017-04-08 17:31:06 +02:00
25baa260e3 feat: add option to set a specific path for a wallet 2017-04-08 17:15:05 +02:00
55c07b90af minor refacto 2017-04-08 10:04:43 +02:00
84afbc4b40 Merge branch 'fix-gpg-password' 2017-04-05 00:09:55 +02:00
3b5bb48e6b add translate for pinmode options 2017-04-05 00:04:15 +02:00
621819203f add option to disable pinmode 2017-04-05 00:03:53 +02:00
45ead1e24e fix syntax for rubocop 0.48.1 2017-04-04 23:52:00 +02:00
d8df357993 not use pinmode if gpg version < 2.1 2017-04-04 23:50:38 +02:00
7ce4ba721b add option to enable pinmode with gpg >= 2.1 2017-04-04 23:45:03 +02:00
d1adfd24c1 fix pinentry mode with gpg 1.4 2017-04-03 22:31:58 +02:00
3543b0cf05 remove unused wallet config 2017-04-02 22:39:31 +02:00
Adrien Waksberg
92cb89ad33 fix gpg password with pinentry 2017-04-02 12:14:27 +02:00
1e688d191c remove unused dependancies 2017-03-30 22:41:12 +02:00
2cb8ad4dbe add rubocop test in travis 2017-03-30 20:18:49 +02:00
Adrien Waksberg
7eb585726f fix syntax on Genfile and mpw.gemspec 2017-03-30 20:08:40 +02:00
Adrien Waksberg
01745cac2d indent class 2017-03-30 20:08:40 +02:00
Adrien Waksberg
0f7510b6e6 multiple fix on syntax 2017-03-30 20:08:40 +02:00
Adrien Waksberg
755df6c342 fix syntax for variable with multiple conditional 2017-03-30 20:08:40 +02:00
Adrien Waksberg
3c787371b3 fix syntax for options in method 2017-03-30 20:08:40 +02:00
Adrien Waksberg
002ec2175b fix rescue 2017-03-30 20:08:40 +02:00
ac2732d116 revert new module form 2017-03-30 20:08:40 +02:00
b1fd013d92 fix indentation for multiline method and hash 2017-03-30 20:08:40 +02:00
782f3d8b5f remove useless line 2017-03-30 20:08:40 +02:00
e04d00d3f4 use new form for module 2017-03-30 20:08:40 +02:00
5db52db1a3 remove do in while line 2017-03-30 20:08:40 +02:00
18ba72e91b fix private style 2017-03-30 20:08:40 +02:00
8cd7b6e583 use iter form 2017-03-30 20:08:40 +02:00
da248460da use %r{} for regex 2017-03-30 20:08:40 +02:00
74d08a7d5b add to_s 2017-03-30 20:08:40 +02:00
c29d2e92d2 replace :? to 2017-03-30 20:08:40 +02:00
b32846ea5e replace while true by Kernel.loop 2017-03-30 20:08:40 +02:00
c1baf3e1d4 remove unused variable 2017-03-30 20:08:40 +02:00
05c30200c3 add rubocop file 2017-03-30 20:08:33 +02:00
043e378eab replace File.exists? by File.exist? 2017-03-29 22:50:52 +02:00
7a831555f4 fix spacing 2017-03-29 22:50:52 +02:00
6a6120ca14 use %w for words array 2017-03-29 22:50:52 +02:00
e99b18519d replace var.length == 0 by var.empty? 2017-03-29 22:50:52 +02:00
db6bb2b0f6 replace "#{var}" by var.to_s 2017-03-29 22:50:52 +02:00
351499aef6 replace MPW::password to MPW.password
replace YAML::load_file to YAML.load_file
replace YAML::load to YAML.safe_load
2017-03-29 22:50:52 +02:00
31aba3b13c replace hash method has_key? by key? 2017-03-29 22:50:52 +02:00
e7fff4bb87 remove return if useless 2017-03-29 22:50:52 +02:00
8ed90c2ddc fix 2017-03-29 22:50:47 +02:00
e71f8e2acf replace if not by unless 2017-03-29 22:49:46 +02:00
178d0e6d1d replace if not by unless 2017-03-29 22:35:40 +02:00
7c72b2d90f change tab by 2 spaces
change tab by 2 spaces
2017-03-27 22:49:46 +02:00
871b1dcbed remove all sync 2017-03-27 21:55:25 +02:00
2e6d111b69 begind version 4.1.0 2017-03-27 21:27:50 +02:00
5a1e0f6aa8 release version 4.0.0 2017-03-09 21:06:05 +01:00
ffedd5b88b fix error when delete an item with sync 2017-03-08 21:23:15 +01:00
Adrien Waksberg
58215d4e01 ignore *.gem 2017-03-03 22:57:03 +01:00
Adrien Waksberg
44c1c2b476 update readme 2017-03-03 22:42:30 +01:00
Adrien Waksberg
de4beba3db export items with id 2017-03-03 22:00:15 +01:00
Adrien Waksberg
8fb83bd391 fix message in export function 2017-03-03 21:57:21 +01:00
55e46e1afa convert changelog to markdown 2017-03-02 23:47:24 +01:00
ba745ccc0c update README 2017-03-02 23:43:19 +01:00
6b8dce2eff add random password for update 2017-02-26 23:12:49 +01:00
e4fb780016 fix minor bug when config password is empty 2017-02-26 23:11:07 +01:00
Adrien Waksberg
52577425a6 fix each_key 2017-02-26 22:11:14 +01:00
Adrien Waksberg
da81f34e07 fix add_key 2017-02-26 22:07:18 +01:00
Adrien Waksberg
89abfac512 Merge branch 'fix-encrypt-share' of github.com:nishiki/manage-password into fix-encrypt-share 2017-02-26 21:54:41 +01:00
Adrien Waksberg
e03614fb72 fix bug encrypt with share key 2017-02-26 21:54:28 +01:00
Adrien Waksberg
cced11f6c4 fix test 2017-02-26 21:45:42 +01:00
Adrien Waksberg
21c3732ad3 fix test 2017-02-26 21:39:33 +01:00
Adrien Waksberg
5d267a4865 config: rename key to gpg_key 2017-02-26 21:34:54 +01:00
Adrien Waksberg
d6f7c78eb1 fix test 2017-02-26 21:26:23 +01:00
Adrien Waksberg
e486be5ba8 fix bug 2017-02-26 21:22:25 +01:00
Adrien Waksberg
980adacc2c fix missing change 2017-02-26 21:17:35 +01:00
Adrien Waksberg
a737ee94d1 add unit test 2017-02-26 09:45:19 +01:00
Adrien Waksberg
cedfe9cef7 fix bug encrypt with share key 2017-02-26 09:35:46 +01:00
Adrien Waksberg
000bc3aaa5 add config option for password parameters 2017-02-25 18:43:30 +01:00
31574751ff fix bug after add default wallet 2017-02-22 21:59:49 +01:00
c841123ac0 feat: add option to set default wallet 2017-02-22 21:51:06 +01:00
50d88fc970 fix translation test 2017-02-22 19:23:55 +01:00
c63d91facc fix bug when exit with help message 2017-02-21 22:38:55 +01:00
a117e8a618 nothing to do if no values 2017-02-21 21:08:14 +01:00
4b6de3575a fix interface for wallets list 2017-02-21 21:05:28 +01:00
35a4cd47e4 change readme syntax 2017-02-21 20:32:26 +01:00
afdbb05bc5 fix nothing item message in copy mode 2017-02-20 22:26:57 +01:00
a3dd83e63c fix update otp key 2017-02-17 00:04:25 +01:00
795343b669 upgrade changelog for version 4.0.0-beta1 2017-02-16 23:39:50 +01:00
dbffea6b6e upgrade version 4.0.0-beta1 2017-02-16 23:32:24 +01:00
e17219c772 minor fix in list_keys interface 2017-02-16 23:25:54 +01:00
362253c63b cli: add list gpg keys in wallet 2017-02-16 20:47:39 +01:00
ec3abbe88a fix bug share key 2017-02-14 21:30:26 +01:00
f251b2ebe0 test with ruby 2.4 2017-02-11 19:08:26 +01:00
501ae5ab2e remove unused test files 2017-02-11 15:11:08 +01:00
adf34a006c config: generate gpg key with rsa 2017-02-11 15:09:48 +01:00
Adrien Waksberg
318d0d357a Merge pull request from nishiki/share_key
Share key
2017-02-11 15:08:35 +01:00
e6238341cd fix test 2017-02-11 13:47:22 +01:00
4bd538fa7c generate a gpg key for the test 2017-02-11 13:43:29 +01:00
b287b719fe add test to check add and delete gpg key 2017-02-11 11:24:49 +01:00
a1a21f9617 mpw: add function list_keys 2017-02-11 11:24:12 +01:00
06c876861b fix english translation 2017-01-30 22:26:18 +01:00
d6d7074341 fix error message when there is a bad option 2017-01-30 22:20:22 +01:00
8c5be6b795 wallet: add remove gpg key option 2017-01-30 22:10:56 +01:00
50aa7713f4 fix error message when host is empty 2017-01-30 20:29:42 +01:00
cb409b1545 fix bug when port is > 4 number 2017-01-24 22:58:03 +01:00
bf356f4d6f add an option for add a share gpg key 2016-12-12 23:13:32 +01:00
3575cd9bd7 feat change add key 2016-12-12 23:09:52 +01:00
Adrien Waksberg
0458013def Merge pull request from nishiki/gpg_name
fix gpg key name
2016-12-12 22:19:07 +01:00
36e0f83175 fix gpg key name 2016-12-12 22:15:09 +01:00
Adrien Waksberg
7b24e10e70 Merge pull request from nishiki/test_translate
Test translate
2016-11-12 23:15:43 +01:00
d8339b53de fix missing translate 2016-11-12 17:16:57 +01:00
04e8a2cd0b add test translate 2016-11-12 16:54:41 +01:00
54 changed files with 3456 additions and 2677 deletions

32
.docker-test Normal file
View file

@ -0,0 +1,32 @@
#!/bin/bash
ruby_version=${1:-2.4.2}
if ! rvm use ruby-${ruby_version} &>/dev/null ; then
echo "The ruby version '${ruby_version}' doesn't exist!"
echo "Available versions are:"
rvm list rubies strings | cut -d '-' -f2
exit 2
fi
echo '# ---------------------------------'
echo "# Use ruby version: ${ruby_version}"
echo '# ---------------------------------'
cp -r /mpw ~/mpw
cd ~/mpw
gem install bundler --no-ri --no-rdoc
bundle install
gem build mpw.gemspec
gem install mpw-$(cat VERSION).gem
cp -a /dev/urandom /dev/random
rubocop
ruby ./test/init.rb
ruby ./test/test_config.rb
ruby ./test/test_item.rb
ruby ./test/test_mpw.rb
ruby ./test/test_translate.rb
ruby ./test/init.rb
ruby ./test/test_cli.rb
ruby ./test/test_import.rb

3
.gitignore vendored
View file

@ -1 +1,4 @@
Gemfile.lock Gemfile.lock
*.gem
.yardoc
doc

38
.rubocop.yml Normal file
View file

@ -0,0 +1,38 @@
AllCops:
Exclude:
- db/**/*
- config/**/*
- Vagrantfile
TargetRubyVersion: 2.3
Naming/AccessorMethodName:
Enabled: false
Lint/RescueWithoutErrorClass:
Enabled: false
Metrics/LineLength:
Max: 120
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/AbcSize:
Enabled: false
Style/NumericLiteralPrefix:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/CommandLiteral:
Enabled: true
EnforcedStyle: percent_x
Style/Documentation:
Enabled: false

View file

@ -1,13 +1,23 @@
language: ruby language: ruby
dist: precise
rvm: rvm:
- 2.3.1 - 2.4.2
- 2.2.5 - 2.3.5
- 2.2.8
- 2.1.10 - 2.1.10
install: install:
- sudo cp -a /dev/urandom /dev/random
- sudo apt-get purge -y gnupg-agent gnupg2
- bundle install - bundle install
- gem install 'test-unit'
- echo 9999 > VERSION
- gem build mpw.gemspec - gem build mpw.gemspec
- gem install mpw-9999.gem - gem install mpw-$(cat VERSION).gem
script: script:
- ruby ./test/tests.rb - rubocop
- ruby ./test/init.rb
- ruby ./test/test_config.rb
- ruby ./test/test_item.rb
- ruby ./test/test_mpw.rb
- ruby ./test/test_translate.rb
- ruby ./test/init.rb
- ruby ./test/test_cli.rb
- ruby ./test/test_import.rb

View file

@ -1,43 +0,0 @@
= CHANGELOG =
== v4.0.0 (beta) ==
* new interface with a table
* new command line interface
* use text editor for add or update an item
* several bugs fix
== v3.2.1 ==
* fix bug when add a new item
== v3.2.0 ==
* add support OTP
* fix bug in synchronize
* improve interface
== v3.1.0 ==
* add clipboard
* can change gpg version
* minor change in interface
* several bugs fix
== v3.0.0 ==
* new storage format
* new share system
* remove MPW server
== v2.0.0 ==
* change format csv to yaml
* easy install with gem
* add sync with ftp and ssh
* many improvement
== v1.1.0 ==
* Add sync with MPW Server
* Add MPW Server
* Fix minors bugs

98
CHANGELOG.md Normal file
View file

@ -0,0 +1,98 @@
# CHANGELOG
## v4.2.2 (2017-08-15)
* minor improvements in the interface
## v4.2.1 (2017-07-30)
* fix bug in otp generator
## v4.2.0 (2017-06-06)
* feat: improve the interface
* feat: add copy url
* feat: add unit tests for cli
* feat: comment the code with yarn syntax
* fix several bugs
* fix translations
## v4.1.1 (2017-05-03)
* fix bug in init
## v4.1.0 (2017-04-22)
* feat: add options to update or add an item in command line
* feat: print config
* feat: add a specific path for a wallet
* feat: add rubocop to fix syntax
* fix: pinentry mode with gpg >= 2.1
* remove SSH and FTP synchronization
## v4.0.0 (2017-03-09)
* feature: set default wallet
* add option for generate a random password when you update an item
* fix encryption when you share an existing wallet
* several bugs fix
## v4.0.0-beta1 (2017-02-16)
* add manage share key with new interface
## v4.0.0-beta (2016-11-11)
* new interface with a table
* new command line interface
* use text editor for add or update an item
* fix generate gpg key with RSA
* several bugs fix
* add unit tests
## v3.2.1 (2016-08-06)
* fix bug when add a new item
## v3.2.0 (2016-08-03)
* add support OTP
* fix bug in synchronize
* improve interface
## v3.1.0 (2016-07-09)
* add clipboard
* can change gpg version
* minor change in interface
* several bugs fix
## v3.0.0 (2016-07-05)
* new storage format
* new share system
* remove MPW server
## v2.0.3 (2015-09-27)
* add no-sync option
## v2.0.1 (2015-06-23)
* fix mpw-ssh
## v2.0.0 (2015-06-22)
* change format csv to yaml
* easy install with gem
* add sync with ftp and ssh
* many improvement
## v1.1.0 (2014-01-28)
* Add sync with MPW Server
* Add MPW Server
* Fix minors bugs
## v1.0.0 (2014-01-15)
* first release

16
Dockerfile Normal file
View file

@ -0,0 +1,16 @@
FROM debian:stretch
MAINTAINER Adrien Waksberg "mpw@yae.im"
RUN apt update
RUN apt dist-upgrade -y
RUN apt install -y procps gnupg1 curl git
RUN ln -snvf /usr/bin/gpg1 /usr/bin/gpg
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN curl -sSL https://get.rvm.io | bash -s stable
RUN echo 'source "/usr/local/rvm/scripts/rvm"' >> /etc/bash.bashrc
RUN /bin/bash -l -c "rvm install 2.4.2"
RUN /bin/bash -l -c "rvm install 2.3.5"
RUN /bin/bash -l -c "rvm install 2.2.8"
RUN /bin/bash -l -c "rvm install 2.1.10"

22
Gemfile
View file

@ -1,10 +1,14 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem "i18n", "~> 0.7", ">= 0.7.0" gem 'clipboard', '~> 1.1', '>= 1.1.1'
gem "gpgme", "~> 2.0", ">= 2.0.12" gem 'colorize', '~> 0.8', '>= 0.8.1'
gem "highline", "~> 1.7", ">= 1.7.8" gem 'gpgme', '~> 2.0', '>= 2.0.14'
gem "locale", "~> 2.1", ">= 2.1.2" gem 'highline', '~> 1.7', '>= 1.7.8'
gem "colorize", "~> 0.8", ">= 0.8.1" gem 'i18n', '~> 0.9', '>= 0.9.1'
gem "net-ssh", "~> 3.2", ">= 3.2.0" gem 'locale', '~> 2.1', '>= 2.1.2'
gem "net-sftp", "~> 2.1", ">= 2.1.2" gem 'rotp', '~> 3.3', '>= 3.3.0'
gem "clipboard", "~> 1.1", ">= 1.1.1"
gem "rotp", "~> 3.1", ">= 3.1.0" group :development do
gem 'rubocop', '0.50.0'
gem 'test-unit'
gem 'yard'
end

476
LICENSE
View file

@ -1,339 +1,201 @@
GNU GENERAL PUBLIC LICENSE Apache License
Version 2, June 1991 Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (C) 1989, 1991 Free Software Foundation, Inc., TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble 1. Definitions.
The licenses for most software are designed to take away your "License" shall mean the terms and conditions for use, reproduction,
freedom to share and change it. By contrast, the GNU General Public and distribution as defined by Sections 1 through 9 of this document.
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not "Licensor" shall mean the copyright owner or entity authorized by
price. Our General Public Licenses are designed to make sure that you the copyright owner that is granting the License.
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid "Legal Entity" shall mean the union of the acting entity and all
anyone to deny you these rights or to ask you to surrender the rights. other entities that control, are controlled by, or are under common
These restrictions translate to certain responsibilities for you if you control with that entity. For the purposes of this definition,
distribute copies of the software, or if you modify it. "control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
For example, if you distribute copies of such a program, whether "You" (or "Your") shall mean an individual or Legal Entity
gratis or for a fee, you must give the recipients all the rights that exercising permissions granted by this License.
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and "Source" form shall mean the preferred form for making modifications,
(2) offer you this license which gives you legal permission to copy, including but not limited to software source code, documentation
distribute and/or modify the software. source, and configuration files.
Also, for each author's protection and ours, we want to make certain "Object" form shall mean any form resulting from mechanical
that everyone understands that there is no warranty for this free transformation or translation of a Source form, including but
software. If the software is modified by someone else and passed on, we not limited to compiled object code, generated documentation,
want its recipients to know that what they have is not the original, so and conversions to other media types.
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software "Work" shall mean the work of authorship, whether in Source or
patents. We wish to avoid the danger that redistributors of a free Object form, made available under the License, as indicated by a
program will individually obtain patent licenses, in effect making the copyright notice that is included in or attached to the work
program proprietary. To prevent this, we have made it clear that any (an example is provided in the Appendix below).
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and "Derivative Works" shall mean any work, whether in Source or Object
modification follow. form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
GNU GENERAL PUBLIC LICENSE "Contribution" shall mean any work of authorship, including
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
0. This License applies to any program or other work which contains "Contributor" shall mean Licensor and any individual or Legal Entity
a notice placed by the copyright holder saying it may be distributed on behalf of whom a Contribution has been received by Licensor and
under the terms of this General Public License. The "Program", below, subsequently incorporated within the Work.
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not 2. Grant of Copyright License. Subject to the terms and conditions of
covered by this License; they are outside its scope. The act of this License, each Contributor hereby grants to You a perpetual,
running the Program is not restricted, and the output from the Program worldwide, non-exclusive, no-charge, royalty-free, irrevocable
is covered only if its contents constitute a work based on the copyright license to reproduce, prepare Derivative Works of,
Program (independent of having been made by running the Program). publicly display, publicly perform, sublicense, and distribute the
Whether that is true depends on what the Program does. Work and such Derivative Works in Source or Object form.
1. You may copy and distribute verbatim copies of the Program's 3. Grant of Patent License. Subject to the terms and conditions of
source code as you receive it, in any medium, provided that you this License, each Contributor hereby grants to You a perpetual,
conspicuously and appropriately publish on each copy an appropriate worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright notice and disclaimer of warranty; keep intact all the (except as stated in this section) patent license to make, have made,
notices that refer to this License and to the absence of any warranty; use, offer to sell, sell, import, and otherwise transfer the Work,
and give any other recipients of the Program a copy of this License where such license applies only to those patent claims licensable
along with the Program. by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
You may charge a fee for the physical act of transferring a copy, and 4. Redistribution. You may reproduce and distribute copies of the
you may at your option offer warranty protection in exchange for a fee. Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
2. You may modify your copy or copies of the Program or any portion (a) You must give any other recipients of the Work or
of it, thus forming a work based on the Program, and copy and Derivative Works a copy of this License; and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices (b) You must cause any modified files to carry prominent notices
stating that you changed the files and the date of any change. stating that You changed the files; and
b) You must cause any work that you distribute or publish, that in (c) You must retain, in the Source form of any Derivative Works
whole or in part contains or is derived from the Program or any that You distribute, all copyright, patent, trademark, and
part thereof, to be licensed as a whole at no charge to all third attribution notices from the Source form of the Work,
parties under the terms of this License. excluding those notices that do not pertain to any part of
the Derivative Works; and
c) If the modified program normally reads commands interactively (d) If the Work includes a "NOTICE" text file as part of its
when run, you must cause it, when started running for such distribution, then any Derivative Works that You distribute must
interactive use in the most ordinary way, to print or display an include a readable copy of the attribution notices contained
announcement including an appropriate copyright notice and a within such NOTICE file, excluding those notices that do not
notice that there is no warranty (or else, saying that you provide pertain to any part of the Derivative Works, in at least one
a warranty) and that users may redistribute the program under of the following places: within a NOTICE text file distributed
these conditions, and telling the user how to view a copy of this as part of the Derivative Works; within the Source form or
License. (Exception: if the Program itself is interactive but documentation, if provided along with the Derivative Works; or,
does not normally print such an announcement, your work based on within a display generated by the Derivative Works, if and
the Program is not required to print an announcement.) wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
These requirements apply to the modified work as a whole. If You may add Your own copyright statement to Your modifications and
identifiable sections of that work are not derived from the Program, may provide additional or different license terms and conditions
and can be reasonably considered independent and separate works in for use, reproduction, or distribution of Your modifications, or
themselves, then this License, and its terms, do not apply to those for any such Derivative Works as a whole, provided Your use,
sections when you distribute them as separate works. But when you reproduction, and distribution of the Work otherwise complies with
distribute the same sections as part of a whole which is a work based the conditions stated in this License.
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest 5. Submission of Contributions. Unless You explicitly state otherwise,
your rights to work written entirely by you; rather, the intent is to any Contribution intentionally submitted for inclusion in the Work
exercise the right to control the distribution of derivative or by You to the Licensor shall be under the terms and conditions of
collective works based on the Program. this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
In addition, mere aggregation of another work not based on the Program 6. Trademarks. This License does not grant permission to use the trade
with the Program (or with a work based on the Program) on a volume of names, trademarks, service marks, or product names of the Licensor,
a storage or distribution medium does not bring the other work under except as required for reasonable and customary use in describing the
the scope of this License. origin of the Work and reproducing the content of the NOTICE file.
3. You may copy and distribute the Program (or a work based on it, 7. Disclaimer of Warranty. Unless required by applicable law or
under Section 2) in object code or executable form under the terms of agreed to in writing, Licensor provides the Work (and each
Sections 1 and 2 above provided that you also do one of the following: Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
a) Accompany it with the complete corresponding machine-readable 8. Limitation of Liability. In no event and under no legal theory,
source code, which must be distributed under the terms of Sections whether in tort (including negligence), contract, or otherwise,
1 and 2 above on a medium customarily used for software interchange; or, unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
b) Accompany it with a written offer, valid for at least three 9. Accepting Warranty or Additional Liability. While redistributing
years, to give any third party, for a charge no more than your the Work or Derivative Works thereof, You may choose to offer,
cost of physically performing source distribution, a complete and charge a fee for, acceptance of support, warranty, indemnity,
machine-readable copy of the corresponding source code, to be or other liability obligations and/or rights consistent with this
distributed under the terms of Sections 1 and 2 above on a medium License. However, in accepting such obligations, You may act only
customarily used for software interchange; or, on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
c) Accompany it with the information you received as to the offer END OF TERMS AND CONDITIONS
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for APPENDIX: How to apply the Apache License to your work.
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering To apply the Apache License to your work, attach the following
access to copy from a designated place, then offering equivalent boilerplate notice, with the fields enclosed by brackets "{}"
access to copy the source code from the same place counts as replaced with your own identifying information. (Don't include
distribution of the source code, even though third parties are not the brackets!) The text should be enclosed in the appropriate
compelled to copy the source along with the object code. comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
4. You may not copy, modify, sublicense, or distribute the Program Copyright 2017 Adrien Waksberg
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not Licensed under the Apache License, Version 2.0 (the "License");
signed it. However, nothing else grants you permission to modify or you may not use this file except in compliance with the License.
distribute the Program or its derivative works. These actions are You may obtain a copy of the License at
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the http://www.apache.org/licenses/LICENSE-2.0
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent Unless required by applicable law or agreed to in writing, software
infringement or for any other reason (not limited to patent issues), distributed under the License is distributed on an "AS IS" BASIS,
conditions are imposed on you (whether by court order, agreement or WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
otherwise) that contradict the conditions of this License, they do not See the License for the specific language governing permissions and
excuse you from the conditions of this License. If you cannot limitations under the License.
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

195
README.md Normal file
View file

@ -0,0 +1,195 @@
# MPW: Manage your passwords!
[![Version](https://img.shields.io/badge/latest_version-4.2.2-green.svg)](https://github.com/nishiki/manage-password/releases)
[![Build Status](https://travis-ci.org/nishiki/manage-password.svg?branch=master)](https://travis-ci.org/nishiki/manage-password)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/nishiki/manage-password/blob/master/LICENSE)
mpw is a little software which stores your passwords in [GnuPG](http://www.gnupg.org/) encrypted files.
## Features
* generate random password
* generate OTP code
* copy your login, password or otp in clipboard
* manage many wallets
* share a wallet with others GPG keys
## Install
On debian or ubuntu:
```
apt install ruby ruby-dev xclip
gem install mpw
```
## How to use
### First steps
Initialize your first wallet:
```
mpw config --init user@host.com
```
Add your first item:
```
mpw add --host assurance.com --port 443 --user user_2132 --protocol https --random
mpw add --host fric.com --user 230403 --otp-code 23434113 --protocol https --comment 'I love my bank' --random
```
And list your items:
```
mpw list
```
or search an item with
```
mpw list --pattern love
mpw list --group bank
```
Output:
```
Assurance
==========================================================================
ID | Host | User | OTP | Comment
==========================================================================
1 | https://assurance.com:443 | user_2132 | |
Bank
==========================================================================
ID | Host | User | OTP | Comment
==========================================================================
3 | https://fric.com | 230403 | X | I love my bank
```
Copy a password, login or OTP code:
```
mpw copy -p assurance.com
```
Update an item:
```
mpw update -p assurance.com
```
Delete an item:
```
mpw delete -p assurance.com
```
### Manage wallets
List all available wallets:
```
mpw wallet
```
List all GPG keys in wallet:
```
mpw wallet --list-keys [--wallet NAME]
```
Share with an other GPG key:
```
mpw wallet --add-gpg-key test42@localhost.com
or
mpw wallet --add-gpg-key /path/to/file
```
Remove a GPG key:
```
mpw wallet --delete-gpg-key test42@localhost.com
```
### Export and import data
You can export your data in yaml file with your passwords in clear text:
```
mpw export --file export.yml
```
Import data from an yaml file:
```
mpw import --file import.yml
```
Example yaml file for mpw:
```
---
1:
host: fric.com
user: 230403
group: Bank
password: 5XdiTQOubRDw9B0aJoMlcEyL
protocol: https
port:
otp_key: 330223432
comment: I love my bank
2:
host: assurance.com
user: user_2132
group: Assurance
password: DMyK6B3v4bWO52VzU7aTHIem
protocol: https
port: 443
otp_key:
comment:
```
### Config
Print the current config
```
mpw config
```
Output:
```
Configuration
==============================================
lang | fr
gpg_key | mpw@yae.im
default_wallet |
config_dir | /home/mpw/.config/mpw
pinmode | true
gpg_exe |
path_wallet_test | /tmp/test.mpw
password_numeric | true
password_alpha | true
password_special | false
password_length | 16
```
## Development
Don't run the tests on your local machine, you risk to lost your datas.
### Test on local machine with docker
* install [docker](https://docs.docker.com/engine/installation/)
* run the tests
```
docker run -v $(pwd):/mpw:ro -it nishiki/ruby:stretch /bin/bash -l /mpw/.docker-test
```
## License
```
* Author:: Adrien Waksberg <mpw@yae.im>
Copyright (c) 2013-2017 Adrien Waksberg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View file

@ -1,54 +0,0 @@
MPW: Manage your passwords!
*******************************************************
|Version| |Build Status| |License|
mpw is a little software which stores your passwords in `GnuPG <http://www.gnupg.org/>`_ encrypted files.
Features
========
* generate OTP code
* synchronize your passwords with SSH or FTP.
* copy your login, password or otp in clipboard
Install
=======
On debian or ubuntu::
apt install ruby ruby-dev xclip
gem install mpw
How to use
==========
A simple mpw usage::
mpw config --init user@host.com
mpw add
mpw copy
mpw add
mpw list
Output::
Bank
==============================================================================
ID | Host | User | Protocol | Port | OTP | Comment
==============================================================================
1 | bank.com | 1234456 | https | | X |
Linux
==============================================================================
ID | Host | User | Protocol | Port | OTP | Comment
==============================================================================
2 | linuxfr.org | example | https | | | Da Linux French Site
.. |Version| image:: https://img.shields.io/badge/latest_version-4.0.0--beta-yellow.svg
:target: https://github.com/nishiki/manage-password/releases
.. |License| image:: https://img.shields.io/badge/license-GPL--2.0-blue.svg
:target: https://github.com/nishiki/manage-password/blob/master/LICENSE
.. |Build Status| image:: https://travis-ci.org/nishiki/manage-password.svg?branch=master
:target: https://travis-ci.org/nishiki/manage-password

View file

@ -1 +1 @@
4.0.0-beta 4.2.2

76
bin/mpw
View file

@ -1,26 +1,30 @@
#!/usr/bin/ruby #!/usr/bin/env ruby
# MPW is a software to crypt and manage your passwords #
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # Copyright:: 2013, Adrien Waksberg
# #
# This program is free software; you can redistribute it and/or # Licensed to the Apache Software Foundation (ASF) under one
# modify it under the terms of the GNU General Public License # or more contributor license agreements. See the NOTICE file
# as published by the Free Software Foundation; either version 2 # distributed with this work for additional information
# of the License, or (at your option) any later version. # regarding copyright ownership. The ASF licenses this file
# # to you under the Apache License, Version 2.0 (the
# This program is distributed in the hope that it will be useful, # "License"); you may not use this file except in compliance
# but WITHOUT ANY WARRANTY; without even the implied warranty of # with the License. You may obtain a copy of the License at
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. # http://www.apache.org/licenses/LICENSE-2.0
# #
# You should have received a copy of the GNU General Public License # Unless required by applicable law or agreed to in writing,
# along with this program; if not, write to the Free Software # software distributed under the License is distributed on an
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
$: << File.expand_path('../../lib', __FILE__) $LOAD_PATH << File.expand_path('../../lib', __FILE__)
require 'locale' require 'locale'
require 'set' require 'set'
require 'i18n' require 'i18n'
require 'colorize'
# --------------------------------------------------------- # # --------------------------------------------------------- #
# Set local # Set local
@ -29,7 +33,7 @@ require 'i18n'
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1] lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined?(I18n.enforce_available_locales) if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true I18n.enforce_available_locales = true
end end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
@ -44,21 +48,25 @@ I18n.locale = lang.to_sym
bin_dir = File.dirname(__FILE__) bin_dir = File.dirname(__FILE__)
command = "#{bin_dir}/mpw-#{ARGV[0]}" command = "#{bin_dir}/mpw-#{ARGV[0]}"
if Dir.glob("#{bin_dir}/mpw-*").include?("#{command}") if Dir.glob("#{bin_dir}/mpw-*").include?(command.to_s)
Kernel.load(command) begin
Kernel.load(command)
rescue OptionParser::ParseError => e
puts "#{I18n.t('display.error')}: #{e}".red
end
else else
puts "#{I18n.t('option.usage')}: mpw COMMAND [options]\n\n" puts "#{I18n.t('option.usage')}: mpw COMMAND [options]\n\n"
puts 'Commands:' puts 'Commands:'
puts " add #{I18n.t('command.add')}" puts " add #{I18n.t('command.add')}"
puts " config #{I18n.t('command.config')}" puts " config #{I18n.t('command.config')}"
puts " copy #{I18n.t('command.copy')}" puts " copy #{I18n.t('command.copy')}"
puts " delete #{I18n.t('command.delete')}" puts " delete #{I18n.t('command.delete')}"
puts " export #{I18n.t('command.export')}" puts " export #{I18n.t('command.export')}"
puts " genpwd #{I18n.t('command.genpwd')}" puts " genpwd #{I18n.t('command.genpwd')}"
puts " import #{I18n.t('command.import')}" puts " import #{I18n.t('command.import')}"
puts " list #{I18n.t('command.list')}" puts " list #{I18n.t('command.list')}"
puts " update #{I18n.t('command.update')}" puts " update #{I18n.t('command.update')}"
puts " wallet #{I18n.t('command.wallet')}" puts " wallet #{I18n.t('command.wallet')}"
exit 3 exit 3
end end

View file

@ -1,20 +1,22 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,38 +26,59 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} values = {}
options[:sync] = true options = {}
options[:text_editor] = true
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw add [options]" opts.banner = "#{I18n.t('option.usage')}: mpw add [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-C', '--comment COMMENT', I18n.t('option.comment')) do |comment|
puts opts values[:comment] = comment
exit 0 end
end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-G', '--group NAME', I18n.t('option.new_group')) do |group|
options[:sync] = false values[:group] = group
end end
opts.on('-r', '--random', I18n.t('option.random_password')) do opts.on('-h', '--help', I18n.t('option.help')) do
options[:password] = true puts opts
end exit 0
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
options[:wallet] = wallet values[:otp_key] = otp
end end
opts.on('-r', '--random', I18n.t('option.random_password')) do
options[:password] = true
end
opts.on('-t', '--text-editor', I18n.t('option.text_editor')) do
options[:text_editor] = true
end
opts.on('-u', '--url URL', I18n.t('option.url')) do |url|
values[:url] = url
end
opts.on('-U', '--user USER', I18n.t('option.user')) do |user|
values[:user] = user
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])
cli.decrypt cli.decrypt
cli.add(options[:password]) cli.add(options[:password], options[:text_editor], values)

View file

@ -1,20 +1,22 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -28,48 +30,92 @@ options = {}
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw config [options]" opts.banner = "#{I18n.t('option.usage')}: mpw config [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-g', '--gpg-exe PATH', I18n.t('option.gpg_exe')) do |gpg_exe| opts.on('-d', '--default-wallet NAME', I18n.t('option.default_wallet')) do |default_wallet|
values[:gpg_exe] = gpg_exe values[:default_wallet] = default_wallet
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-g', '--gpg-exe PATH', I18n.t('option.gpg_exe')) do |gpg_exe|
puts opts values[:gpg_exe] = gpg_exe
exit 0 end
end
opts.on('-i', '--init GPG_KEY', I18n.t('option.init')) do |gpg_key| opts.on('-h', '--help', I18n.t('option.help')) do
options[:init] = true puts opts
values[:gpg_key] = gpg_key exit 0
end end
opts.on('-k', '--key GPG_KEY', I18n.t('option.gpg_key')) do |gpg_key| opts.on('-i', '--init GPG_KEY', I18n.t('option.init')) do |gpg_key|
values[:gpg_key] = gpg_key options[:init] = true
end values[:gpg_key] = gpg_key
end
opts.on('-l', '--lang LANG', I18n.t('option.lang')) do |lang| opts.on('-k', '--key GPG_KEY', I18n.t('option.gpg_key')) do |gpg_key|
values[:lang] = lang values[:gpg_key] = gpg_key
end end
opts.on('-w', '--wallet-dir PATH', I18n.t('option.wallet_dir')) do |wallet_dir| opts.on('-L', '--lang LANG', I18n.t('option.lang')) do |lang|
values[:wallet_dir] = wallet_dir values[:lang] = lang
end end
opts.on('-P', '--enable-pinmode', I18n.t('option.pinmode')) do
values[:pinmode] = true
end
opts.on('-p', '--disable-pinmode', I18n.t('option.disable_pinmode')) do
values[:pinmode] = false
end
opts.on('-w', '--wallet-dir PATH', I18n.t('option.wallet_dir')) do |wallet_dir|
values[:wallet_dir] = wallet_dir
end
opts.on('-l', '--length NUMBER', I18n.t('option.length')) do |length|
values[:pwd_length] = length.to_i
end
opts.on('-n', '--numeric', I18n.t('option.numeric')) do
values[:pwd_numeric] = true
end
opts.on('-N', '--disable-numeric', I18n.t('option.disable_numeric')) do
values[:pwd_numeric] = false
end
opts.on('-s', '--special-chars', I18n.t('option.special_chars')) do
values[:pwd_special] = true
end
opts.on('-S', '--disable-special-chars', I18n.t('option.special_chars')) do
values[:pwd_special] = false
end
opts.on('-a', '--alpha', I18n.t('option.alpha')) do
values[:pwd_alpha] = true
end
opts.on('-A', '--disable-alpha', I18n.t('option.disable_alpha')) do
values[:pwd_alpha] = false
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, nil) cli = MPW::Cli.new(config)
if not options[:init].nil? if options.key?(:init)
cli.setup(values) cli.setup(values)
cli.load_config cli.load_config
cli.get_wallet cli.get_wallet
cli.setup_gpg_key(options[:init]) cli.setup_gpg_key(values[:gpg_key])
cli.setup_wallet_config
else else
cli.set_config(values) cli.load_config
if values.empty?
cli.list_config
else
cli.set_config(values)
end
end end

View file

@ -1,20 +1,22 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -25,45 +27,40 @@ require 'mpw/cli'
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true
options[:clipboard] = true options[:clipboard] = true
values = {} values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw copy [options]" opts.banner = "#{I18n.t('option.usage')}: mpw copy [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-d', '--disable-clipboard', I18n.t('option.clipboard')) do opts.on('-d', '--disable-clipboard', I18n.t('option.clipboard')) do
options[:clipboard] = false options[:clipboard] = false
end end
opts.on('-g', '--group NAME', I18n.t('option.group')) do |group| opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
values[:group] = group values[:group] = group
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
puts opts puts opts
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
options[:sync] = false values[:pattern] = pattern
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
values[:pattern] = pattern options[:wallet] = wallet
end end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])

View file

@ -1,20 +1,22 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,41 +26,36 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true values = {}
values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw delete [options]" opts.banner = "#{I18n.t('option.usage')}: mpw delete [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-g', '--group NAME', I18n.t('option.group')) do |group| opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
values[:group] = group values[:group] = group
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
puts opts puts opts
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
options[:sync] = false values[:pattern] = pattern
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
values[:pattern] = pattern options[:wallet] = wallet
end end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,45 +23,40 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true values = {}
values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]" opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-f', '--file PATH', I18n.t('option.file_export')) do |file| opts.on('-f', '--file PATH', I18n.t('option.file_export')) do |file|
options[:file] = file options[:file] = file
end end
opts.on('-g', '--group GROUP', I18n.t('option.group')) do |group| opts.on('-g', '--group GROUP', I18n.t('option.group')) do |group|
values[:group] = group values[:group] = group
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
puts opts puts opts
exit 0 exit 0
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
options[:sync] = false values[:pattern] = pattern
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
values[:pattern] = pattern options[:wallet] = wallet
end end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/mpw' require 'mpw/mpw'
@ -22,29 +21,29 @@ require 'mpw/mpw'
options = {} options = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw passwd [options]" opts.banner = "#{I18n.t('option.usage')}: mpw passwd [options]"
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
puts opts puts opts
exit 0 exit 0
end end
opts.on('-l', '--length NUMBER', I18n.t('option.length')) do |length| opts.on('-l', '--length NUMBER', I18n.t('option.length')) do |length|
options[:length] = length.to_i options[:length] = length.to_i
end end
opts.on('-n', '--numeric', I18n.t('option.numeric')) do opts.on('-n', '--numeric', I18n.t('option.numeric')) do
options[:numeric] = true options[:numeric] = true
end end
opts.on('-s', '--special-chars', I18n.t('option.special_chars')) do opts.on('-s', '--special-chars', I18n.t('option.special_chars')) do
options[:special] = true options[:special] = true
end end
opts.on('-a', '--alpha', I18n.t('option.alpha')) do opts.on('-a', '--alpha', I18n.t('option.alpha')) do
options[:alpha] = true options[:alpha] = true
end end
end.parse! end.parse!
puts MPW::MPW::password(options) puts MPW::MPW.password(options)
exit 0 exit 0

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,38 +23,43 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} formats =
options[:sync] = true Dir["#{File.expand_path('../../lib/mpw/import', __FILE__)}/*.rb"]
.map { |v| File.basename(v, '.rb') }
.join(', ')
options = {
format: 'mpw'
}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw import [options]" opts.banner = "#{I18n.t('option.usage')}: mpw import [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-f', '--file PATH', I18n.t('option.file_import')) do |file| opts.on('-f', '--file PATH', I18n.t('option.file_import')) do |file|
options[:file] = file options[:file] = file
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-F', '--format STRING', I18n.t('option.file_format', formats: formats)) do |format|
puts opts options[:format] = format
exit 0 end
end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-h', '--help', I18n.t('option.help')) do
options[:sync] = false puts opts
end exit 0
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet options[:wallet] = wallet
end end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])
cli.decrypt cli.decrypt
cli.import(options[:file]) cli.import(options[:file], options[:format])

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,41 +23,36 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = true values = {}
values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw list [options]" opts.banner = "#{I18n.t('option.usage')}: mpw list [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-g', '--group NAME', I18n.t('option.group')) do |group| opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
values[:group] = group values[:group] = group
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-h', '--help', I18n.t('option.help')) do
puts opts puts opts
exit 0 exit 0
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
values[:pattern] = pattern values[:pattern] = pattern
end end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:sync] = false options[:wallet] = wallet
end end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,43 +23,70 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} values = {}
options[:sync] = true search = {}
values = {} options = {}
options[:text_editor] = false
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw update [options]" opts.banner = "#{I18n.t('option.usage')}: mpw update [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on('-g', '--group NAME', I18n.t('option.group')) do |group| opts.on('-C', '--comment COMMENT', I18n.t('option.comment')) do |comment|
values[:group] = group values[:comment] = comment
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
puts opts search[:group] = group
exit 0 end
end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-G', '--new-group NAME', I18n.t('option.new_group')) do |group|
options[:sync] = false values[:group] = group
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern| opts.on('-h', '--help', I18n.t('option.help')) do
values[:pattern] = pattern puts opts
end exit 0
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet| opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
options[:wallet] = wallet values[:otp_key] = otp
end end
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
search[:pattern] = pattern
end
opts.on('-r', '--random', I18n.t('option.random_password')) do
options[:password] = true
end
opts.on('-t', '--text-editor', I18n.t('option.text_editor')) do
options[:text_editor] = true
end
opts.on('-u', '--url URL', I18n.t('option.url')) do |url|
values[:url] = url
end
opts.on('-U', '--user USER', I18n.t('option.user')) do |user|
values[:user] = user
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
options[:text_editor] = true if values.empty?
cli.load_config cli.load_config
cli.get_wallet(options[:wallet]) cli.get_wallet(options[:wallet])
cli.decrypt cli.decrypt
cli.update(values) cli.update(options[:password], options[:text_editor], search, values)

View file

@ -1,20 +1,19 @@
#!/usr/bin/ruby # Licensed to the Apache Software Foundation (ASF) under one
# MPW is a software to crypt and manage your passwords # or more contributor license agreements. See the NOTICE file
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> # distributed with this work for additional information
# # regarding copyright ownership. The ASF licenses this file
# This program is free software; you can redistribute it and/or # to you under the Apache License, Version 2.0 (the
# modify it under the terms of the GNU General Public License # "License"); you may not use this file except in compliance
# as published by the Free Software Foundation; either version 2 # with the License. You may obtain a copy of the License at
# of the License, or (at your option) any later version. #
# # http://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # Unless required by applicable law or agreed to in writing,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # software distributed under the License is distributed on an
# GNU General Public License for more details. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# # KIND, either express or implied. See the License for the
# You should have received a copy of the GNU General Public License # specific language governing permissions and limitations
# along with this program; if not, write to the Free Software # under the License.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'optparse' require 'optparse'
require 'mpw/config' require 'mpw/config'
@ -24,68 +23,68 @@ require 'mpw/cli'
# Options # Options
# --------------------------------------------------------- # # --------------------------------------------------------- #
options = {} options = {}
options[:sync] = {} options[:delete] = false
values = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]" opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
opts.on('-c', '--config PATH', I18n.t('option.config')) do |config| opts.on('-a', '--add-gpg-key NAME', I18n.t('option.add_gpg_key')) do |gpg_key|
options[:config] = config options[:gpg_key] = gpg_key
end end
opts.on('-h', '--help', I18n.t('option.help')) do opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
puts opts options[:config] = config
exit 0 end
end
opts.on('--host NAME', I18n.t('option.host')) do |host| opts.on('-d', '--delete-gpg-key NAME', I18n.t('option.delete_gpg_key')) do |gpg_key|
values[:host] = host options[:gpg_key] = gpg_key
end options[:delete] = true
end
opts.on('-l', '--list', I18n.t('option.list')) do |list| opts.on('-h', '--help', I18n.t('option.help')) do
options[:list] = true puts opts
end exit 0
end
opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do opts.on('-l', '--list', I18n.t('option.list')) do
options[:sync] = false options[:list] = true
end end
opts.on('--password', I18n.t('option.password')) do opts.on('-L', '--list-keys', I18n.t('option.list_keys')) do
values[:password] = true options[:list_keys] = true
end end
opts.on('--path PATH', I18n.t('option.path')) do |path| opts.on('-p', '--path PATH', I18n.t('option.path')) do |path|
values[:path] = path options[:path] = path
end end
opts.on('--port NUMBER', I18n.t('option.port')) do |port| opts.on('-P', '--default-path', I18n.t('option.default_path')) do
values[:port] = port options[:path] = 'default'
end end
opts.on('--protocol NAME', I18n.t('option.protocol')) do |protocol| opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
values[:protocol] = protocol options[:wallet] = wallet
end end
opts.on('--user NAME', I18n.t('option.user')) do |user|
values[:user] = user
end
opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
options[:wallet] = wallet
end
end.parse! end.parse!
config = MPW::Config.new(options[:config]) config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync]) cli = MPW::Cli.new(config)
cli.load_config cli.load_config
if not options[:list].nil? if options.key?(:path)
cli.list_wallet cli.get_wallet(options[:wallet])
cli.set_wallet_path(options[:path])
elsif options.key?(:list_keys) || options.key?(:gpg_key)
cli.get_wallet(options[:wallet])
cli.decrypt
if options.key?(:list_keys)
cli.list_keys
elsif options.key?(:gpg_key)
options[:delete] ? cli.delete_key(options[:gpg_key]) : cli.add_key(options[:gpg_key])
end
else else
cli.get_wallet(options[:wallet]) cli.list_wallet
cli.decrypt
cli.setup_wallet_config(values)
end end

View file

@ -1,37 +1,31 @@
--- ---
en: en:
error: error:
bad_class: "The object class isn't valid!"
config: config:
write: "Can't write the config file!" write: "Can't write the config file!"
load: "Checkconfig failed!" load: "Checkconfig failed!"
key_bad_format: "The key string isn't in good format!" key_bad_format: "The key string isn't in the right format!"
no_key_public: "You haven't the public key of %{key}!" no_key_public: "You haven't entered the public key of %{key}!"
genkey_gpg: genkey_gpg:
exception: "Can't create the GPG key!" exception: "Can't create the GPG key!"
name: "You must define a name for your GPG key!" name: "You must define a name for your GPG key!"
password: "You must define a password for your GPG key!" password: "You must define a password for your GPG key!"
empty: "The class is empty"
export: "Can't export, unable to write in %{file}!" export: "Can't export, unable to write in %{file}!"
export_key: "Can't export the GPG key"
gpg_file: gpg_file:
decrypt: "Can't decrypt file!" decrypt: "Can't decrypt file!"
encrypt: "Can't encrypt the GPG file!" encrypt: "Can't encrypt the GPG file!"
mpw_file: mpw_file:
read_data: "Can't to read the MPW file!" read_data: "Can't read the MPW file!"
write_data: "Can't to write the MPW file!" write_data: "Can't write the MPW file!"
import: "Can't import, unable to read %{file}!" import: "Can't import, unable to read %{file}!"
update: update:
name_empty: "You must define a name!" host_and_comment_empty: "You must define a host or a comment!"
sync:
general: "An error has appeared during the sync"
connection: "Connection fail!"
communication: "A communication problem with the server is appeared!"
download: "Can't download the file!"
not_authorized: "You haven't the access to remote file!"
upload: "Can't upload the file on the server!"
unknown: "An unknown error is occured!"
unknown_type: "The sync type is unknown"
warning: warning:
select: 'Your choice is not a valid element!' select: 'Your choice is not a valid item!'
command: command:
add: "Add a new item" add: "Add a new item"
@ -47,53 +41,68 @@ en:
option: option:
add: "Add an item or key" add: "Add an item or key"
alpha: "Use letter to generate a password" add_gpg_key: "Share the wallet with another GPG key"
alpha: "Use letter to create a password"
comment: "Specify a comment"
config: "Specify the configuration file to use" config: "Specify the configuration file to use"
clipboard: "Disable the clipboard feature" clipboard: "Disable the clipboard feature"
default_path: "Move the wallet to the default directory"
default_wallet: "Specify the default wallet to use"
delete_gpg_key: "Delete wallet sharing with an other GPG key"
disable_alpha: "Don't use letters to create a password"
disable_numeric: "Don't use numbers to generate a password"
disable_pinmode: "Disable the pinentry mode"
disable_special_chars: "Don't use special char to create a password"
export: "Export a wallet in an yaml file" export: "Export a wallet in an yaml file"
file_export: "Specify the file where export data" file_export: "Specify the file to export data"
file_format: "Format of import file (default: mpw; available: %{formats})"
file_import: "Specify the file to import" file_import: "Specify the file to import"
force: "No ask to confirm when you delete an item" force: "Do not ask confirmation when deleting an item"
generate_password: "Generate a random password (default 8 characters)" generate_password: "Create a random password (default 8 characters)"
gpg_exe: "Set the gpg binary path to use" gpg_exe: "Set the gpg binary path to use"
gpg_key: "Specify a GPG key (ex: user@example.com)" gpg_key: "Specify a GPG key (ex: user@example.com)"
group: "Search the items with specified group" group: "Search the items with specified group"
help: "Show this help message" help: "Show this help message"
host: "Specify the server for the synchronization"
init: "Initialize mpw" init: "Initialize mpw"
import: "Import item since a yaml file" import: "Import item from an yaml file"
key: "Specify the key name" key: "Define the key name"
lang: "Set the software language" lang: "Set the software language"
length: "Size of the password"
list: "List the wallets" list: "List the wallets"
no_sync: "Disable synchronization with the server" list_keys: "List the GPG keys in wallet"
numeric: "Use number to generate a password" new_group: "Define a group for the item"
password: "Change the password for the synchronization" numeric: "Use number to create a password"
path: "Specify the remote path" otp_code: "Set an otp key"
path: "Move the wallet in new specify directory"
pattern: "Given search pattern" pattern: "Given search pattern"
port: "Specify the connection port" pinmode: "Enable pinentry mode (available with gpg >= 2.1)"
protocol: "Specify the protocol for the connection" random_password: "Generate a random password"
setup: "Create a new configuration file" setup: "Create a new configuration file"
setup_wallet: "Create a new configuration file for a wallet" setup_wallet: "Create a new configuration file for a wallet"
special_chars: "Use special char to generate a password" special_chars: "Use special char to create a password"
show: "Search and show the items" show: "Search and display the items"
show_all: "List all items" show_all: "Listing all items"
usage: "Usage" text_editor: "Use text editor to edit the item"
user: "Specify the user for the connection" usage: "Use"
url: "Set an url (ex: https://example.com/path)"
user: "Set an user"
wallet: "Specify a wallet to use" wallet: "Specify a wallet to use"
wallet_dir: "Set the wallets folder" wallet_dir: "Set the wallets folder"
form: form:
select: "Select the item: " select:
choice: "Select the item: "
error: "No item selected"
add_key: add_key:
valid: "Key has been added!" valid: "Key has been added!"
add_item: add_item:
name: "The item's name (mandatory" name: "Item name (mandatory)"
group: "The group's name" group: "Group name"
host: "The hostname or ip" host: "Hostname or ip"
protocol: "The protocol of the connection (ssh, http, ...)" protocol: "Connection protocol (ssh, http, ...)"
login: "The login of connection" login: "Connection ID"
password: "The password" password: "Password"
port: "The connection port" port: "Connection port"
comment: "A comment" comment: "A comment"
otp_key: "The OTP secret" otp_key: "The OTP secret"
valid: "Item has been added!" valid: "Item has been added!"
@ -102,9 +111,11 @@ en:
clean: "The clipboard has been cleaned." clean: "The clipboard has been cleaned."
login: "The login has been copied in clipboard." login: "The login has been copied in clipboard."
password: "The password has been copied in clipboard for 30s!" password: "The password has been copied in clipboard for 30s!"
otp: "The OTP code has been copied for %{time}s!" otp: "The OTP code has been copied %{time}s!"
url: "The URL has been copied in clipboard."
help: help:
name: "Help" name: "Help"
url: "Press <u> to copy URL"
login: "Press <l> to copy the login" login: "Press <l> to copy the login"
password: "Press <p> to copy the password" password: "Press <p> to copy the password"
otp_code: "Press <o> to copy the otp code" otp_code: "Press <o> to copy the otp code"
@ -112,12 +123,19 @@ en:
delete_key: delete_key:
valid: "Key has been deleted!" valid: "Key has been deleted!"
delete_item: delete_item:
ask: "Are you sure you want to remove the item ?" ask: "Are you sure you want to remove this item ?"
valid: "The item has been removed!" valid: "The item has been removed!"
import: import:
ask: "Are you sure you want to import this file %{file} ?" ask: "Are you sure you want to import this file %{file} ?"
valid: "The import is succesfull!" file_empty: "The import file is empty!"
file_not_exist: "The import file doesn't exist!"
format_unknown: "The import format '%{file_format} is unknown!"
valid: "The import is successful!"
not_valid: "No data to import!" not_valid: "No data to import!"
set_config:
valid: "The config file has been edited!"
set_wallet_path:
valid: "The wallet has been moved!"
setup_config: setup_config:
title: "Setup a new config file" title: "Setup a new config file"
lang: "Choose your language (en, fr, ...) [default=%{lang}]: " lang: "Choose your language (en, fr, ...) [default=%{lang}]: "
@ -125,45 +143,38 @@ en:
gpg_exe: "Enter the executable GPG path (optional): " gpg_exe: "Enter the executable GPG path (optional): "
wallet_dir: "Enter the wallets's folder path [default=%{home}/wallets]: " wallet_dir: "Enter the wallets's folder path [default=%{home}/wallets]: "
valid: "The config file has been created!" valid: "The config file has been created!"
setup_wallet:
title: "Wallet setup"
sync_type: "Synchronization type (ssh, ftp): "
sync_host: "Synchronization server: "
sync_port: "Port of the synchronization server: "
sync_user: "Username for the synchronization: "
sync_pwd: "Password for the synchronization: "
sync_path: "File path for the synchronization : "
valid: "The wallet config file has been created!"
setup_gpg_key: setup_gpg_key:
title: "Setup a GPG key" title: "Setup a GPG key"
ask: "Do you want create your GPG key ? (Y/n)" ask: "Do you want to create your GPG key ? (Y/n)"
no_create: "You must create manually your GPG key or relaunch the software." no_create: "You must to create manually your GPG key or relaunch the software."
name: "Your name and lastname: " name: "Your name and lastname: "
password: "A password for the GPG key: " password: "A password for the GPG key: "
confirm_password: "Confirm your password: " confirm_password: "Confirm your password: "
error_password: "Your passwords aren't identical!" error_password: "Your passwords aren't identical!"
length: "Size of the GPG key [default=2048]: " length: "Size of the GPG key [default=2048]: "
expire: "Expire time of the GPG key [default=0 (unlimited)]: " expire: "Expire time of the GPG key [default=0 (unlimited)]: "
wait: "Please waiting during the GPG key generate, this process can take few minutes." wait: "Please wait until GPG key is created, this process can take a few minutes."
valid: "Your GPG key has been created ;-)" valid: "Your GPG key has been created ;-)"
update_item: update_item:
name: "The item's name (mandatory" name: "Item name (mandatory)"
group: "The group's name" group: "Group name"
host: "The hostname or ip" host: "Hostname or ip"
protocol: "The protocol of the connection (ssh, http, ...)" protocol: "Connection protocol (ssh, http, ...)"
login: "The login of connection" login: "Login id"
password: "The password (leave empty if you don't want change)" password: "Password (leave empty if you don't want to update it)"
port: "The connection port" port: "Connection port"
comment: "A comment" comment: "A comment"
otp_key: "The OTP secret (leave empty if you don't want change" otp_key: "Secret OTP (leave empty if you don't want to update it"
valid: "Item has been updated!" valid: "Item has been updated!"
export: export:
valid: "The export in %{file} is succesfull!" valid: "The export in %{file} is successful!"
display: display:
comment: "Comment" comment: "Comment"
config: "Configuration"
error: "ERROR" error: "ERROR"
gpg_password: "GPG passphrase: " keys: "GPG keys"
gpg_password: "GPG password: "
group: "Group" group: "Group"
login: "Login" login: "Login"
name: "Name" name: "Name"
@ -174,6 +185,7 @@ en:
port: "Port" port: "Port"
protocol: "Protocol" protocol: "Protocol"
server: "Server" server: "Server"
wallets: "Wallets"
warning: "Warning" warning: "Warning"
formats: formats:

View file

@ -1,6 +1,7 @@
--- ---
fr: fr:
error: error:
bad_class: "La classe de l'objet n'est pas celle attendue!"
config: config:
write: "Impossible d'écrire le fichier de configuration!" write: "Impossible d'écrire le fichier de configuration!"
load: "Le fichier de configuration est invalide!" load: "Le fichier de configuration est invalide!"
@ -10,7 +11,9 @@ fr:
exception: "La création de la clé GPG n'a pas pu aboutir!" exception: "La création de la clé GPG n'a pas pu aboutir!"
name: "Vous devez définir un nom pour votre clé GPG!" name: "Vous devez définir un nom pour votre clé GPG!"
password: "Vous devez définir un mot de passe pour votre clé GPG!" password: "Vous devez définir un mot de passe pour votre clé GPG!"
empty: "La classe est vide"
export: "Impossible d'exporter les données dans le fichier %{file}!" export: "Impossible d'exporter les données dans le fichier %{file}!"
export_key: "Impossible d'exporter la clé GPG"
gpg_file: gpg_file:
decrypt: "Impossible de déchiffrer le fichier GPG!" decrypt: "Impossible de déchiffrer le fichier GPG!"
encrypt: "Impossible de chiffrer le fichier GPG!" encrypt: "Impossible de chiffrer le fichier GPG!"
@ -19,16 +22,7 @@ fr:
write_data: "Impossible d'écrire le fichier MPW!" write_data: "Impossible d'écrire le fichier MPW!"
import: "Impossible d'importer le fichier %{file}, car il n'est pas lisible!" import: "Impossible d'importer le fichier %{file}, car il n'est pas lisible!"
update: update:
name_empty: "Vous devez définir un nom!" host_and_comment_empty: "Vous devez définir un host ou un commentaire!"
sync:
general: "Une erreur est survenue durant la synchronisation"
connection: "La connexion n'a pu être établie!"
communication: "Un problème de communication avec le serveur est apparu!"
download: "Impossible de télécharger le fichier!"
not_authorized: "Vous n'avez pas les autorisations d'accès au fichier distant!"
upload: "Impossible d'envoyer le fichier sur le serveur!"
unknown: "Une erreur inconnue est survenue!"
unknown_type: "Le type de synchronisation est inconnu"
warning: warning:
select: "Votre choix n'est pas un élément valide!" select: "Votre choix n'est pas un élément valide!"
@ -47,11 +41,21 @@ fr:
option: option:
add: "Ajoute un élément ou une clé" add: "Ajoute un élément ou une clé"
add_gpg_key: "Partage le portefeuille avec une autre clé GPG"
alpha: "Utilise des lettres dans la génération d'un mot de passe" alpha: "Utilise des lettres dans la génération d'un mot de passe"
config: "Spécifie le fichier de configuration à utiliser" config: "Spécifie le fichier de configuration à utiliser"
comment: "Spécifie un commentaire"
clipboard: "Désactive la fonction presse papier" clipboard: "Désactive la fonction presse papier"
default_path: "Déplace le portefeuille dans le dossier par défaut"
default_wallet: "Spécifie le porte-feuille à utiliser par défaut"
delete_gpg_key: "Supprime le partage le portefeuille avec une autre clé GPG"
disable_alpha: "Désactive l'utilisation des lettres dans la génération d'un mot de passe"
disable_numeric: "Désactive l'utilisation des chiffre dans la génération d'un mot de passe"
disable_pinmode: "Désactive le mode pinentry"
disable_special_chars: "Désactive l'utilisation des charactères speciaux dans la génération d'un mot de passe"
export: "Exporte un portefeuille dans un fichier yaml" export: "Exporte un portefeuille dans un fichier yaml"
file_export: "Spécifie le fichier où exporter les données" file_export: "Spécifie le fichier où exporter les données"
file_format: "Format du fichier d'import (défault: mpw; disponible: %{formats})"
file_import: "Spécifie le fichier à importer" file_import: "Spécifie le fichier à importer"
force: "Ne demande pas de confirmation pour la suppression d'un élément" force: "Ne demande pas de confirmation pour la suppression d'un élément"
generate_password: "Génére un mot de passe aléatoire (défaut 8 caractères)" generate_password: "Génére un mot de passe aléatoire (défaut 8 caractères)"
@ -59,31 +63,36 @@ fr:
gpg_key: "Spécifie une clé GPG (ex: user@example.com)" gpg_key: "Spécifie une clé GPG (ex: user@example.com)"
group: "Recherche les éléments appartenant au groupe spécifié" group: "Recherche les éléments appartenant au groupe spécifié"
help: "Affiche ce message d'aide" help: "Affiche ce message d'aide"
host: "Spécifie le serveur pour la synchronisation"
import: "Importe des éléments depuis un fichier yaml" import: "Importe des éléments depuis un fichier yaml"
init: "Initialise mpw" init: "Initialise mpw"
key: "Spécifie le nom d'une clé" key: "Spécifie le nom d'une clé"
lang: "Spécifie la langue du logiciel (ex: fr)" lang: "Spécifie la langue du logiciel (ex: fr)"
length: "Taille du mot de passe"
list: "Liste les portefeuilles" list: "Liste les portefeuilles"
no_sync: "Désactive la synchronisation avec le serveur" list_keys: "Liste les clés GPG dans le portefeuille"
new_group: "Spécifie le groupe de l'item"
numeric: "Utilise des chiffre dans la génération d'un mot de passe" numeric: "Utilise des chiffre dans la génération d'un mot de passe"
password: "Changer le mot de passe de connexion" otp_code: "Spécifie un code OTP"
path: "Spécifie le chemin distant" path: "Déplace le portefeuille dans un nouveau dossier"
pattern: "Motif de donnée à chercher" pattern: "Motif de donnée à chercher"
port: "Spécifie le port de connexion" pinmode: "Active le mode pinentry (valable avec gpg >= 2.1)"
protocol: "Spécifie le protocol utilisé pour la connexion" random_password: "Génére un mot de passe aléatoire"
setup: "Création d'un nouveau fichier de configuration" setup: "Création d'un nouveau fichier de configuration"
setup_wallet: "Création d'un nouveau fichier de configuration pour un portefeuille" setup_wallet: "Création d'un nouveau fichier de configuration pour un portefeuille"
special_chars: "Utilise des charactères speciaux dans la génération d'un mot de passe" special_chars: "Utilise des charactères speciaux dans la génération d'un mot de passe"
show: "Recherche et affiche les éléments" show: "Recherche et affiche les éléments"
show_all: "Liste tous les éléments" show_all: "Liste tous les éléments"
text_editor: "Active l'édition avec un éditeur de texte"
usage: "Utilisation" usage: "Utilisation"
user: "Spécifie l'identifiant de connection" url: "Spécifie l'url (ex: http://example.com/path)"
user: "Spécifie un utilisateur"
wallet: "Spécifie le portefeuille à utiliser" wallet: "Spécifie le portefeuille à utiliser"
wallet_dir: "Spécifie le répertoire des portefeuilles" wallet_dir: "Spécifie le répertoire des portefeuilles"
form: form:
select: "Sélectionner l'élément: " select:
choice: "Sélectionner l'élément: "
error: "Aucun élément sélectionné"
add_key: add_key:
valid: "La clé a bien été ajoutée!" valid: "La clé a bien été ajoutée!"
add_item: add_item:
@ -103,8 +112,10 @@ fr:
login: "L'identifiant a été copié dans le presse papier" login: "L'identifiant a été copié dans le presse papier"
password: "Le mot de passe a été copié dans le presse papier pour 30s!" password: "Le mot de passe a été copié dans le presse papier pour 30s!"
otp: "Le code OTP a été copié dans le presse papier il est valable %{time}s!" otp: "Le code OTP a été copié dans le presse papier il est valable %{time}s!"
url: "L'URL a été copié dans le presse papier"
help: help:
name: "Aide" name: "Aide"
url: "Pressez <u> pour copier l'URL"
login: "Pressez <l> pour copier l'identifiant" login: "Pressez <l> pour copier l'identifiant"
password: "Pressez <p> pour copier le mot de passe" password: "Pressez <p> pour copier le mot de passe"
otp_code: "Pressez <o> pour copier le code OTP" otp_code: "Pressez <o> pour copier le code OTP"
@ -116,8 +127,15 @@ fr:
valid: "L'élément a bien été supprimé!" valid: "L'élément a bien été supprimé!"
import: import:
ask: "Êtes vous sûre de vouloir importer le fichier %{file} ?" ask: "Êtes vous sûre de vouloir importer le fichier %{file} ?"
file_empty: "Le fichier d'import est vide!"
file_not_exist: "Le fichier d'import n'existe pas"
format_unknown: "Le format d'import '%{file_format}' est inconnu!"
valid: "L'import est un succès!" valid: "L'import est un succès!"
not_valid: "Aucune donnée à importer!" not_valid: "Aucune donnée à importer!"
set_config:
valid: "Le fichier de configuration a bien été modifié!"
set_wallet_path:
valid: "Le portefeuille a bien été déplacé!"
setup_config: setup_config:
title: "Création d'un nouveau fichier de configuration" title: "Création d'un nouveau fichier de configuration"
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: " lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
@ -125,15 +143,6 @@ fr:
gpg_exe: "Entrez le chemin de l'exécutable GPG (optionnel): " gpg_exe: "Entrez le chemin de l'exécutable GPG (optionnel): "
wallet_dir: "Entrez le chemin du répertoire qui contiendra les porte-feuilles de mot de passe [défaut=%{home}/wallets]: " wallet_dir: "Entrez le chemin du répertoire qui contiendra les porte-feuilles de mot de passe [défaut=%{home}/wallets]: "
valid: "Le fichier de configuration a bien été créé!" valid: "Le fichier de configuration a bien été créé!"
setup_wallet:
title: "Configuration du porte-feuille"
sync_type: "Type de synchronisation (ssh, ftp): "
sync_host: "Serveur: "
sync_port: "Port: "
sync_user: "Utilisateur: "
sync_pwd: "Mot de passe: "
sync_path: "Chemin du fichier: "
valid: "Le fichier de configuration du porte-feuille a bien été créé!"
setup_gpg_key: setup_gpg_key:
title: "Configuration d'une nouvelle clé GPG" title: "Configuration d'une nouvelle clé GPG"
ask: "Voulez vous créer votre clé GPG ? (O/n)" ask: "Voulez vous créer votre clé GPG ? (O/n)"
@ -162,7 +171,9 @@ fr:
display: display:
comment: "Commentaire" comment: "Commentaire"
config: "Configuration"
error: "ERREUR" error: "ERREUR"
keys: "Clés GPG"
gpg_password: "Mot de passe GPG: " gpg_password: "Mot de passe GPG: "
group: "Groupe" group: "Groupe"
login: "Identifiant" login: "Identifiant"
@ -174,6 +185,7 @@ fr:
port: "Port" port: "Port"
protocol: "Protocol" protocol: "Protocol"
server: "Serveur" server: "Serveur"
wallets: "Porte-feuilles"
warning: "Warning" warning: "Warning"
formats: formats:

File diff suppressed because it is too large Load diff

View file

@ -1,144 +1,190 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'gpgme' require 'gpgme'
require 'yaml' require 'yaml'
require 'i18n' require 'i18n'
require 'fileutils' require 'fileutils'
module MPW module MPW
class Config class Config
attr_accessor :error_msg
attr_accessor :error_msg
attr_accessor :key attr_accessor :gpg_key
attr_accessor :lang attr_accessor :lang
attr_accessor :config_dir attr_accessor :config_dir
attr_accessor :wallet_dir attr_accessor :default_wallet
attr_accessor :gpg_exe attr_accessor :wallet_dir
attr_accessor :wallet_paths
attr_accessor :gpg_exe
attr_accessor :password
attr_accessor :pinmode
# Constructor # @param config_file [String] path of config file
# @args: config_file -> the specify config file def initialize(config_file = nil)
def initialize(config_file=nil) @config_file = config_file
@config_file = config_file @config_dir =
if RUBY_PLATFORM =~ /darwin/
"#{Dir.home}/Library/Preferences/mpw"
elsif RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/
"#{Dir.home}/AppData/Local/mpw"
else
"#{Dir.home}/.config/mpw"
end
if /darwin/ =~ RUBY_PLATFORM @config_file = "#{@config_dir}/mpw.cfg" if @config_file.to_s.empty?
@config_dir = "#{Dir.home}/Library/Preferences/mpw" end
elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
@config_dir = "#{Dir.home}/AppData/Local/mpw"
else
@config_dir = "#{Dir.home}/.config/mpw"
end
if @config_file.nil? or @config_file.empty?
@config_file = "#{@config_dir}/mpw.cfg"
end
end
# Create a new config file # Create a new config file
# @args: key -> the gpg key to encrypt # @param options [Hash] the value to set the config file
# lang -> the software language def setup(**options)
# wallet_dir -> the directory where are the wallets password gpg_key = options[:gpg_key] || @gpg_key
# gpg_exe -> the path of gpg executable lang = options[:lang] || @lang
# @rtrn: true if le config file is create wallet_dir = options[:wallet_dir] || @wallet_dir
def setup(key, lang, wallet_dir, gpg_exe) default_wallet = options[:default_wallet] || @default_wallet
if not key =~ /[a-zA-Z0-9.-_]+\@[a-zA-Z0-9]+\.[a-zA-Z]+/ gpg_exe = options[:gpg_exe] || @gpg_exe
raise I18n.t('error.config.key_bad_format') pinmode = options.key?(:pinmode) ? options[:pinmode] : @pinmode
end password = {
numeric: true,
alpha: true,
special: false,
length: 16
}
if wallet_dir.to_s.empty? %w[numeric special alpha length].each do |k|
wallet_dir = "#{@config_dir}/wallets" if options.key?("pwd_#{k}".to_sym)
end password[k.to_sym] = options["pwd_#{k}".to_sym]
elsif !@password.nil? && @password.key?(k.to_sym)
password[k.to_sym] = @password[k.to_sym]
end
end
config = { 'key' => key, unless gpg_key =~ /[a-zA-Z0-9.-_]+\@[a-zA-Z0-9]+\.[a-zA-Z]+/
'lang' => lang, raise I18n.t('error.config.key_bad_format')
'wallet_dir' => wallet_dir, end
'gpg_exe' => gpg_exe,
}
FileUtils.mkdir_p(@config_dir, mode: 0700) wallet_dir = "#{@config_dir}/wallets" if wallet_dir.to_s.empty?
FileUtils.mkdir_p(wallet_dir, mode: 0700) config = { 'gpg_key' => gpg_key,
'lang' => lang,
'wallet_dir' => wallet_dir,
'default_wallet' => default_wallet,
'gpg_exe' => gpg_exe,
'password' => password,
'pinmode' => pinmode,
'wallet_paths' => @wallet_paths }
File.open(@config_file, 'w') do |file| FileUtils.mkdir_p(@config_dir, mode: 0700)
file << config.to_yaml FileUtils.mkdir_p(wallet_dir, mode: 0700)
end
rescue Exception => e
raise "#{I18n.t('error.config.write')}\n#{e}"
end
# Setup a new gpg key File.open(@config_file, 'w') do |file|
# @args: password -> the GPG key password file << config.to_yaml
# name -> the name of user end
# length -> length of the GPG key rescue => e
# expire -> the time of expire to GPG key raise "#{I18n.t('error.config.write')}\n#{e}"
# @rtrn: true if the GPG key is create, else false end
def setup_gpg_key(password, name, length = 4096, expire = 0)
if name.to_s.empty?
raise "#{I18n.t('error.config.genkey_gpg.name')}"
elsif password.to_s.empty?
raise "#{I18n.t('error.config.genkey_gpg.password')}"
end
param = '' # Setup a new gpg key
param << '<GnupgKeyParms format="internal">' + "\n" # @param password [String] gpg key password
param << "Key-Type: DSA\n" # @param name [String] the name of user
param << "Key-Length: #{length}\n" # @param length [Integer] length of the gpg key
param << "Subkey-Type: ELG-E\n" # @param expire [Integer] time of expire to gpg key
param << "Subkey-Length: #{length}\n" def setup_gpg_key(password, name, length = 4096, expire = 0)
param << "Name-Real: #{name}\n" raise I18n.t('error.config.genkey_gpg.name') if name.to_s.empty?
param << "Name-Comment: #{name}\n" raise I18n.t('error.config.genkey_gpg.password') if password.to_s.empty?
param << "Name-Email: #{@key}\n"
param << "Expire-Date: #{expire}\n"
param << "Passphrase: #{password}\n"
param << "</GnupgKeyParms>\n"
ctx = GPGME::Ctx.new param = ''
ctx.genkey(param, nil, nil) param << '<GnupgKeyParms format="internal">' + "\n"
rescue Exception => e param << "Key-Type: RSA\n"
raise "#{I18n.t('error.config.genkey_gpg.exception')}\n#{e}" param << "Key-Length: #{length}\n"
end param << "Subkey-Type: ELG-E\n"
param << "Subkey-Length: #{length}\n"
param << "Name-Real: #{name}\n"
param << "Name-Comment: #{name}\n"
param << "Name-Email: #{@gpg_key}\n"
param << "Expire-Date: #{expire}\n"
param << "Passphrase: #{password}\n"
param << "</GnupgKeyParms>\n"
# Load the config file ctx = GPGME::Ctx.new
def load_config ctx.genkey(param, nil, nil)
config = YAML::load_file(@config_file) rescue => e
@key = config['key'] raise "#{I18n.t('error.config.genkey_gpg.exception')}\n#{e}"
@lang = config['lang'] end
@wallet_dir = config['wallet_dir']
@gpg_exe = config['gpg_exe']
raise if @key.empty? or @wallet_dir.empty? # Load the config file
def load_config
I18n.locale = @lang.to_sym config = YAML.load_file(@config_file)
@gpg_key = config['gpg_key']
@lang = config['lang']
@wallet_dir = config['wallet_dir']
@wallet_paths = config['wallet_paths'] || {}
@default_wallet = config['default_wallet']
@gpg_exe = config['gpg_exe']
@password = config['password'] || {}
@pinmode = config['pinmode'] || false
rescue Exception => e raise if @gpg_key.empty? || @wallet_dir.empty?
raise "#{I18n.t('error.config.load')}\n#{e}"
end
# Check if private key exist I18n.locale = @lang.to_sym
# @rtrn: true if the key exist, else false rescue => e
def check_gpg_key? raise "#{I18n.t('error.config.load')}\n#{e}"
ctx = GPGME::Ctx.new end
ctx.each_key(@key, true) do
return true
end
return false # Check if private key exist
end # @return [Boolean] true if the key exist, else false
end def check_gpg_key?
ctx = GPGME::Ctx.new
ctx.each_key(@gpg_key, true) do
return true
end
false
end
# Change the path of one wallet
# @param path [String]new directory path
# @param wallet [String] wallet name
def set_wallet_path(path, wallet)
path = @wallet_dir if path == 'default'
path = File.absolute_path(path)
return if path == @wallet_dir && File.exist?("#{@wallet_dir}/#{wallet}.mpw")
return if path == @wallet_paths[wallet]
old_wallet_file =
if @wallet_paths.key?(wallet)
"#{@wallet_paths[wallet]}/#{wallet}.mpw"
else
"#{@wallet_dir}/#{wallet}.mpw"
end
FileUtils.mkdir_p(path) unless Dir.exist?(path)
FileUtils.mv(old_wallet_file, "#{path}/#{wallet}.mpw") if File.exist?(old_wallet_file)
if path == @wallet_dir
@wallet_paths.delete(wallet)
else
@wallet_paths[wallet] = path
end
setup
end
end
end end

53
lib/mpw/import/gorilla.rb Normal file
View file

@ -0,0 +1,53 @@
#
# Copyright:: 2013, Adrien Waksberg
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'csv'
module MPW
module Import
# Import an export mpw file
# @param file [String] the file path to import
def self.gorilla(file)
data = {}
CSV.foreach(file, headers: true) do |row|
id = row['uuid']
comment =
if row['title'] && row['notes']
"#{row['title']} #{row['notes']}"
elsif row['title']
row['title']
elsif row['notes']
row['notes']
end
data[id] = {
'comment' => comment,
'group' => row['group'],
'password' => row['password'],
'url' => row['url'],
'user' => row['user']
}
end
data
end
end
end

53
lib/mpw/import/keepass.rb Normal file
View file

@ -0,0 +1,53 @@
#
# Copyright:: 2013, Adrien Waksberg
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'csv'
module MPW
module Import
# Import an keepass2 export csv file
# @param file [String] the file path to import
def self.keepass(file)
data = {}
CSV.foreach(file, headers: true) do |row|
id = "#{row['Group']} #{row['Title']}"
comment =
if row['Title'] && row['Notes']
"#{row['Title']} #{row['Notes']}"
elsif row['Title']
row['Title']
elsif row['Notes']
row['Notes']
end
data[id] = {
'comment' => comment,
'group' => row['Group'],
'password' => row['Password'],
'url' => row['URL'],
'user' => row['Username']
}
end
data
end
end
end

31
lib/mpw/import/mpw.rb Normal file
View file

@ -0,0 +1,31 @@
#
# Copyright:: 2013, Adrien Waksberg
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'yaml'
module MPW
module Import
# Import an export mpw file
# @param file [String] the file path to import
def self.mpw(file)
YAML.load_file(file)
end
end
end

48
lib/mpw/import/mpw_old.rb Normal file
View file

@ -0,0 +1,48 @@
#
# Copyright:: 2013, Adrien Waksberg
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'yaml'
module MPW
module Import
# Import an export mpw file
# @param file [String] the file path to import
def self.mpw_old(file)
data = {}
YAML.load_file(file).each do |id, item|
url = ''
url += "#{item['protocol']}://" if item['protocol']
url += item['host']
url += ":#{item['port']}" if item['port']
data[id] = {
'comment' => item['comment'],
'group' => item['group'],
'otp' => item['otp'],
'password' => item['password'],
'url' => url,
'user' => item['user']
}
end
data
end
end
end

View file

@ -1,109 +1,108 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'i18n' require 'i18n'
require 'uri'
module MPW module MPW
class Item class Item
attr_accessor :created
attr_accessor :comment
attr_accessor :group
attr_accessor :host
attr_accessor :id
attr_accessor :otp
attr_accessor :port
attr_accessor :protocol
attr_accessor :last_edit
attr_accessor :url
attr_accessor :user
attr_accessor :id # @param options [Hash] the option :host is required
attr_accessor :group def initialize(**options)
attr_accessor :host @host = ''
attr_accessor :protocol
attr_accessor :user
attr_accessor :port
attr_accessor :otp
attr_accessor :comment
attr_accessor :last_edit
attr_accessor :last_sync
attr_accessor :created
# Constructor if !options[:id] || !options[:created]
# Create a new item @id = generate_id
# @args: options -> a hash of parameter @created = Time.now.to_i
# raise an error if the hash hasn't the key name else
def initialize(options={}) @id = options[:id]
if not options.has_key?(:host) or options[:host].to_s.empty? @created = options[:created]
raise I18n.t('error.update.name_empty') @last_edit = options[:last_edit]
end options[:no_update_last_edit] = true
end
if not options.has_key?(:id) or options[:id].to_s.empty? or not options.has_key?(:created) or options[:created].to_s.empty? update(options)
@id = generate_id end
@created = Time.now.to_i
else
@id = options[:id]
@created = options[:created]
@last_edit = options[:last_edit]
options[:no_update_last_edit] = true
end
update(options) # Update the item
end # @param options [Hash]
def update(**options)
unless options[:url] || options[:comment]
raise I18n.t('error.update.host_and_comment_empty')
end
# Update the item if options[:url]
# @args: options -> a hash of parameter uri = URI(options[:url])
def update(options={}) @host = uri.host || options[:url]
if options.has_key?(:host) and options[:host].to_s.empty? @port = uri.port || nil
raise I18n.t('error.update.name_empty') @protocol = uri.scheme || nil
end @url = options[:url]
end
@group = options[:group] if options.has_key?(:group) @comment = options[:comment] if options.key?(:comment)
@host = options[:host] if options.has_key?(:host) @group = options[:group] if options.key?(:group)
@protocol = options[:protocol] if options.has_key?(:protocol) @last_edit = Time.now.to_i unless options.key?(:no_update_last_edit)
@user = options[:user] if options.has_key?(:user) @otp = options[:otp] if options.key?(:otp)
@port = options[:port].to_i if options.has_key?(:port) and not options[:port].to_s.empty? @user = options[:user] if options.key?(:user)
@otp = options[:otp] if options.has_key?(:otp) end
@comment = options[:comment] if options.has_key?(:comment)
@last_edit = Time.now.to_i if not options.has_key?(:no_update_last_edit)
end
# Update last_sync # Delete all data
def set_last_sync def delete
@last_sync = Time.now.to_i @id = nil
end @comment = nil
@created = nil
@group = nil
@host = nil
@last_edit = nil
@otp = nil
@port = nil
@protocol = nil
@url = nil
@user = nil
end
# Delete all data def empty?
def delete @id.to_s.empty?
@id = nil end
@group = nil
@host = nil
@protocol = nil
@user = nil
@port = nil
@otp = nil
@comment = nil
@created = nil
@last_edit = nil
@last_sync = nil
end
def empty? def nil?
return @id.to_s.empty? false
end end
def nil? private
return false
end
# Generate an random id # Generate an random id
private # @return [String] random string
def generate_id def generate_id
return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(16).join [*('A'..'Z'), *('a'..'z'), *('0'..'9')].sample(16).join
end end
end end
end end

View file

@ -1,20 +1,22 @@
#!/usr/bin/ruby #
# MPW is a software to crypt and manage your passwords # Copyright:: 2013, Adrien Waksberg
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im> #
# # Licensed to the Apache Software Foundation (ASF) under one
# This program is free software; you can redistribute it and/or # or more contributor license agreements. See the NOTICE file
# modify it under the terms of the GNU General Public License # distributed with this work for additional information
# as published by the Free Software Foundation; either version 2 # regarding copyright ownership. The ASF licenses this file
# of the License, or (at your option) any later version. # to you under the Apache License, Version 2.0 (the
# # "License"); you may not use this file except in compliance
# This program is distributed in the hope that it will be useful, # with the License. You may obtain a copy of the License at
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # http://www.apache.org/licenses/LICENSE-2.0
# GNU General Public License for more details. #
# # Unless required by applicable law or agreed to in writing,
# You should have received a copy of the GNU General Public License # software distributed under the License is distributed on an
# along with this program; if not, write to the Free Software # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'rubygems/package' require 'rubygems/package'
require 'gpgme' require 'gpgme'
@ -22,454 +24,328 @@ require 'i18n'
require 'yaml' require 'yaml'
require 'rotp' require 'rotp'
require 'mpw/item' require 'mpw/item'
module MPW module MPW
class MPW class MPW
# @param key [String] gpg key name
# Constructor # @param wallet_file [String] path of the wallet file
def initialize(key, wallet_file, gpg_pass=nil, gpg_exe=nil) # @param gpg_pass [String] password of the gpg key
@key = key # @param gpg_exe [String] path of the gpg executable
@gpg_pass = gpg_pass # @param pinmode [Boolean] enable the gpg pinmode
@gpg_exe = gpg_exe def initialize(key, wallet_file, gpg_pass = nil, gpg_exe = nil, pinmode = false)
@wallet_file = wallet_file @key = key
@gpg_pass = gpg_pass
if not @gpg_exe.to_s.empty? @gpg_exe = gpg_exe
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg") @wallet_file = wallet_file
end @pinmode = pinmode
end
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg") unless @gpg_exe.to_s.empty?
# Read mpw file end
def read_data
@config = {} # Read mpw file
@data = [] def read_data
@keys = {} @data = []
@passwords = {} @keys = {}
@otp_keys = {} @passwords = {}
@otp_keys = {}
data = nil
data = nil
return if not File.exists?(@wallet_file)
return unless File.exist?(@wallet_file)
Gem::Package::TarReader.new(File.open(@wallet_file)) do |tar|
tar.each do |f| Gem::Package::TarReader.new(File.open(@wallet_file)) do |tar|
case f.full_name tar.each do |f|
when 'wallet/config.gpg' case f.full_name
@config = YAML.load(decrypt(f.read)) when 'wallet/meta.gpg'
data = decrypt(f.read)
when 'wallet/meta.gpg'
data = decrypt(f.read) when %r{^wallet/keys/(?<key>.+)\.pub$}
key = Regexp.last_match('key')
when /^wallet\/keys\/(?<key>.+)\.pub$/
key = Regexp.last_match('key') if GPGME::Key.find(:public, key).empty?
GPGME::Key.import(f.read, armor: true)
if GPGME::Key.find(:public, key).length == 0 end
GPGME::Key.import(f.read, armor: true)
end @keys[key] = f.read
@keys[key] = f.read when %r{^wallet/passwords/(?<id>[a-zA-Z0-9]+)\.gpg$}
@passwords[Regexp.last_match('id')] = f.read
when /^wallet\/passwords\/(?<id>[a-zA-Z0-9]+)\.gpg$/
@passwords[Regexp.last_match('id')] = f.read when %r{^wallet/otp_keys/(?<id>[a-zA-Z0-9]+)\.gpg$}
@otp_keys[Regexp.last_match('id')] = f.read
when /^wallet\/otp_keys\/(?<id>[a-zA-Z0-9]+)\.gpg$/
@otp_keys[Regexp.last_match('id')] = f.read else
next
else end
next end
end end
end
end unless data.to_s.empty?
YAML.safe_load(data).each_value do |d|
if not data.nil? and not data.empty? @data.push(
YAML.load(data).each_value do |d| Item.new(
@data.push(Item.new(id: d['id'], id: d['id'],
group: d['group'], group: d['group'],
host: d['host'], user: d['user'],
protocol: d['protocol'], url: d['url'],
user: d['user'], otp: @otp_keys.key?(d['id']),
port: d['port'], comment: d['comment'],
otp: @otp_keys.has_key?(d['id']), last_edit: d['last_edit'],
comment: d['comment'], created: d['created']
last_edit: d['last_edit'], )
created: d['created'], )
) end
) end
end
end add_key(@key) unless @keys.key?(@key)
rescue => e
add_key(@key) if @keys[@key].nil? raise "#{I18n.t('error.mpw_file.read_data')}\n#{e}"
rescue Exception => e end
raise "#{I18n.t('error.mpw_file.read_data')}\n#{e}"
end # Encrypt all data in tarball
def write_data
# Encrypt a file data = {}
def write_data tmp_file = "#{@wallet_file}.tmp"
data = {}
tmp_file = "#{@wallet_file}.tmp" @data.each do |item|
next if item.empty?
@data.each do |item|
next if item.empty? data.merge!(
item.id => {
data.merge!(item.id => { 'id' => item.id, 'id' => item.id,
'group' => item.group, 'group' => item.group,
'host' => item.host, 'user' => item.user,
'protocol' => item.protocol, 'url' => item.url,
'user' => item.user, 'comment' => item.comment,
'port' => item.port, 'last_edit' => item.last_edit,
'comment' => item.comment, 'created' => item.created
'last_edit' => item.last_edit, }
'created' => item.created, )
} end
)
end Gem::Package::TarWriter.new(File.open(tmp_file, 'w+')) do |tar|
data_encrypt = encrypt(data.to_yaml)
@config['last_update'] = Time.now.to_i tar.add_file_simple('wallet/meta.gpg', 0400, data_encrypt.length) do |io|
io.write(data_encrypt)
Gem::Package::TarWriter.new(File.open(tmp_file, 'w+')) do |tar| end
data_encrypt = encrypt(data.to_yaml)
tar.add_file_simple('wallet/meta.gpg', 0400, data_encrypt.length) do |io| @passwords.each do |id, password|
io.write(data_encrypt) tar.add_file_simple("wallet/passwords/#{id}.gpg", 0400, password.length) do |io|
end io.write(password)
end
config = encrypt(@config.to_yaml) end
tar.add_file_simple('wallet/config.gpg', 0400, config.length) do |io|
io.write(config) @otp_keys.each do |id, key|
end tar.add_file_simple("wallet/otp_keys/#{id}.gpg", 0400, key.length) do |io|
io.write(key)
@passwords.each do |id, password| end
tar.add_file_simple("wallet/passwords/#{id}.gpg", 0400, password.length) do |io| end
io.write(password)
end @keys.each do |id, key|
end tar.add_file_simple("wallet/keys/#{id}.pub", 0400, key.length) do |io|
io.write(key)
@otp_keys.each do |id, key| end
tar.add_file_simple("wallet/otp_keys/#{id}.gpg", 0400, key.length) do |io| end
io.write(key) end
end
end File.rename(tmp_file, @wallet_file)
rescue => e
@keys.each do |id, key| File.unlink(tmp_file) if File.exist?(tmp_file)
tar.add_file_simple("wallet/keys/#{id}.pub", 0400, key.length) do |io|
io.write(key) raise "#{I18n.t('error.mpw_file.write_data')}\n#{e}"
end end
end
end # Get a password
# @param id [String] the item id
File.rename(tmp_file, @wallet_file) def get_password(id)
rescue Exception => e password = decrypt(@passwords[id])
File.unlink(tmp_file) if File.exist?(tmp_file)
if /^\$[a-zA-Z0-9]{4,9}::(?<password>.+)$/ =~ password
raise "#{I18n.t('error.mpw_file.write_data')}\n#{e}" Regexp.last_match('password')
end else
password
# Get a password end
# args: id -> the item id end
def get_password(id)
password = decrypt(@passwords[id]) # Set a new password for an item
# @param id [String] the item id
if /^\$[a-zA-Z0-9]{4,9}::(?<password>.+)$/ =~ password # @param password [String] the new password
return Regexp.last_match('password') def set_password(id, password)
else salt = MPW.password(length: Random.rand(4..9))
return password password = "$#{salt}::#{password}"
end
end @passwords[id] = encrypt(password)
end
# Set a password
# args: id -> the item id # Return the list of all gpg keys
# password -> the new password # @return [Array] the gpg keys name
def set_password(id, password) def list_keys
salt = MPW::password(length: Random.rand(4..9)) @keys.keys
password = "$#{salt}::#{password}" end
@passwords[id] = encrypt(password) # Add a public key
end # @param key [String] new public key file or name
def add_key(key)
# Add a public key if File.exist?(key)
# args: key -> new public key data = File.open(key).read
# file -> public gpg file to import key_import = GPGME::Key.import(data, armor: true)
def add_key(key, file=nil) key = GPGME::Key.get(key_import.imports[0].fpr).uids[0].email
if not file.nil? and File.exists?(file) else
data = File.open(file).read data = GPGME::Key.export(key, armor: true).read
GPGME::Key.import(data, armor: true) end
else
data = GPGME::Key.export(key, armor: true).read raise I18n.t('error.export_key') if data.to_s.empty?
end
@keys[key] = data
if data.to_s.empty? @passwords.each_key { |id| set_password(id, get_password(id)) }
raise I18n.t('error.export_key') @otp_keys.each_key { |id| set_otp_key(id, get_otp_key(id)) }
end end
@keys[key] = data # Delete a public key
end # @param key [String] public key to delete
def delete_key(key)
# Delete a public key @keys.delete(key)
# args: key -> public key to delete @passwords.each_key { |id| set_password(id, get_password(id)) }
def delete_key(key) @otp_keys.each_key { |id| set_otp_key(id, get_otp_key(id)) }
@keys.delete(key) end
end
# Add a new item
# Set config # @param item [Item]
# args: config -> a hash with config options def add(item)
def set_config(options={}) raise I18n.t('error.bad_class') unless item.instance_of?(Item)
@config = {} if @config.nil? raise I18n.t('error.empty') if item.empty?
@config['protocol'] = options[:protocol] if options.has_key?(:protocol) @data.push(item)
@config['host'] = options[:host] if options.has_key?(:host) end
@config['port'] = options[:port] if options.has_key?(:port)
@config['user'] = options[:user] if options.has_key?(:user) # Search in some csv data
@config['password'] = options[:password] if options.has_key?(:password) # @param options [Hash]
@config['path'] = options[:path] if options.has_key?(:path) # @return [Array] a list with the resultat of the search
@config['last_sync'] = @config['last_sync'].nil? ? 0 : @config['last_sync'] def list(**options)
end result = []
# Add a new item search = options[:pattern].to_s.downcase
# @args: item -> Object MPW::Item group = options[:group].to_s.downcase
def add(item)
if not item.instance_of?(Item) @data.each do |item|
raise I18n.t('error.bad_class') next if item.empty?
elsif item.empty? next unless group.empty? || group.eql?(item.group.to_s.downcase)
raise I18n.t('error.add.empty')
else host = item.host.to_s.downcase
@data.push(item) comment = item.comment.to_s.downcase
end
end next unless host =~ /^.*#{search}.*$/ || comment =~ /^.*#{search}.*$/
# Search in some csv data result.push(item)
# @args: options -> a hash with paramaters end
# @rtrn: a list with the resultat of the search
def list(options={}) result
result = [] end
search = options[:pattern].to_s.downcase # Search an item with an id
group = options[:group].to_s.downcase # @param id [String]the id item
# @return [Item] an item or nil
@data.each do |item| def search_by_id(id)
next if item.empty? @data.each do |item|
next if not group.empty? and not group.eql?(item.group.to_s.downcase) return item if item.id == id
end
host = item.host.to_s.downcase
comment = item.comment.to_s.downcase nil
end
if not host =~ /^.*#{search}.*$/ and not comment =~ /^.*#{search}.*$/
next # Set a new opt key
end # @param id [String] the item id
# @param key [String] the new key
result.push(item) def set_otp_key(id, key)
end @otp_keys[id] = encrypt(key.to_s) unless key.to_s.empty?
end
return result
end # Get an opt key
# @param id [String] the item id
# Search in some csv data def get_otp_key(id)
# @args: id -> the id item @otp_keys.key?(id) ? decrypt(@otp_keys[id]) : nil
# @rtrn: a row with the result of the search end
def search_by_id(id)
@data.each do |item| # Get an otp code
return item if item.id == id # @param id [String] the item id
end # @return [String] an otp code
def get_otp_code(id)
return nil @otp_keys.key?(id) ? ROTP::TOTP.new(decrypt(@otp_keys[id])).now : 0
end end
# Get last sync # Get remaining time before expire otp code
def get_last_sync # @return [Integer] time in seconde
return @config['last_sync'].to_i def get_otp_remaining_time
rescue (Time.now.utc.to_i / 30 + 1) * 30 - Time.now.utc.to_i
return 0 end
end
# Generate a random password
# Sync data with remote file # @param options [Hash] :length, :special, :alpha, :numeric
# @args: force -> force the sync # @return [String] a random string
def sync(force=false) def self.password(**options)
return if @config.empty? or @config['protocol'].to_s.empty? length =
return if get_last_sync + 300 > Time.now.to_i and not force if !options.include?(:length) || options[:length].to_i <= 0
8
tmp_file = "#{@wallet_file}.sync" elsif options[:length].to_i >= 32_768
32_768
case @config['protocol'] else
when 'sftp', 'scp', 'ssh' options[:length].to_i
require "mpw/sync/ssh" end
sync = SyncSSH.new(@config)
when 'ftp' chars = []
require 'mpw/sync/ftp' chars += [*('!'..'?')] - [*('0'..'9')] if options[:special]
sync = SyncFTP.new(@config) chars += [*('A'..'Z'), *('a'..'z')] if options[:alpha]
else chars += [*('0'..'9')] if options[:numeric]
raise I18n.t('error.sync.unknown_type') chars = [*('A'..'Z'), *('a'..'z'), *('0'..'9')] if chars.empty?
end
result = ''
sync.connect length.times do
sync.get(tmp_file) result << chars.sample
end
remote = MPW.new(@key, tmp_file, @gpg_pass, @gpg_exe)
remote.read_data result
end
File.unlink(tmp_file) if File.exist?(tmp_file)
private
return if remote.get_last_sync == @config['last_update']
# Decrypt a gpg file
if not remote.to_s.empty? # @param data [String] data to decrypt
@data.each do |item| # @return [String] data decrypted
update = false def decrypt(data)
return nil if data.to_s.empty?
remote.list.each do |r|
next if item.id != r.id password =
if /^(1\.[0-9.]+|2\.0)(\.[0-9]+)?/ =~ GPGME::Engine.info.first.version || @pinmode
# Update item { password: @gpg_pass }
if item.last_edit < r.last_edit else
item.update(group: r.group, { password: @gpg_pass,
host: r.host, pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK }
protocol: r.protocol, end
user: r.user,
port: r.port, crypto = GPGME::Crypto.new(armor: true)
comment: r.comment crypto
) .decrypt(data, password)
set_password(item.id, remote.get_password(item.id)) .read.force_encoding('utf-8')
end rescue => e
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
r.delete end
update = true
# Encrypt a file
break # @param data [String] data to encrypt
end # @return [String] data encrypted
def encrypt(data)
# Remove an old item recipients = []
if not update and item.last_sync.to_i < get_last_sync and item.last_edit < get_last_sync crypto = GPGME::Crypto.new(armor: true, always_trust: true)
item.delete
end recipients.push(@key)
end @keys.each_key do |key|
end next if key == @key
recipients.push(key)
# Add item end
remote.list.each do |r|
next if r.last_edit <= get_last_sync crypto.encrypt(data, recipients: recipients).read
rescue => e
item = Item.new(id: r.id, raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}"
group: r.group, end
host: r.host, end
protocol: r.protocol,
user: r.user,
port: r.port,
comment: r.comment,
created: r.created,
last_edit: r.last_edit
)
set_password(item.id, remote.get_password(item.id))
add(item)
end
remote = nil
@data.each do |item|
item.set_last_sync
end
@config['last_sync'] = Time.now.to_i
write_data
sync.update(@wallet_file)
rescue Exception => e
File.unlink(tmp_file) if File.exist?(tmp_file)
raise "#{I18n.t('error.sync.general')}\n#{e}"
end
# Set an opt key
# args: id -> the item id
# key -> the new key
def set_otp_key(id, key)
if not key.to_s.empty?
@otp_keys[id] = encrypt(key.to_s)
end
end
# Get an opt key
# args: id -> the item id
# key -> the new key
def get_otp_key(id)
if @otp_keys.has_key?(id)
return decrypt(@otp_keys[id])
else
return nil
end
end
# Get an otp code
# @args: id -> the item id
# @rtrn: an otp code
def get_otp_code(id)
if not @otp_keys.has_key?(id)
return 0
else
return ROTP::TOTP.new(decrypt(@otp_keys[id])).now
end
end
# Get remaining time before expire otp code
# @rtrn: return time in seconde
def get_otp_remaining_time
return (Time.now.utc.to_i / 30 + 1) * 30 - Time.now.utc.to_i
end
# Generate a random password
# @args: options -> :length, :special, :alpha, :numeric
# @rtrn: a random string
def self.password(options={})
if not options.include?(:length) or options[:length].to_i <= 0
length = 8
elsif options[:length].to_i >= 32768
length = 32768
else
length = options[:length].to_i
end
chars = []
chars += [*('!'..'?')] - [*('0'..'9')] if options.include?(:special)
chars += [*('A'..'Z'),*('a'..'z')] if options.include?(:alpha)
chars += [*('0'..'9')] if options.include?(:numeric)
chars = [*('A'..'Z'),*('a'..'z'),*('0'..'9')] if chars.empty?
result = ''
while length > 62 do
result << chars.sample(62).join
length -= 62
end
result << chars.sample(length).join
return result
end
# Decrypt a gpg file
# @args: data -> string to decrypt
private
def decrypt(data)
return nil if data.to_s.empty?
crypto = GPGME::Crypto.new(armor: true)
return crypto.decrypt(data, password: @gpg_pass).read.force_encoding('utf-8')
rescue Exception => e
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
end
# Encrypt a file
# args: data -> string to encrypt
private
def encrypt(data)
recipients = []
crypto = GPGME::Crypto.new(armor: true, always_trust: true)
recipients.push(@key)
@keys.each_key do |key|
next if key == @key
recipients.push(key)
end
return crypto.encrypt(data, recipients: recipients).read
rescue Exception => e
raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}"
end
end
end end

View file

@ -1,68 +0,0 @@
#!/usr/bin/ruby
# MPW is a software to crypt and manage your passwords
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'i18n'
require 'net/ftp'
module MPW
class FTP
# Constructor
# @args: config -> the config
def initialize(config)
@host = config['host']
@user = config['user']
@password = config['password']
@path = config['path']
@port = config['port'].instance_of?(Integer) ? 22 : config['port']
end
# Connect to server
def connect
Net::FTP.open(@host) do |ftp|
ftp.login(@user, @password)
break
end
rescue Exception => e
raise "#{I18n.t('error.sync.connection')}\n#{e}"
end
# Get data on server
# @args: file_tmp -> the path where download the file
def get(file_tmp)
Net::FTP.open(@host) do |ftp|
ftp.login(@user, @password)
ftp.gettextfile(@path, file_tmp)
end
rescue Exception => e
raise "#{I18n.t('error.sync.download')}\n#{e}"
end
# Update the remote data
# @args: file_gpg -> the data to send on server
def update(file_gpg)
Net::FTP.open(@host) do |ftp|
ftp.login(@user, @password)
ftp.puttextfile(file_gpg, @path)
end
rescue Exception => e
raise "#{I18n.t('error.sync.upload')}\n#{e}"
end
end
end

View file

@ -1,67 +0,0 @@
#!/usr/bin/ruby
# MPW is a software to crypt and manage your passwords
# Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'i18n'
require 'net/ssh'
require 'net/sftp'
module MPW
class SyncSSH
# Constructor
# @args: config -> the config
def initialize(config)
@host = config['host']
@user = config['user']
@password = config['password']
@path = config['path']
@port = config['port'].instance_of?(Integer) ? 22 : config['port']
end
# Connect to server
def connect
Net::SSH.start(@host, @user, password: @password, port: @port) do
break
end
rescue Exception => e
raise "#{I18n.t('error.sync.connection')}\n#{e}"
end
# Get data on server
# @args: file_tmp -> the path where download the file
def get(file_tmp)
Net::SFTP.start(@host, @user, password: @password, port: @port) do |sftp|
sftp.lstat(@path) do |response|
sftp.download!(@path, file_tmp) if response.ok?
end
end
rescue Exception => e
raise "#{I18n.t('error.sync.download')}\n#{e}"
end
# Update the remote data
# @args: file_gpg -> the data to send on server
def update(file_gpg)
Net::SFTP.start(@host, @user, password: @password, port: @port) do |sftp|
sftp.upload!(file_gpg, @path)
end
rescue Exception => e
raise "#{I18n.t('error.sync.upload')}\n#{e}"
end
end
end

View file

@ -1,4 +1,3 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__) lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@ -12,18 +11,18 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/nishiki/manage-password' spec.homepage = 'https://github.com/nishiki/manage-password'
spec.license = 'GPL-2.0' spec.license = 'GPL-2.0'
spec.files = `git ls-files -z`.split("\x0") spec.files = %x(git ls-files -z).split("\x0")
spec.executables = ['mpw'] spec.executables = ['mpw']
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib'] spec.require_paths = ['lib']
spec.add_dependency "i18n", "~> 0.7", ">= 0.7.0" spec.required_ruby_version = '>= 2.1'
spec.add_dependency "gpgme", "~> 2.0", ">= 2.0.12"
spec.add_dependency "highline", "~> 1.7", ">= 1.7.8" spec.add_dependency 'i18n', '~> 0.9', '>= 0.9.1'
spec.add_dependency "locale", "~> 2.1", ">= 2.1.2" spec.add_dependency 'gpgme', '~> 2.0', '>= 2.0.14'
spec.add_dependency "colorize", "~> 0.8", ">= 0.8.1" spec.add_dependency 'highline', '~> 1.7', '>= 1.7.8'
spec.add_dependency "net-ssh", "~> 3.2", ">= 3.2.0" spec.add_dependency 'locale', '~> 2.1', '>= 2.1.2'
spec.add_dependency "net-sftp", "~> 2.1", ">= 2.1.2" spec.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
spec.add_dependency "clipboard", "~> 1.1", ">= 1.1.1" spec.add_dependency 'clipboard', '~> 1.1', '>= 1.1.1'
spec.add_dependency "rotp", "~> 3.1", ">= 3.1.0" spec.add_dependency 'rotp', '~> 3.3', '>= 3.3.0'
end end

View file

@ -1,9 +1,13 @@
--- ---
host: # <%= I18n.t('form.add_item.host') %> # <%= I18n.t('form.add_item.url') %>
user: # <%= I18n.t('form.add_item.login') %> url: <%= options[:url] %>
group: # <%= I18n.t('form.add_item.group') %> # <%= I18n.t('form.add_item.login') %>
protocol: # <%= I18n.t('form.add_item.protocol') %><% if not password %> user: <%= options[:user] %>
password: # <%= I18n.t('form.add_item.password') %><% end %> # <%= I18n.t('form.add_item.group') %>
port: # <%= I18n.t('form.add_item.port') %> group: <%= options[:group] %><% unless password %>
comment: # <%= I18n.t('form.add_item.comment') %> # <%= I18n.t('form.add_item.password') %>
otp_key: # <%= I18n.t('form.add_item.otp_key') %> password:<% end %>
# <%= I18n.t('form.add_item.comment') %>
comment: <%= options[:comment] %>
# <%= I18n.t('form.add_item.otp_key') %>
otp_key: <%= options[:otp] %>

View file

@ -1,9 +0,0 @@
---
# <%= I18n.t('form.setup_config.lang') %>
language: <%= @config.lang %>
# <%= I18n.t('form.setup_config.gpg_key') %>
gpg_key: <%= @config.key %>
# <%= I18n.t('form.setup_config.wallet_dir') %>
wallet_dir: <%= @config.config_dir %>
# <%= I18n.t('form.setup_config.gpg_exe') %>
gpg_exe: <%= @config.gpg_exe %>

View file

@ -1,17 +1,13 @@
--- ---
# <%= I18n.t('form.update_item.host') %> # <%= I18n.t('form.update_item.url') %>
host: <%= item.host %> host: <% if options[:url] %><%= options[:url] %><% else %><%= item.url %><% end %>
# <%= I18n.t('form.update_item.login') %> # <%= I18n.t('form.update_item.login') %>
user: <%= item.user %> user: <% if options[:user] %><%= options[:user] %><% else %><%= item.user %><% end %><% unless password %>
# <%= I18n.t('form.update_item.password') %> # <%= I18n.t('form.update_item.password') %>
password: password: <% end %>
# <%= I18n.t('form.update_item.group') %> # <%= I18n.t('form.update_item.group') %>
group: <%= item.group %> group: <% if options[:group] %><%= options[:group] %><% else %><%= item.group %><% end %>
# <%= I18n.t('form.update_item.protocol') %>
protocol: <%= item.protocol %>
# <%= I18n.t('form.update_item.port') %>
port: <%= item.port %>
# <%= I18n.t('form.update_item.otp_key') %> # <%= I18n.t('form.update_item.otp_key') %>
opt_key: otp_key: <% if options[:otp_key] %><%= options[:otp_key] %><% end %>
# <%= I18n.t('form.update_item.comment') %> # <%= I18n.t('form.update_item.comment') %>
comment: <%= item.comment %> comment: <% if options[:comment] %><%= options[:comment] %><% else %><%= item.comment %><% end %>

View file

@ -0,0 +1,16 @@
---
1:
url: https://fric.com
user: 230403
group: Bank
password: 5XdiTQOubRDw9B0aJoMlcEyL
otp_key: 330223432
comment: I love my bank
2:
url: https://assurance.com:443
user: user_2132
host: assurance.com
group: Assurance
password: DMyK6B3v4bWO52VzU7aTHIem
otp_key:
comment:

View file

@ -1,28 +1,31 @@
add_new: add:
group: 'test_group' url: 'https://example.com:8080'
host: 'test_host' group: 'Bank'
protocol: 'test_protocol' host: 'example.com'
user: 'test_user' protocol: 'https'
password: 'test_password' user: 'admin'
port: '42' password: 'VmfnCN6pPIqgRIbc'
comment: 'test_comment' port: '8080'
comment: 'the website'
add_existing: import:
id: 'TEST-ID-XXXXX' id: 'TEST-ID-XXXXX'
group: 'test_group_existing' url: 'https://gogole.com:8081/toto'
host: 'test_host_existing' group: 'Cloud'
protocol: 'test_protocol_existing' host: 'gogole.com'
user: 'test_user_existing' protocol: 'https'
password: 'test_password_existing' user: 'gg-2304'
port: '44' password: 'TITl0kV9CDDa9sVK'
comment: 'test_comment_existing' port: '8081'
comment: 'My little servers'
created: 1386752948 created: 1386752948
update: update:
group: 'test_group_update' url: 'ssh://example2.com:2222'
host: 'test_host_update' group: 'Assurance'
protocol: 'test_protocol_update' host: 'example2.com'
user: 'test_user_update' protocol: 'ssh'
password: 'test_password_update' user: 'root'
port: '43' password: 'kbSrbv4WlMaVxaZ7'
comment: 'test_comment_update' port: '2222'
comment: 'i love ssh'

View file

@ -0,0 +1,4 @@
uuid,group,title,url,user,password,notes
49627979-e393-48c4-49ca-1cf66603238e,Bank,Fric,http://fric.com,12345,secret,money money
49627979-e393-48c4-49ca-1cf66603238f,,My little server,server.com,secret2,
49627979-e393-48c4-49ca-1cf66603238g,Cloud,,ssh://fric.com:4333,username,secret,bastion

View file

@ -0,0 +1,3 @@
"Group","Title","Username","Password","URL","Notes"
"Racine","Bank","123456","ywcExJW8qmBVTSyi","http://bank.com/login","My little bank"
"Racine/Cloud","GAFAM","wesh","superpassword","localhost.local",""

View file

@ -0,0 +1,35 @@
---
1:
host: fric.com
user: 12345
group: Bank
password: secret
protocol: http
port:
otp_key:
comment: Fric money money
last_edit: 1487623641
created: 1485729356
2:
host: server.com
user: sercret2
group:
password:
protocol:
port: 4222
otp_key:
comment: My little server
last_edit: 1487623641
created: 1485729356
3:
host: fric.com
user: username
group: Cloud
password:
protocol: ssh
port: 4333
otp_key:
comment: bastion
last_edit: 1487623641
created: 1485729356

21
test/init.rb Normal file
View file

@ -0,0 +1,21 @@
require 'fileutils'
require 'gpgme'
FileUtils.rm_rf("#{Dir.home}/.config/mpw")
FileUtils.rm_rf("#{Dir.home}/.gnupg")
param = ''
param << '<GnupgKeyParms format="internal">' + "\n"
param << "Key-Type: RSA\n"
param << "Key-Length: 512\n"
param << "Subkey-Type: ELG-E\n"
param << "Subkey-Length: 512\n"
param << "Name-Real: test\n"
param << "Name-Comment: test\n"
param << "Name-Email: test2@example.com\n"
param << "Expire-Date: 0\n"
param << "Passphrase: password\n"
param << "</GnupgKeyParms>\n"
ctx = GPGME::Ctx.new
ctx.genkey(param, nil, nil)

View file

@ -1 +0,0 @@
echo "test\ntest\n" | ruby ./bin/mpw config --init test@test.com

View file

@ -1,11 +0,0 @@
require 'open3'
Open3.popen3("./bin/mpw config --init test@test.com") do |stdin, stdout, stderr, thread|
stdin.puts 'test'
stdin.puts 'test'
end
Open3.popen3("./bin/mpw list") do |stdin, stdout, stderr, thread|
stdin.puts 'test'
puts stdout
end

256
test/test_cli.rb Normal file
View file

@ -0,0 +1,256 @@
require 'i18n'
require 'test/unit'
class TestConfig < Test::Unit::TestCase
def setup
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = ["#{File.expand_path('../../i18n', __FILE__)}/en.yml"]
I18n.locale = :en
@password = 'password'
@fixtures = YAML.load_file('./test/files/fixtures.yml')
@gpg_key = 'test@example.com'
end
def test_00_init_config
output = %x(
echo "#{@password}\n#{@password}" | mpw config \
--init #{@gpg_key} \
2>/dev/null
)
assert_match(I18n.t('form.setup_config.valid'), output)
assert_match(I18n.t('form.setup_gpg_key.valid'), output)
end
def test_01_add_item
data = @fixtures['add']
output = %x(
echo #{@password} | mpw add \
--url #{data['url']} \
--user #{data['user']} \
--comment '#{data['comment']}' \
--group #{data['group']} \
--random \
2>/dev/null
)
assert_match(I18n.t('form.add_item.valid'), output)
output = %x(echo #{@password} | mpw list 2>/dev/null)
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
assert_match(data['user'], output)
assert_match(data['comment'], output)
assert_match(data['group'], output)
end
def test_02_search
data = @fixtures['add']
output = %x(echo #{@password} | mpw list --group #{data['group']} 2>/dev/null)
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
output = %x(echo #{@password} | mpw list --pattern #{data['host']} 2>/dev/null)
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
output = %x(echo #{@password} | mpw list --pattern #{data['comment']} 2>/dev/null)
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
output = %x(echo #{@password} | mpw list --group R1Pmfbp626TFpjlr 2>/dev/null)
assert_match(I18n.t('display.nothing'), output)
output = %x(echo #{@password} | mpw list --pattern h1IfnKqamaGM9oEX 2>/dev/null)
assert_match(I18n.t('display.nothing'), output)
end
def test_03_update_item
data = @fixtures['update']
output = %x(
echo #{@password} | mpw update \
-p #{@fixtures['add']['host']} \
--url #{data['url']} \
--user #{data['user']} \
--comment '#{data['comment']}' \
--new-group #{data['group']} \
2>/dev/null
)
assert_match(I18n.t('form.update_item.valid'), output)
output = %x(echo #{@password} | mpw list 2>/dev/null)
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
assert_match(data['user'], output)
assert_match(data['comment'], output)
assert_match(data['group'], output)
end
def test_04_delete_item
output = %x(
echo "#{@password}\ny" | mpw delete \
-p #{@fixtures['update']['host']} \
2>/dev/null
)
assert_match(I18n.t('form.delete_item.valid'), output)
output = %x(echo #{@password} | mpw list 2>/dev/null)
assert_match(I18n.t('display.nothing'), output)
end
def test_05_import_export
file_import = './test/files/fixtures-import.yml'
file_export = '/tmp/test-mpw.yml'
output = %x(echo #{@password} | mpw import --file #{file_import} 2>/dev/null)
assert_match(I18n.t('form.import.valid', file: file_import), output)
output = %x(echo #{@password} | mpw export --file #{file_export} 2>/dev/null)
assert_match(I18n.t('form.export.valid', file: file_export), output)
assert(File.exist?(file_export))
assert_equal(YAML.load_file(file_export).length, 2)
YAML.load_file(file_import).each_value do |import|
error = true
YAML.load_file(file_export).each_value do |export|
next if import['url'] != export['url']
%w[user group password protocol port otp_key comment].each do |key|
assert_equal(import[key].to_s, export[key].to_s)
end
error = false
break
end
assert(!error)
end
end
def test_06_copy
data = YAML.load_file('./test/files/fixtures-import.yml')[2]
output = %x(
echo "#{@password}\np\nq" | mpw copy \
--disable-clipboard \
-p #{data['host']} \
2>/dev/null
)
assert_match(data['password'], output)
end
def test_07_setup_wallet
gpg_key = 'test2@example.com'
output = %x(echo #{@password} | mpw wallet --add-gpg-key #{gpg_key} 2>/dev/null)
assert_match(I18n.t('form.add_key.valid'), output)
output = %x(echo #{@password} | mpw wallet --list-keys 2>/dev/null)
assert_match("| #{@gpg_key}", output)
assert_match("| #{gpg_key}", output)
output = %x(echo #{@password} | mpw wallet --delete-gpg-key #{gpg_key} 2>/dev/null)
assert_match(I18n.t('form.delete_key.valid'), output)
output = %x(echo #{@password} | mpw wallet --list-keys 2>/dev/null)
assert_match("| #{@gpg_key}", output)
assert_no_match(/\| #{gpg_key}/, output)
output = %x(mpw wallet)
assert_match('| default', output)
output = %x(mpw wallet --path '.')
assert_match(I18n.t('form.set_wallet_path.valid'), output)
output = %x(mpw config)
assert_match(%r{path_wallet_default.+\| #{Dir.pwd}/default.mpw}, output)
assert(File.exist?("#{Dir.pwd}/default.mpw"))
output = %x(mpw wallet)
assert_match('default', output)
output = %x(mpw wallet --default-path)
assert_match(I18n.t('form.set_wallet_path.valid'), output)
output = %x(mpw config)
assert_no_match(/path_wallet_default/, output)
end
def test_08_setup_config
gpg_key = 'test2@example.com'
gpg_exe = '/usr/bin/gpg2'
wallet_dir = '/tmp'
length = 24
wallet = 'work'
output = %x(
mpw config \
--gpg-exe #{gpg_exe} \
--key #{gpg_key} \
--enable-pinmode \
--disable-alpha \
--disable-special-chars \
--disable-numeric \
--length #{length} \
--wallet-dir #{wallet_dir} \
--default-wallet #{wallet}
)
assert_match(I18n.t('form.set_config.valid'), output)
output = %x(mpw config)
assert_match(/gpg_key.+\| #{gpg_key}/, output)
assert_match(/gpg_exe.+\| #{gpg_exe}/, output)
assert_match(/pinmode.+\| true/, output)
assert_match(/default_wallet.+\| #{wallet}/, output)
assert_match(/wallet_dir.+\| #{wallet_dir}/, output)
assert_match(/password_length.+\| #{length}/, output)
%w[numeric alpha special].each do |k|
assert_match(/password_#{k}.+\| false/, output)
end
output = %x(
mpw config \
--gpg-exe '' \
--key #{@gpg_key} \
--alpha \
--special-chars \
--numeric \
--disable-pinmode
)
assert_match(I18n.t('form.set_config.valid'), output)
output = %x(mpw config)
assert_match(/gpg_key.+\| #{@gpg_key}/, output)
assert_match(/pinmode.+\| false/, output)
%w[numeric alpha special].each do |k|
assert_match(/password_#{k}.+\| true/, output)
end
end
def test_09_generate_password
length = 24
output = %x(
mpw genpwd \
--length #{length} \
--alpha
)
assert_match(/[a-zA-Z]{#{length}}/, output)
output = %x(
mpw genpwd \
--length #{length} \
--numeric
)
assert_match(/[0-9]{#{length}}/, output)
output = %x(
mpw genpwd \
--length #{length} \
--special-chars
)
assert_no_match(/[a-zA-Z0-9]/, output)
end
end

View file

@ -1,40 +1,79 @@
#!/usr/bin/ruby
require 'mpw/config' require 'mpw/config'
require 'test/unit' require 'test/unit'
require 'locale' require 'locale'
require 'i18n' require 'i18n'
class TestConfig < Test::Unit::TestCase class TestConfig < Test::Unit::TestCase
def setup def setup
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1] lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{File.expand_path('../../i18n', __FILE__)}/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
end
def test_00_config if defined?(I18n.enforce_available_locales)
data = { key: 'test@example.com', I18n.enforce_available_locales = true
lang: 'en', end
wallet_dir: '/tmp/test',
gpg_exe: '',
}
@config = MPW::Config.new I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
@config.setup(data[:key], data[:lang], data[:wallet_dir], data[:gpg_exe]) I18n.load_path = Dir["#{File.expand_path('../../i18n', __FILE__)}/*.yml"]
@config.load_config I18n.default_locale = :en
I18n.locale = lang.to_sym
end
data.each do |k,v| def test_00_config
assert_equal(v, @config.send(k)) data = {
end gpg_key: 'test@example.com',
lang: 'en',
wallet_dir: '/tmp/test',
gpg_exe: ''
}
@config.setup_gpg_key('password', 'test@example.com', 2048) @config = MPW::Config.new
assert(@config.check_gpg_key?) @config.setup(data)
end @config.load_config
data.each do |k, v|
assert_equal(v, @config.send(k))
end
@config.setup_gpg_key('password', 'test@example.com', 2048)
assert(@config.check_gpg_key?)
end
def test_01_password
data = {
pwd_alpha: false,
pwd_numeric: false,
pwd_special: true,
pwd_length: 32
}
@config = MPW::Config.new
@config.load_config
assert_equal(@config.password[:length], 16)
assert(@config.password[:alpha])
assert(@config.password[:numeric])
assert(!@config.password[:special])
@config.setup(data)
@config.load_config
assert_equal(@config.password[:length], data[:pwd_length])
assert(!@config.password[:alpha])
assert(!@config.password[:numeric])
assert(@config.password[:special])
end
def test_02_wallet_paths
new_path = '/tmp/mpw-test'
@config = MPW::Config.new
@config.load_config
assert(!@config.wallet_paths['default'])
@config.set_wallet_path(new_path, 'default')
assert_equal(@config.wallet_paths['default'], new_path)
@config.set_wallet_path('default', 'default')
assert(!@config.wallet_paths['default'])
end
end end

79
test/test_import.rb Normal file
View file

@ -0,0 +1,79 @@
require 'i18n'
require 'test/unit'
class TestImport < Test::Unit::TestCase
def setup
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = ["#{File.expand_path('../../i18n', __FILE__)}/en.yml"]
I18n.locale = :en
@password = 'password'
end
def test_00_import_mpw_old
file = './test/files/import-mpw_old.txt'
format = 'mpw_old'
output = %x(
mpw import \
--file #{file} \
--format #{format} \
--wallet #{format}
)
assert_match(I18n.t('form.import.valid'), output)
output = %x(echo #{@password} | mpw list --group Bank --wallet #{format})
assert_match(%r{http://.*fric\.com.*12345.*Fric money money}, output)
output = %x(echo #{@password} | mpw list --group Cloud --wallet #{format})
assert_match(%r{ssh://.*fric\.com.*:4333.*username.*bastion}, output)
output = %x(echo #{@password} | mpw list --wallet #{format})
assert_match(/server\.com.*My little server/, output)
end
def test_01_import_gorilla
file = './test/files/import-gorilla.txt'
format = 'gorilla'
output = %x(
mpw import \
--file #{file} \
--format #{format} \
--wallet #{format}
)
assert_match(I18n.t('form.import.valid'), output)
output = %x(echo #{@password} | mpw list --group Bank --wallet #{format})
assert_match(%r{http://.*fric\.com.*12345.*Fric money money}, output)
output = %x(echo #{@password} | mpw list --group Cloud --wallet #{format})
assert_match(%r{ssh://.*fric\.com.*:4333.*username.*bastion}, output)
output = %x(echo #{@password} | mpw list --wallet #{format})
assert_match(/server\.com.*My little server/, output)
end
def test_02_import_keepass
file = './test/files/import-keepass.txt'
format = 'keepass'
output = %x(
mpw import \
--file #{file} \
--format #{format} \
--wallet #{format}
)
assert_match(I18n.t('form.import.valid'), output)
output = %x(echo #{@password} | mpw list --group 'Racine/Cloud' --wallet #{format})
assert_match(/localhost\.local.*wesh.*GAFAM/, output)
output = %x(echo #{@password} | mpw list --wallet #{format})
assert_match(%r{http://.*bank\.com.*123456.*Bank My little bank}, output)
end
end

View file

@ -1,172 +1,165 @@
#!/usr/bin/ruby
require 'mpw/item' require 'mpw/item'
require 'test/unit' require 'test/unit'
require 'yaml' require 'yaml'
class TestItem < Test::Unit::TestCase class TestItem < Test::Unit::TestCase
def setup def setup
@fixture_file = 'test/files/fixtures.yml' if defined?(I18n.enforce_available_locales)
@fixtures = YAML.load_file(@fixture_file) I18n.enforce_available_locales = false
end
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = false
end
I18n.load_path = Dir['./i18n/cli/*.yml'] I18n.load_path = Dir['./i18n/cli/*.yml']
I18n.default_locale = :en I18n.default_locale = :en
@fixtures = YAML.load_file('./test/files/fixtures.yml')
end
puts def test_00_add_without_name
end assert_raise(RuntimeError) { MPW::Item.new }
end
def test_00_add_without_name def test_01_add
assert_raise(RuntimeError){MPW::Item.new} data = {
end group: @fixtures['add']['group'],
user: @fixtures['add']['user'],
url: @fixtures['add']['url'],
comment: @fixtures['add']['comment']
}
def test_01_add_new item = MPW::Item.new(data)
data = { group: @fixtures['add_new']['group'],
host: @fixtures['add_new']['host'],
protocol: @fixtures['add_new']['protocol'],
user: @fixtures['add_new']['user'],
port: @fixtures['add_new']['port'],
comment: @fixtures['add_new']['comment'],
}
item = MPW::Item.new(data)
assert(!item.nil?) assert(!item.nil?)
assert(!item.empty?) assert(!item.empty?)
assert_equal(@fixtures['add_new']['group'], item.group) assert_equal(@fixtures['add']['url'], item.url)
assert_equal(@fixtures['add_new']['host'], item.host) assert_equal(@fixtures['add']['group'], item.group)
assert_equal(@fixtures['add_new']['protocol'], item.protocol) assert_equal(@fixtures['add']['host'], item.host)
assert_equal(@fixtures['add_new']['user'], item.user) assert_equal(@fixtures['add']['protocol'], item.protocol)
assert_equal(@fixtures['add_new']['port'].to_i, item.port) assert_equal(@fixtures['add']['user'], item.user)
assert_equal(@fixtures['add_new']['comment'], item.comment) assert_equal(@fixtures['add']['port'].to_i, item.port)
end assert_equal(@fixtures['add']['comment'], item.comment)
end
def test_02_add_existing def test_02_import
data = { id: @fixtures['add_existing']['id'], data = {
group: @fixtures['add_existing']['group'], id: @fixtures['import']['id'],
host: @fixtures['add_existing']['host'], group: @fixtures['import']['group'],
protocol: @fixtures['add_existing']['protocol'], user: @fixtures['import']['user'],
user: @fixtures['add_existing']['user'], url: @fixtures['import']['url'],
port: @fixtures['add_existing']['port'], comment: @fixtures['import']['comment'],
comment: @fixtures['add_existing']['comment'], created: @fixtures['import']['created']
created: @fixtures['add_existing']['created'], }
}
item = MPW::Item.new(data) item = MPW::Item.new(data)
assert(!item.nil?) assert(!item.nil?)
assert(!item.empty?) assert(!item.empty?)
assert_equal(@fixtures['add_existing']['id'], item.id) assert_equal(@fixtures['import']['id'], item.id)
assert_equal(@fixtures['add_existing']['group'], item.group) assert_equal(@fixtures['import']['url'], item.url)
assert_equal(@fixtures['add_existing']['host'], item.host) assert_equal(@fixtures['import']['group'], item.group)
assert_equal(@fixtures['add_existing']['protocol'], item.protocol) assert_equal(@fixtures['import']['host'], item.host)
assert_equal(@fixtures['add_existing']['user'], item.user) assert_equal(@fixtures['import']['protocol'], item.protocol)
assert_equal(@fixtures['add_existing']['port'].to_i, item.port) assert_equal(@fixtures['import']['user'], item.user)
assert_equal(@fixtures['add_existing']['comment'], item.comment) assert_equal(@fixtures['import']['port'].to_i, item.port)
assert_equal(@fixtures['add_existing']['created'], item.created) assert_equal(@fixtures['import']['comment'], item.comment)
end assert_equal(@fixtures['import']['created'], item.created)
end
def test_03_update def test_03_update
data = { group: @fixtures['add_new']['group'], data = {
host: @fixtures['add_new']['host'], group: @fixtures['add']['group'],
protocol: @fixtures['add_new']['protocol'], user: @fixtures['add']['user'],
user: @fixtures['add_new']['user'], url: @fixtures['add']['url'],
port: @fixtures['add_new']['port'], comment: @fixtures['add']['comment']
comment: @fixtures['add_new']['comment'], }
}
item = MPW::Item.new(data)
assert(!item.nil?) item = MPW::Item.new(data)
assert(!item.empty?)
created = item.created assert(!item.nil?)
last_edit = item.last_edit assert(!item.empty?)
data = { group: @fixtures['update']['group'], created = item.created
host: @fixtures['update']['host'], last_edit = item.last_edit
protocol: @fixtures['update']['protocol'],
user: @fixtures['update']['user'],
port: @fixtures['update']['port'],
comment: @fixtures['update']['comment'],
}
sleep(1)
assert(item.update(data))
assert(!item.empty?) data = {
group: @fixtures['update']['group'],
user: @fixtures['update']['user'],
url: @fixtures['update']['url'],
comment: @fixtures['update']['comment']
}
assert_equal(@fixtures['update']['group'], item.group) sleep(1)
assert_equal(@fixtures['update']['host'], item.host) assert(item.update(data))
assert_equal(@fixtures['update']['protocol'], item.protocol)
assert_equal(@fixtures['update']['user'], item.user)
assert_equal(@fixtures['update']['port'].to_i, item.port)
assert_equal(@fixtures['update']['comment'], item.comment)
assert_equal(created, item.created) assert(!item.empty?)
assert_not_equal(last_edit, item.last_edit)
end
def test_05_update_one_element assert_equal(@fixtures['update']['url'], item.url)
data = { group: @fixtures['add_new']['group'], assert_equal(@fixtures['update']['group'], item.group)
host: @fixtures['add_new']['host'], assert_equal(@fixtures['update']['host'], item.host)
protocol: @fixtures['add_new']['protocol'], assert_equal(@fixtures['update']['protocol'], item.protocol)
user: @fixtures['add_new']['user'], assert_equal(@fixtures['update']['user'], item.user)
port: @fixtures['add_new']['port'], assert_equal(@fixtures['update']['port'].to_i, item.port)
comment: @fixtures['add_new']['comment'], assert_equal(@fixtures['update']['comment'], item.comment)
}
item = MPW::Item.new(data)
assert(!item.nil?) assert_equal(created, item.created)
assert(!item.empty?) assert_not_equal(last_edit, item.last_edit)
end
last_edit = item.last_edit def test_05_update_one_element
data = {
group: @fixtures['add']['group'],
user: @fixtures['add']['user'],
url: @fixtures['add']['url'],
comment: @fixtures['add']['comment']
}
sleep(1) item = MPW::Item.new(data)
assert(item.update({comment: @fixtures['update']['comment']}))
assert_equal(@fixtures['add_new']['group'], item.group) assert(!item.nil?)
assert_equal(@fixtures['add_new']['host'], item.host) assert(!item.empty?)
assert_equal(@fixtures['add_new']['protocol'], item.protocol)
assert_equal(@fixtures['add_new']['user'], item.user)
assert_equal(@fixtures['add_new']['port'].to_i, item.port)
assert_equal(@fixtures['update']['comment'], item.comment)
assert_not_equal(last_edit, item.last_edit)
end
def test_05_delete last_edit = item.last_edit
data = { group: @fixtures['add_new']['group'],
host: @fixtures['add_new']['host'],
protocol: @fixtures['add_new']['protocol'],
user: @fixtures['add_new']['user'],
port: @fixtures['add_new']['port'],
comment: @fixtures['add_new']['comment'],
}
item = MPW::Item.new(data)
assert(!item.nil?) sleep(1)
assert(!item.empty?) item.update(comment: @fixtures['update']['comment'])
item.delete assert_equal(@fixtures['add']['url'], item.url)
assert(!item.nil?) assert_equal(@fixtures['add']['group'], item.group)
assert(item.empty?) assert_equal(@fixtures['add']['host'], item.host)
assert_equal(@fixtures['add']['protocol'], item.protocol)
assert_equal(@fixtures['add']['user'], item.user)
assert_equal(@fixtures['add']['port'].to_i, item.port)
assert_equal(@fixtures['update']['comment'], item.comment)
assert_equal(nil, item.id) assert_not_equal(last_edit, item.last_edit)
assert_equal(nil, item.group) end
assert_equal(nil, item.host)
assert_equal(nil, item.protocol) def test_05_delete
assert_equal(nil, item.user) data = {
assert_equal(nil, item.port) group: @fixtures['add']['group'],
assert_equal(nil, item.comment) user: @fixtures['add']['user'],
assert_equal(nil, item.created) url: @fixtures['add']['url'],
end comment: @fixtures['add']['comment']
end }
item = MPW::Item.new(data)
assert(!item.nil?)
assert(!item.empty?)
item.delete
assert(!item.nil?)
assert(item.empty?)
assert_equal(nil, item.id)
assert_equal(nil, item.url)
assert_equal(nil, item.group)
assert_equal(nil, item.host)
assert_equal(nil, item.protocol)
assert_equal(nil, item.user)
assert_equal(nil, item.port)
assert_equal(nil, item.comment)
assert_equal(nil, item.created)
end
end

View file

@ -1,121 +1,130 @@
#!/usr/bin/ruby
require 'mpw/mpw' require 'mpw/mpw'
require 'mpw/item' require 'mpw/item'
require 'test/unit' require 'test/unit'
require 'yaml' require 'yaml'
require 'csv' require 'csv'
class TestMPW < Test::Unit::TestCase class TestMPW < Test::Unit::TestCase
def setup def setup
fixture_file = './test/files/fixtures.yml' wallet_file = 'default.gpg'
key = 'test@example.com'
password = 'password'
wallet_file = 'default.gpg' if defined?(I18n.enforce_available_locales)
key = 'test@example.com' I18n.enforce_available_locales = false
password = 'password' end
if defined?(I18n.enforce_available_locales) @mpw = MPW::MPW.new(key, wallet_file, password)
I18n.enforce_available_locales = false @fixtures = YAML.load_file('./test/files/fixtures.yml')
end end
@mpw = MPW::MPW.new(key, wallet_file, password) def test_00_decrypt_empty_file
@fixtures = YAML.load_file(fixture_file) @mpw.read_data
end assert_equal(0, @mpw.list.length)
end
def test_00_decrypt_empty_file
@mpw.read_data
assert_equal(0, @mpw.list.length)
end
def test_01_encrypt_empty_file def test_01_encrypt_empty_file
@mpw.read_data @mpw.read_data
@mpw.write_data @mpw.write_data
end end
def test_02_add_item def test_02_add_item
data = { group: @fixtures['add_new']['group'], data = {
host: @fixtures['add_new']['host'], group: @fixtures['add']['group'],
protocol: @fixtures['add_new']['protocol'], user: @fixtures['add']['user'],
user: @fixtures['add_new']['user'], url: @fixtures['add']['url'],
port: @fixtures['add_new']['port'], comment: @fixtures['add']['comment']
comment: @fixtures['add_new']['comment'], }
}
item = MPW::Item.new(data)
assert(!item.nil?) item = MPW::Item.new(data)
assert(!item.empty?)
@mpw.read_data assert(!item.nil?)
@mpw.add(item) assert(!item.empty?)
@mpw.set_password(item.id, @fixtures['add_new']['password'])
assert_equal(1, @mpw.list.length) @mpw.read_data
@mpw.add(item)
@mpw.set_password(item.id, @fixtures['add']['password'])
item = @mpw.list[0] assert_equal(1, @mpw.list.length)
@fixtures['add_new'].each do |k,v|
if k == 'password'
assert_equal(v, @mpw.get_password(item.id))
else
assert_equal(v, item.send(k).to_s)
end
end
@mpw.write_data item = @mpw.list[0]
end @fixtures['add'].each do |k, v|
if k == 'password'
assert_equal(v, @mpw.get_password(item.id))
else
assert_equal(v, item.send(k).to_s)
end
end
def test_03_decrypt_file @mpw.write_data
@mpw.read_data end
assert_equal(1, @mpw.list.length)
item = @mpw.list[0] def test_03_decrypt_file
@fixtures['add_new'].each do |k,v| @mpw.read_data
if k == 'password' assert_equal(1, @mpw.list.length)
assert_equal(v, @mpw.get_password(item.id))
else
assert_equal(v, item.send(k).to_s)
end
end
end
def test_04_delete_item item = @mpw.list[0]
@mpw.read_data @fixtures['add'].each do |k, v|
if k == 'password'
assert_equal(v, @mpw.get_password(item.id))
else
assert_equal(v, item.send(k).to_s)
end
end
end
assert_equal(1, @mpw.list.length) def test_04_delete_item
@mpw.read_data
assert_equal(1, @mpw.list.length)
@mpw.list.each do |item| @mpw.list.each(&:delete)
item.delete assert_equal(0, @mpw.list.length)
end
assert_equal(0, @mpw.list.length) @mpw.write_data
end
@mpw.write_data def test_05_search
end @mpw.read_data
def test_05_search @fixtures.each_value do |v|
@mpw.read_data data = {
group: v['group'],
user: v['user'],
url: v['url'],
comment: v['comment']
}
@fixtures.each_value do |v| item = MPW::Item.new(data)
data = { group: v['group'],
host: v['host'],
protocol: v['protocol'],
user: v['user'],
port: v['port'],
comment: v['comment'],
}
item = MPW::Item.new(data)
assert(!item.nil?)
assert(!item.empty?)
@mpw.add(item)
@mpw.set_password(item.id, v['password'])
end
assert_equal(3, @mpw.list.length) assert(!item.nil?)
assert_equal(1, @mpw.list(group: @fixtures['add_new']['group']).length) assert(!item.empty?)
assert_equal(1, @mpw.list(pattern: 'existing').length)
assert_equal(2, @mpw.list(pattern: 'host_[eu]').length) @mpw.add(item)
end @mpw.set_password(item.id, v['password'])
end
assert_equal(3, @mpw.list.length)
assert_equal(1, @mpw.list(group: @fixtures['add']['group']).length)
assert_equal(1, @mpw.list(pattern: 'gogole').length)
assert_equal(2, @mpw.list(pattern: 'example[2\.]').length)
end
def test_06_add_gpg_key
@mpw.read_data
@mpw.add_key('test2@example.com')
assert_equal(2, @mpw.list_keys.length)
@mpw.write_data
end
def test_07_delete_gpg_key
@mpw.read_data
assert_equal(2, @mpw.list_keys.length)
@mpw.delete_key('test2@example.com')
assert_equal(1, @mpw.list_keys.length)
@mpw.write_data
end
end end

29
test/test_translate.rb Normal file
View file

@ -0,0 +1,29 @@
require 'yaml'
require 'test/unit'
class TestTranslate < Test::Unit::TestCase
def test_00_check_translate
missing = 0
Dir.glob('i18n/*.yml').each do |yaml|
lang = File.basename(yaml, '.yml')
translate = YAML.load_file(yaml)
%x(grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2).each_line do |line|
begin
t = translate[lang]
line.strip.split('.').each do |v|
t = t[v]
end
assert(!t.to_s.empty?)
rescue
puts "#{lang}.#{line}"
missing = 1
end
end
end
assert_equal(0, missing)
end
end

View file

@ -1,5 +0,0 @@
#!/usr/bin/ruby
require_relative 'test_config.rb'
require_relative 'test_item.rb'
require_relative 'test_mpw.rb'