Compare commits
No commits in common. "master" and "v4.2.0" have entirely different histories.
45 changed files with 862 additions and 1025 deletions
.docker-test.rubocop.yml.travis.ymlCHANGELOG.mdDockerfileGemfileLICENSEREADME.mdVERSION
bin
i18n
lib/mpw
mpw.gemspectemplates
test
32
.docker-test
32
.docker-test
|
@ -1,32 +0,0 @@
|
||||||
#!/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
|
|
109
.rubocop.yml
109
.rubocop.yml
|
@ -6,33 +6,116 @@ AllCops:
|
||||||
- Vagrantfile
|
- Vagrantfile
|
||||||
TargetRubyVersion: 2.3
|
TargetRubyVersion: 2.3
|
||||||
|
|
||||||
Naming/AccessorMethodName:
|
Style/AccessorMethodName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Style/NumericLiteralPrefix:
|
||||||
Lint/RescueWithoutErrorClass:
|
Enabled: false
|
||||||
|
Style/TrailingCommaInArguments:
|
||||||
|
Enabled: false
|
||||||
|
Style/TrailingCommaInLiteral:
|
||||||
|
Enabled: false
|
||||||
|
Style/FrozenStringLiteralComment:
|
||||||
|
Enabled: false
|
||||||
|
Metrics/ParameterLists:
|
||||||
|
Max: 5
|
||||||
|
CountKeywordArgs: false
|
||||||
|
Style/MutableConstant:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Metrics/LineLength:
|
Metrics/LineLength:
|
||||||
Max: 120
|
Max: 120
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/AbcSize:
|
||||||
Enabled: false
|
|
||||||
Metrics/PerceivedComplexity:
|
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Metrics/CyclomaticComplexity:
|
||||||
|
Enabled: false
|
||||||
|
Metrics/PerceivedComplexity:
|
||||||
|
Enabled: false
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/AbcSize:
|
Style/SpaceInsideHashLiteralBraces:
|
||||||
|
Enabled: false
|
||||||
|
Style/AsciiComments:
|
||||||
|
Enabled: true
|
||||||
|
Style/Documentation:
|
||||||
|
Enabled: false
|
||||||
|
Style/SignalException:
|
||||||
|
Enabled: false
|
||||||
|
Style/OptionHash:
|
||||||
|
Enabled: true
|
||||||
|
Style/SymbolArray:
|
||||||
|
Enabled: true
|
||||||
|
Performance/Casecmp:
|
||||||
|
Enabled: false
|
||||||
|
Style/DoubleNegation:
|
||||||
|
Enabled: false
|
||||||
|
Style/Alias:
|
||||||
|
EnforcedStyle: prefer_alias_method
|
||||||
|
Style/MultilineMethodCallIndentation:
|
||||||
|
EnforcedStyle: indented
|
||||||
|
Style/RaiseArgs:
|
||||||
|
EnforcedStyle: exploded
|
||||||
|
Style/SpaceInLambdaLiteral:
|
||||||
|
Enabled: false
|
||||||
|
Lint/UnneededSplatExpansion:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/NumericLiteralPrefix:
|
|
||||||
Enabled: false
|
# Generated configuration
|
||||||
Style/FrozenStringLiteralComment:
|
Style/HashSyntax:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: ruby19
|
||||||
|
UseHashRocketsWithSymbolValues: false
|
||||||
|
Style/MethodDefParentheses:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: require_parentheses
|
||||||
|
Style/MultilineAssignmentLayout:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: new_line
|
||||||
|
Style/IndentationConsistency:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: normal
|
||||||
|
Style/AlignParameters:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: with_fixed_indentation
|
||||||
|
Style/BlockDelimiters:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: line_count_based
|
||||||
|
Style/AndOr:
|
||||||
|
Enabled: true
|
||||||
|
Style/DotPosition:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: leading
|
||||||
|
Style/EmptyLinesAroundClassBody:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: no_empty_lines
|
||||||
|
Style/EmptyLinesAroundModuleBody:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: no_empty_lines
|
||||||
|
Style/NumericPredicate:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: comparison
|
||||||
|
Style/EvenOdd:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Style/CollectionMethods:
|
||||||
|
Enabled: true
|
||||||
|
PreferredMethods:
|
||||||
|
collect: map
|
||||||
|
collect!: map!
|
||||||
|
inject: reduce
|
||||||
|
detect: find
|
||||||
|
find_all: select
|
||||||
|
Style/EmptyLinesAroundAccessModifier:
|
||||||
|
Enabled: true
|
||||||
Style/CommandLiteral:
|
Style/CommandLiteral:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
EnforcedStyle: percent_x
|
EnforcedStyle: percent_x
|
||||||
Style/Documentation:
|
Style/StringLiterals:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
EnforcedStyle: single_quotes
|
||||||
|
Style/SpaceInsideBlockBraces:
|
||||||
|
EnforcedStyle: space
|
||||||
|
Style/VariableNumber:
|
||||||
|
EnforcedStyle: snake_case
|
||||||
|
|
13
.travis.yml
13
.travis.yml
|
@ -1,16 +1,14 @@
|
||||||
language: ruby
|
language: ruby
|
||||||
dist: precise
|
|
||||||
rvm:
|
rvm:
|
||||||
- 2.4.2
|
- 2.4.1
|
||||||
- 2.3.5
|
- 2.3.4
|
||||||
- 2.2.8
|
- 2.2.7
|
||||||
- 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
|
||||||
|
- echo 9999 > VERSION
|
||||||
- gem build mpw.gemspec
|
- gem build mpw.gemspec
|
||||||
- gem install mpw-$(cat VERSION).gem
|
- gem install mpw-9999.gem
|
||||||
script:
|
script:
|
||||||
- rubocop
|
- rubocop
|
||||||
- ruby ./test/init.rb
|
- ruby ./test/init.rb
|
||||||
|
@ -20,4 +18,3 @@ script:
|
||||||
- ruby ./test/test_translate.rb
|
- ruby ./test/test_translate.rb
|
||||||
- ruby ./test/init.rb
|
- ruby ./test/init.rb
|
||||||
- ruby ./test/test_cli.rb
|
- ruby ./test/test_cli.rb
|
||||||
- ruby ./test/test_import.rb
|
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
# CHANGELOG
|
# 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)
|
## v4.2.0 (2017-06-06)
|
||||||
|
|
||||||
* feat: improve the interface
|
* feat: improve the interface
|
||||||
|
|
16
Dockerfile
16
Dockerfile
|
@ -1,16 +0,0 @@
|
||||||
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"
|
|
8
Gemfile
8
Gemfile
|
@ -1,14 +1,14 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
gem 'clipboard', '~> 1.1', '>= 1.1.1'
|
gem 'clipboard', '~> 1.1', '>= 1.1.1'
|
||||||
gem 'colorize', '~> 0.8', '>= 0.8.1'
|
gem 'colorize', '~> 0.8', '>= 0.8.1'
|
||||||
gem 'gpgme', '~> 2.0', '>= 2.0.14'
|
gem 'gpgme', '~> 2.0', '>= 2.0.12'
|
||||||
gem 'highline', '~> 1.7', '>= 1.7.8'
|
gem 'highline', '~> 1.7', '>= 1.7.8'
|
||||||
gem 'i18n', '~> 0.9', '>= 0.9.1'
|
gem 'i18n', '~> 0.7', '>= 0.7.0'
|
||||||
gem 'locale', '~> 2.1', '>= 2.1.2'
|
gem 'locale', '~> 2.1', '>= 2.1.2'
|
||||||
gem 'rotp', '~> 3.3', '>= 3.3.0'
|
gem 'rotp', '~> 3.1', '>= 3.1.0'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'rubocop', '0.50.0'
|
gem 'rubocop'
|
||||||
gem 'test-unit'
|
gem 'test-unit'
|
||||||
gem 'yard'
|
gem 'yard'
|
||||||
end
|
end
|
||||||
|
|
476
LICENSE
476
LICENSE
|
@ -1,201 +1,339 @@
|
||||||
Apache License
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2.0, January 2004
|
Version 2, June 1991
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
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.
|
||||||
|
|
||||||
1. Definitions.
|
Preamble
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
The licenses for most software are designed to take away your
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
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.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
When we speak of free software, we are referring to freedom, not
|
||||||
the copyright owner that is granting the License.
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
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.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
To protect your rights, we need to make restrictions that forbid
|
||||||
other entities that control, are controlled by, or are under common
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
control with that entity. For the purposes of this definition,
|
These restrictions translate to certain responsibilities for you if you
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
distribute copies of the software, or if you modify it.
|
||||||
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.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
For example, if you distribute copies of such a program, whether
|
||||||
exercising permissions granted by this License.
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
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.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
including but not limited to software source code, documentation
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
source, and configuration files.
|
distribute and/or modify the software.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
Also, for each author's protection and ours, we want to make certain
|
||||||
transformation or translation of a Source form, including but
|
that everyone understands that there is no warranty for this free
|
||||||
not limited to compiled object code, generated documentation,
|
software. If the software is modified by someone else and passed on, we
|
||||||
and conversions to other media types.
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
Finally, any free program is threatened constantly by software
|
||||||
Object form, made available under the License, as indicated by a
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
copyright notice that is included in or attached to the work
|
program will individually obtain patent licenses, in effect making the
|
||||||
(an example is provided in the Appendix below).
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
The precise terms and conditions for copying, distribution and
|
||||||
form, that is based on (or derived from) the Work and for which the
|
modification follow.
|
||||||
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.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
GNU GENERAL PUBLIC LICENSE
|
||||||
the original version of the Work and any modifications or additions
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
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."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
0. This License applies to any program or other work which contains
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
subsequently incorporated within the Work.
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
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".
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
Activities other than copying, distribution and modification are not
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
covered by this License; they are outside its scope. The act of
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
running the Program is not restricted, and the output from the Program
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
is covered only if its contents constitute a work based on the
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
Program (independent of having been made by running the Program).
|
||||||
Work and such Derivative Works in Source or Object form.
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
source code as you receive it, in any medium, provided that you
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
(except as stated in this section) patent license to make, have made,
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
notices that refer to this License and to the absence of any warranty;
|
||||||
where such license applies only to those patent claims licensable
|
and give any other recipients of the Program a copy of this License
|
||||||
by such Contributor that are necessarily infringed by their
|
along with the Program.
|
||||||
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.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
Derivative Works a copy of this License; and
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
a) You must cause the modified files to carry prominent notices
|
||||||
stating that You changed the files; and
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
b) You must cause any work that you distribute or publish, that in
|
||||||
that You distribute, all copyright, patent, trademark, and
|
whole or in part contains or is derived from the Program or any
|
||||||
attribution notices from the Source form of the Work,
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
excluding those notices that do not pertain to any part of
|
parties under the terms of this License.
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
c) If the modified program normally reads commands interactively
|
||||||
distribution, then any Derivative Works that You distribute must
|
when run, you must cause it, when started running for such
|
||||||
include a readable copy of the attribution notices contained
|
interactive use in the most ordinary way, to print or display an
|
||||||
within such NOTICE file, excluding those notices that do not
|
announcement including an appropriate copyright notice and a
|
||||||
pertain to any part of the Derivative Works, in at least one
|
notice that there is no warranty (or else, saying that you provide
|
||||||
of the following places: within a NOTICE text file distributed
|
a warranty) and that users may redistribute the program under
|
||||||
as part of the Derivative Works; within the Source form or
|
these conditions, and telling the user how to view a copy of this
|
||||||
documentation, if provided along with the Derivative Works; or,
|
License. (Exception: if the Program itself is interactive but
|
||||||
within a display generated by the Derivative Works, if and
|
does not normally print such an announcement, your work based on
|
||||||
wherever such third-party notices normally appear. The contents
|
the Program is not required to print an announcement.)
|
||||||
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.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
These requirements apply to the modified work as a whole. If
|
||||||
may provide additional or different license terms and conditions
|
identifiable sections of that work are not derived from the Program,
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
and can be reasonably considered independent and separate works in
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
themselves, then this License, and its terms, do not apply to those
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
sections when you distribute them as separate works. But when you
|
||||||
the conditions stated in this License.
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
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.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
exercise the right to control the distribution of derivative or
|
||||||
this License, without any additional terms or conditions.
|
collective works based on the Program.
|
||||||
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.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
In addition, mere aggregation of another work not based on the Program
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
except as required for reasonable and customary use in describing the
|
a storage or distribution medium does not bring the other work under
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
the scope of this License.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
under Section 2) in object code or executable form under the terms of
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
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.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
source code, which must be distributed under the terms of Sections
|
||||||
unless required by applicable law (such as deliberate and grossly
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
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.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
b) Accompany it with a written offer, valid for at least three
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
years, to give any third party, for a charge no more than your
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
cost of physically performing source distribution, a complete
|
||||||
or other liability obligations and/or rights consistent with this
|
machine-readable copy of the corresponding source code, to be
|
||||||
License. However, in accepting such obligations, You may act only
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
customarily used for software interchange; or,
|
||||||
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.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
c) Accompany it with the information you received as to the offer
|
||||||
|
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.)
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
The source code for a work means the preferred form of the work for
|
||||||
|
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.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
If distribution of executable or object code is made by offering
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
access to copy from a designated place, then offering equivalent
|
||||||
replaced with your own identifying information. (Don't include
|
access to copy the source code from the same place counts as
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
distribution of the source code, even though third parties are not
|
||||||
comment syntax for the file format. We also recommend that a
|
compelled to copy the source along with the object code.
|
||||||
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.
|
|
||||||
|
|
||||||
Copyright 2017 Adrien Waksberg
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
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.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
5. You are not required to accept this License, since you have not
|
||||||
you may not use this file except in compliance with the License.
|
signed it. However, nothing else grants you permission to modify or
|
||||||
You may obtain a copy of the License at
|
distribute the Program or its derivative works. These actions are
|
||||||
|
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.
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
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.
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
infringement or for any other reason (not limited to patent issues),
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
See the License for the specific language governing permissions and
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
limitations under the License.
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
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.
|
||||||
|
|
38
README.md
38
README.md
|
@ -1,7 +1,7 @@
|
||||||
# MPW: Manage your passwords!
|
# MPW: Manage your passwords!
|
||||||
[](https://github.com/nishiki/manage-password/releases)
|
[](https://github.com/nishiki/manage-password/releases)
|
||||||
[](https://travis-ci.org/nishiki/manage-password)
|
[](https://travis-ci.org/nishiki/manage-password)
|
||||||
[](https://github.com/nishiki/manage-password/blob/master/LICENSE)
|
[](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.
|
mpw is a little software which stores your passwords in [GnuPG](http://www.gnupg.org/) encrypted files.
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ Add your first item:
|
||||||
```
|
```
|
||||||
mpw add --host assurance.com --port 443 --user user_2132 --protocol https --random
|
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
|
mpw add --host fric.com --user 230403 --otp-code 23434113 --protocol https --comment 'I love my bank' --random
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
And list your items:
|
And list your items:
|
||||||
|
@ -160,36 +161,3 @@ Configuration
|
||||||
password_length | 16
|
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.
|
|
||||||
```
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.2.2
|
4.2.0
|
||||||
|
|
31
bin/mpw
31
bin/mpw
|
@ -1,23 +1,20 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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.
|
|
||||||
|
|
||||||
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
||||||
|
|
||||||
|
|
48
bin/mpw-add
48
bin/mpw-add
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
@ -50,10 +48,22 @@ OptionParser.new do |opts|
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-H', '--host HOST', I18n.t('option.host')) do |host|
|
||||||
|
values[:host] = host
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
|
opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
|
||||||
values[:otp_key] = otp
|
values[:otp_key] = otp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-O', '--protocol PROTOCOL', I18n.t('option.protocol')) do |protocol|
|
||||||
|
values[:protocol] = protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on('-P', '--port NUMBER', I18n.t('option.port')) do |port|
|
||||||
|
values[:port] = port
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-r', '--random', I18n.t('option.random_password')) do
|
opts.on('-r', '--random', I18n.t('option.random_password')) do
|
||||||
options[:password] = true
|
options[:password] = true
|
||||||
end
|
end
|
||||||
|
@ -62,11 +72,7 @@ OptionParser.new do |opts|
|
||||||
options[:text_editor] = true
|
options[:text_editor] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-u', '--url URL', I18n.t('option.url')) do |url|
|
opts.on('-u', '--user USER', I18n.t('option.user')) do |user|
|
||||||
values[:url] = url
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on('-U', '--user USER', I18n.t('option.user')) do |user|
|
|
||||||
values[:user] = user
|
values[:user] = user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
30
bin/mpw-copy
30
bin/mpw-copy
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/mpw'
|
require 'mpw/mpw'
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
@ -23,13 +24,7 @@ require 'mpw/cli'
|
||||||
# Options
|
# Options
|
||||||
# --------------------------------------------------------- #
|
# --------------------------------------------------------- #
|
||||||
|
|
||||||
formats =
|
options = {}
|
||||||
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]"
|
||||||
|
@ -42,10 +37,6 @@ OptionParser.new do |opts|
|
||||||
options[:file] = file
|
options[:file] = file
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-F', '--format STRING', I18n.t('option.file_format', formats: formats)) do |format|
|
|
||||||
options[:format] = format
|
|
||||||
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
|
||||||
|
@ -62,4 +53,4 @@ 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], options[:format])
|
cli.import(options[:file])
|
||||||
|
|
29
bin/mpw-list
29
bin/mpw-list
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
@ -52,14 +53,26 @@ OptionParser.new do |opts|
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-H', '--host HOST', I18n.t('option.host')) do |host|
|
||||||
|
values[:host] = host
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
|
opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
|
||||||
values[:otp_key] = otp
|
values[:otp_key] = otp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-O', '--protocol PROTOCOL', I18n.t('option.protocol')) do |protocol|
|
||||||
|
values[:protocol] = protocol
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
|
opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
|
||||||
search[:pattern] = pattern
|
search[:pattern] = pattern
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('-P', '--port NUMBER', I18n.t('option.port')) do |port|
|
||||||
|
values[:port] = port
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('-r', '--random', I18n.t('option.random_password')) do
|
opts.on('-r', '--random', I18n.t('option.random_password')) do
|
||||||
options[:password] = true
|
options[:password] = true
|
||||||
end
|
end
|
||||||
|
@ -68,11 +81,7 @@ OptionParser.new do |opts|
|
||||||
options[:text_editor] = true
|
options[:text_editor] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-u', '--url URL', I18n.t('option.url')) do |url|
|
opts.on('-u', '--user USER', I18n.t('option.user')) do |user|
|
||||||
values[:url] = url
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on('-U', '--user USER', I18n.t('option.user')) do |user|
|
|
||||||
values[:user] = user
|
values[:user] = user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
#!/usr/bin/ruby
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# MPW is a software to crypt and manage your passwords
|
||||||
# distributed with this work for additional information
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
# 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
|
# 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.
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# software distributed under the License is distributed on an
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# KIND, either express or implied. See the License for the
|
# GNU General Public License for more details.
|
||||||
# specific language governing permissions and limitations
|
#
|
||||||
# under the License.
|
# 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 'optparse'
|
require 'optparse'
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
|
|
12
i18n/en.yml
12
i18n/en.yml
|
@ -22,7 +22,7 @@ en:
|
||||||
write_data: "Can't 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:
|
||||||
host_and_comment_empty: "You must define a host or a comment!"
|
host_empty: "You must define a host!"
|
||||||
|
|
||||||
warning:
|
warning:
|
||||||
select: 'Your choice is not a valid item!'
|
select: 'Your choice is not a valid item!'
|
||||||
|
@ -55,7 +55,6 @@ en:
|
||||||
disable_special_chars: "Don't use special char to create a password"
|
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 to 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: "Do not ask confirmation when deleting an item"
|
force: "Do not ask confirmation when deleting an item"
|
||||||
generate_password: "Create a random password (default 8 characters)"
|
generate_password: "Create a random password (default 8 characters)"
|
||||||
|
@ -63,6 +62,7 @@ en:
|
||||||
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 a host or ip"
|
||||||
init: "Initialize mpw"
|
init: "Initialize mpw"
|
||||||
import: "Import item from an yaml file"
|
import: "Import item from an yaml file"
|
||||||
key: "Define the key name"
|
key: "Define the key name"
|
||||||
|
@ -76,6 +76,8 @@ en:
|
||||||
path: "Move the wallet in new specify directory"
|
path: "Move the wallet in new specify directory"
|
||||||
pattern: "Given search pattern"
|
pattern: "Given search pattern"
|
||||||
pinmode: "Enable pinentry mode (available with gpg >= 2.1)"
|
pinmode: "Enable pinentry mode (available with gpg >= 2.1)"
|
||||||
|
port: "Set a port of connexion"
|
||||||
|
protocol: "Set a protocol of connexion"
|
||||||
random_password: "Generate a random password"
|
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"
|
||||||
|
@ -84,15 +86,12 @@ en:
|
||||||
show_all: "Listing all items"
|
show_all: "Listing all items"
|
||||||
text_editor: "Use text editor to edit the item"
|
text_editor: "Use text editor to edit the item"
|
||||||
usage: "Use"
|
usage: "Use"
|
||||||
url: "Set an url (ex: https://example.com/path)"
|
|
||||||
user: "Set an user"
|
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: "Select the item: "
|
||||||
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:
|
||||||
|
@ -129,7 +128,6 @@ en:
|
||||||
ask: "Are you sure you want to import this file %{file} ?"
|
ask: "Are you sure you want to import this file %{file} ?"
|
||||||
file_empty: "The import file is empty!"
|
file_empty: "The import file is empty!"
|
||||||
file_not_exist: "The import file doesn't exist!"
|
file_not_exist: "The import file doesn't exist!"
|
||||||
format_unknown: "The import format '%{file_format} is unknown!"
|
|
||||||
valid: "The import is successful!"
|
valid: "The import is successful!"
|
||||||
not_valid: "No data to import!"
|
not_valid: "No data to import!"
|
||||||
set_config:
|
set_config:
|
||||||
|
|
12
i18n/fr.yml
12
i18n/fr.yml
|
@ -22,7 +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:
|
||||||
host_and_comment_empty: "Vous devez définir un host ou un commentaire!"
|
host_empty: "Vous devez définir un host!"
|
||||||
|
|
||||||
warning:
|
warning:
|
||||||
select: "Votre choix n'est pas un élément valide!"
|
select: "Votre choix n'est pas un élément valide!"
|
||||||
|
@ -55,7 +55,6 @@ fr:
|
||||||
disable_special_chars: "Désactive l'utilisation des charactères speciaux dans la génération d'un mot de passe"
|
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)"
|
||||||
|
@ -63,6 +62,7 @@ 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 nom du serveur ou l'ip"
|
||||||
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é"
|
||||||
|
@ -76,6 +76,8 @@ fr:
|
||||||
path: "Déplace le portefeuille dans un nouveau dossier"
|
path: "Déplace le portefeuille dans un nouveau dossier"
|
||||||
pattern: "Motif de donnée à chercher"
|
pattern: "Motif de donnée à chercher"
|
||||||
pinmode: "Active le mode pinentry (valable avec gpg >= 2.1)"
|
pinmode: "Active le mode pinentry (valable avec gpg >= 2.1)"
|
||||||
|
port: "Spécifie un port de connexion"
|
||||||
|
protocol: "Spécifie un protocol de connexion"
|
||||||
random_password: "Génére un mot de passe aléatoire"
|
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"
|
||||||
|
@ -84,15 +86,12 @@ fr:
|
||||||
show_all: "Liste tous les éléments"
|
show_all: "Liste tous les éléments"
|
||||||
text_editor: "Active l'édition avec un éditeur de texte"
|
text_editor: "Active l'édition avec un éditeur de texte"
|
||||||
usage: "Utilisation"
|
usage: "Utilisation"
|
||||||
url: "Spécifie l'url (ex: http://example.com/path)"
|
|
||||||
user: "Spécifie un utilisateur"
|
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:
|
select: "Sélectionner l'élément: "
|
||||||
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:
|
||||||
|
@ -129,7 +128,6 @@ fr:
|
||||||
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_empty: "Le fichier d'import est vide!"
|
||||||
file_not_exist: "Le fichier d'import n'existe pas"
|
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:
|
set_config:
|
||||||
|
|
100
lib/mpw/cli.rb
100
lib/mpw/cli.rb
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'readline'
|
require 'readline'
|
||||||
require 'locale'
|
require 'locale'
|
||||||
|
@ -288,22 +286,9 @@ module MPW
|
||||||
return items[0] if items.length == 1
|
return items[0] if items.length == 1
|
||||||
|
|
||||||
items.sort! { |a, b| a.group.to_s.downcase <=> b.group.to_s.downcase }
|
items.sort! { |a, b| a.group.to_s.downcase <=> b.group.to_s.downcase }
|
||||||
choice = ask(I18n.t('form.select.choice')).to_i
|
choice = ask(I18n.t('form.select')).to_i
|
||||||
|
|
||||||
raise I18n.t('form.select.error') unless choice >= 1 && choice <= items.length
|
choice >= 1 && choice <= items.length ? items[choice - 1] : nil
|
||||||
|
|
||||||
items[choice - 1]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Print help message for clipboard mode
|
|
||||||
# @param item [Item]
|
|
||||||
def clipboard_help(item)
|
|
||||||
puts "----- #{I18n.t('form.clipboard.help.name')} -----".cyan
|
|
||||||
puts I18n.t('form.clipboard.help.url')
|
|
||||||
puts I18n.t('form.clipboard.help.login')
|
|
||||||
puts I18n.t('form.clipboard.help.password')
|
|
||||||
puts I18n.t('form.clipboard.help.otp_code') if item.otp
|
|
||||||
puts I18n.t('form.clipboard.help.quit')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Copy in clipboard the login and password
|
# Copy in clipboard the login and password
|
||||||
|
@ -354,10 +339,7 @@ module MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'o', 'otp'
|
when 'o', 'otp'
|
||||||
if !item.otp
|
if clipboard
|
||||||
clipboard_help(item)
|
|
||||||
next
|
|
||||||
elsif clipboard
|
|
||||||
Clipboard.copy(@mpw.get_otp_code(item.id))
|
Clipboard.copy(@mpw.get_otp_code(item.id))
|
||||||
else
|
else
|
||||||
puts @mpw.get_otp_code(item.id)
|
puts @mpw.get_otp_code(item.id)
|
||||||
|
@ -365,7 +347,13 @@ module MPW
|
||||||
puts I18n.t('form.clipboard.otp', time: @mpw.get_otp_remaining_time).yellow
|
puts I18n.t('form.clipboard.otp', time: @mpw.get_otp_remaining_time).yellow
|
||||||
|
|
||||||
else
|
else
|
||||||
clipboard_help(item)
|
puts "----- #{I18n.t('form.clipboard.help.name')} -----".cyan
|
||||||
|
puts I18n.t('form.clipboard.help.url')
|
||||||
|
puts I18n.t('form.clipboard.help.login')
|
||||||
|
puts I18n.t('form.clipboard.help.password')
|
||||||
|
puts I18n.t('form.clipboard.help.otp_code')
|
||||||
|
puts I18n.t('form.clipboard.help.quit')
|
||||||
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -376,8 +364,7 @@ module MPW
|
||||||
|
|
||||||
# List all wallets
|
# List all wallets
|
||||||
def list_wallet
|
def list_wallet
|
||||||
wallets = @config.wallet_paths.keys
|
wallets = []
|
||||||
|
|
||||||
Dir.glob("#{@config.wallet_dir}/*.mpw").each do |f|
|
Dir.glob("#{@config.wallet_dir}/*.mpw").each do |f|
|
||||||
wallet = File.basename(f, '.mpw')
|
wallet = File.basename(f, '.mpw')
|
||||||
wallet += ' *'.green if wallet == @config.default_wallet
|
wallet += ' *'.green if wallet == @config.default_wallet
|
||||||
|
@ -566,14 +553,16 @@ module MPW
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
data.merge!(
|
data.merge!(
|
||||||
item.id => {
|
item.id => {
|
||||||
'comment' => item.comment,
|
'host' => item.host,
|
||||||
'created' => item.created,
|
'user' => item.user,
|
||||||
'group' => item.group,
|
'group' => item.group,
|
||||||
'last_edit' => item.last_edit,
|
|
||||||
'otp_key' => @mpw.get_otp_key(item.id),
|
|
||||||
'password' => @mpw.get_password(item.id),
|
'password' => @mpw.get_password(item.id),
|
||||||
'url' => item.url,
|
'protocol' => item.protocol,
|
||||||
'user' => item.user
|
'port' => item.port,
|
||||||
|
'otp_key' => @mpw.get_otp_key(item.id),
|
||||||
|
'comment' => item.comment,
|
||||||
|
'last_edit' => item.last_edit,
|
||||||
|
'created' => item.created,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -587,24 +576,17 @@ module MPW
|
||||||
|
|
||||||
# Import items from an yaml file
|
# Import items from an yaml file
|
||||||
# @param file [String] path of import file
|
# @param file [String] path of import file
|
||||||
# @param format [String] the software import file format
|
def import(file)
|
||||||
def import(file, format = 'mpw')
|
|
||||||
raise I18n.t('form.import.file_empty') if file.to_s.empty?
|
raise I18n.t('form.import.file_empty') if file.to_s.empty?
|
||||||
raise I18n.t('form.import.file_not_exist') unless File.exist?(file)
|
raise I18n.t('form.import.file_not_exist') unless File.exist?(file)
|
||||||
|
|
||||||
begin
|
YAML.load_file(file).each_value do |row|
|
||||||
require "mpw/import/#{format}"
|
item = Item.new(group: row['group'],
|
||||||
rescue LoadError
|
host: row['host'],
|
||||||
raise I18n.t('form.import.format_unknown', file_format: format)
|
protocol: row['protocol'],
|
||||||
end
|
user: row['user'],
|
||||||
|
port: row['port'],
|
||||||
Import.send(format, file).each_value do |row|
|
comment: row['comment'])
|
||||||
item = Item.new(
|
|
||||||
comment: row['comment'],
|
|
||||||
group: row['group'],
|
|
||||||
url: row['url'],
|
|
||||||
user: row['user']
|
|
||||||
)
|
|
||||||
|
|
||||||
next if item.empty?
|
next if item.empty?
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'gpgme'
|
require 'gpgme'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
@ -41,9 +39,9 @@ module MPW
|
||||||
def initialize(config_file = nil)
|
def initialize(config_file = nil)
|
||||||
@config_file = config_file
|
@config_file = config_file
|
||||||
@config_dir =
|
@config_dir =
|
||||||
if RUBY_PLATFORM =~ /darwin/
|
if /darwin/ =~ RUBY_PLATFORM
|
||||||
"#{Dir.home}/Library/Preferences/mpw"
|
"#{Dir.home}/Library/Preferences/mpw"
|
||||||
elsif RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
|
||||||
"#{Dir.home}/AppData/Local/mpw"
|
"#{Dir.home}/AppData/Local/mpw"
|
||||||
else
|
else
|
||||||
"#{Dir.home}/.config/mpw"
|
"#{Dir.home}/.config/mpw"
|
||||||
|
@ -163,7 +161,6 @@ module MPW
|
||||||
# @param wallet [String] wallet name
|
# @param wallet [String] wallet name
|
||||||
def set_wallet_path(path, wallet)
|
def set_wallet_path(path, wallet)
|
||||||
path = @wallet_dir if path == 'default'
|
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_dir && File.exist?("#{@wallet_dir}/#{wallet}.mpw")
|
||||||
return if path == @wallet_paths[wallet]
|
return if path == @wallet_paths[wallet]
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
|
@ -1,53 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
|
@ -1,31 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
|
@ -1,48 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
|
@ -1,45 +1,43 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'i18n'
|
require 'i18n'
|
||||||
require 'uri'
|
|
||||||
|
|
||||||
module MPW
|
module MPW
|
||||||
class Item
|
class Item
|
||||||
attr_accessor :created
|
attr_accessor :id
|
||||||
attr_accessor :comment
|
|
||||||
attr_accessor :group
|
attr_accessor :group
|
||||||
attr_accessor :host
|
attr_accessor :host
|
||||||
attr_accessor :id
|
|
||||||
attr_accessor :otp
|
|
||||||
attr_accessor :port
|
|
||||||
attr_accessor :protocol
|
attr_accessor :protocol
|
||||||
attr_accessor :last_edit
|
|
||||||
attr_accessor :url
|
|
||||||
attr_accessor :user
|
attr_accessor :user
|
||||||
|
attr_accessor :port
|
||||||
|
attr_accessor :otp
|
||||||
|
attr_accessor :comment
|
||||||
|
attr_accessor :last_edit
|
||||||
|
attr_accessor :created
|
||||||
|
|
||||||
# @param options [Hash] the option :host is required
|
# @param options [Hash] the option :host is required
|
||||||
def initialize(**options)
|
def initialize(**options)
|
||||||
@host = ''
|
if !options.key?(:host) || options[:host].to_s.empty?
|
||||||
|
raise I18n.t('error.update.host_empty')
|
||||||
|
end
|
||||||
|
|
||||||
if !options[:id] || !options[:created]
|
if !options.key?(:id) || options[:id].to_s.empty? || !options.key?(:created) || options[:created].to_s.empty?
|
||||||
@id = generate_id
|
@id = generate_id
|
||||||
@created = Time.now.to_i
|
@created = Time.now.to_i
|
||||||
else
|
else
|
||||||
|
@ -55,38 +53,43 @@ module MPW
|
||||||
# Update the item
|
# Update the item
|
||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
def update(**options)
|
def update(**options)
|
||||||
unless options[:url] || options[:comment]
|
if options.key?(:host) && options[:host].to_s.empty?
|
||||||
raise I18n.t('error.update.host_and_comment_empty')
|
raise I18n.t('error.update.host_empty')
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:url]
|
@group = options[:group] if options.key?(:group)
|
||||||
uri = URI(options[:url])
|
@host = options[:host] if options.key?(:host)
|
||||||
@host = uri.host || options[:url]
|
@protocol = options[:protocol] if options.key?(:protocol)
|
||||||
@port = uri.port || nil
|
@user = options[:user] if options.key?(:user)
|
||||||
@protocol = uri.scheme || nil
|
@port = options[:port].to_i if options.key?(:port) && !options[:port].to_s.empty?
|
||||||
@url = options[:url]
|
@otp = options[:otp] if options.key?(:otp)
|
||||||
end
|
@comment = options[:comment] if options.key?(:comment)
|
||||||
|
@last_edit = Time.now.to_i unless options.key?(:no_update_last_edit)
|
||||||
@comment = options[:comment] if options.key?(:comment)
|
|
||||||
@group = options[:group] if options.key?(:group)
|
|
||||||
@last_edit = Time.now.to_i unless options.key?(:no_update_last_edit)
|
|
||||||
@otp = options[:otp] if options.key?(:otp)
|
|
||||||
@user = options[:user] if options.key?(:user)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete all data
|
# Delete all data
|
||||||
def delete
|
def delete
|
||||||
@id = nil
|
@id = nil
|
||||||
@comment = nil
|
|
||||||
@created = nil
|
|
||||||
@group = nil
|
@group = nil
|
||||||
@host = nil
|
@host = nil
|
||||||
@last_edit = nil
|
|
||||||
@otp = nil
|
|
||||||
@port = nil
|
|
||||||
@protocol = nil
|
@protocol = nil
|
||||||
@url = nil
|
|
||||||
@user = nil
|
@user = nil
|
||||||
|
@port = nil
|
||||||
|
@otp = nil
|
||||||
|
@comment = nil
|
||||||
|
@created = nil
|
||||||
|
@last_edit = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return data on url format
|
||||||
|
# @return [String] an url
|
||||||
|
def url
|
||||||
|
url = ''
|
||||||
|
url += "#{@protocol}://" if @protocol
|
||||||
|
url += @host
|
||||||
|
url += ":#{@port}" if @port
|
||||||
|
|
||||||
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty?
|
def empty?
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# MPW is a software to crypt and manage your passwords
|
||||||
|
# Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
|
||||||
#
|
#
|
||||||
# Copyright:: 2013, Adrien Waksberg
|
# 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.
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
# This program is distributed in the hope that it will be useful,
|
||||||
# or more contributor license agreements. See the NOTICE file
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# distributed with this work for additional information
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
# GNU General Public License for more details.
|
||||||
# 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
|
# You should have received a copy of the GNU General Public License
|
||||||
#
|
# along with this program; if not, write to the Free Software
|
||||||
# Unless required by applicable law or agreed to in writing,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# 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 'rubygems/package'
|
require 'rubygems/package'
|
||||||
require 'gpgme'
|
require 'gpgme'
|
||||||
|
@ -86,12 +84,14 @@ module MPW
|
||||||
Item.new(
|
Item.new(
|
||||||
id: d['id'],
|
id: d['id'],
|
||||||
group: d['group'],
|
group: d['group'],
|
||||||
|
host: d['host'],
|
||||||
|
protocol: d['protocol'],
|
||||||
user: d['user'],
|
user: d['user'],
|
||||||
url: d['url'],
|
port: d['port'],
|
||||||
otp: @otp_keys.key?(d['id']),
|
otp: @otp_keys.key?(d['id']),
|
||||||
comment: d['comment'],
|
comment: d['comment'],
|
||||||
last_edit: d['last_edit'],
|
last_edit: d['last_edit'],
|
||||||
created: d['created']
|
created: d['created'],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -114,11 +114,13 @@ module MPW
|
||||||
item.id => {
|
item.id => {
|
||||||
'id' => item.id,
|
'id' => item.id,
|
||||||
'group' => item.group,
|
'group' => item.group,
|
||||||
|
'host' => item.host,
|
||||||
|
'protocol' => item.protocol,
|
||||||
'user' => item.user,
|
'user' => item.user,
|
||||||
'url' => item.url,
|
'port' => item.port,
|
||||||
'comment' => item.comment,
|
'comment' => item.comment,
|
||||||
'last_edit' => item.last_edit,
|
'last_edit' => item.last_edit,
|
||||||
'created' => item.created
|
'created' => item.created,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -270,7 +272,7 @@ module MPW
|
||||||
# @param id [String] the item id
|
# @param id [String] the item id
|
||||||
# @return [String] an otp code
|
# @return [String] an otp code
|
||||||
def get_otp_code(id)
|
def get_otp_code(id)
|
||||||
@otp_keys.key?(id) ? ROTP::TOTP.new(decrypt(@otp_keys[id])).now : 0
|
@otp_keys.key?(id) ? 0 : ROTP::TOTP.new(decrypt(@otp_keys[id])).now
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get remaining time before expire otp code
|
# Get remaining time before expire otp code
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
@ -18,11 +20,11 @@ Gem::Specification.new do |spec|
|
||||||
|
|
||||||
spec.required_ruby_version = '>= 2.1'
|
spec.required_ruby_version = '>= 2.1'
|
||||||
|
|
||||||
spec.add_dependency 'i18n', '~> 0.9', '>= 0.9.1'
|
spec.add_dependency 'i18n', '~> 0.7', '>= 0.7.0'
|
||||||
spec.add_dependency 'gpgme', '~> 2.0', '>= 2.0.14'
|
spec.add_dependency 'gpgme', '~> 2.0', '>= 2.0.12'
|
||||||
spec.add_dependency 'highline', '~> 1.7', '>= 1.7.8'
|
spec.add_dependency 'highline', '~> 1.7', '>= 1.7.8'
|
||||||
spec.add_dependency 'locale', '~> 2.1', '>= 2.1.2'
|
spec.add_dependency 'locale', '~> 2.1', '>= 2.1.2'
|
||||||
spec.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
|
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.3', '>= 3.3.0'
|
spec.add_dependency 'rotp', '~> 3.1', '>= 3.1.0'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
---
|
---
|
||||||
# <%= I18n.t('form.add_item.url') %>
|
host: <%= options[:host] %> # <%= I18n.t('form.add_item.host') %>
|
||||||
url: <%= options[:url] %>
|
user: <%= options[:user] %> # <%= I18n.t('form.add_item.login') %>
|
||||||
# <%= I18n.t('form.add_item.login') %>
|
group: <%= options[:group] %> # <%= I18n.t('form.add_item.group') %>
|
||||||
user: <%= options[:user] %>
|
protocol: <%= options[:protocol] %> # <%= I18n.t('form.add_item.protocol') %><% unless password %>
|
||||||
# <%= I18n.t('form.add_item.group') %>
|
password: # <%= I18n.t('form.add_item.password') %><% end %>
|
||||||
group: <%= options[:group] %><% unless password %>
|
port: <%= options[:port] %> # <%= I18n.t('form.add_item.port') %>
|
||||||
# <%= I18n.t('form.add_item.password') %>
|
comment: <%= options[:comment] %> # <%= I18n.t('form.add_item.comment') %>
|
||||||
password:<% end %>
|
otp_key: <%= options[:otp] %> # <%= I18n.t('form.add_item.otp_key') %>
|
||||||
# <%= I18n.t('form.add_item.comment') %>
|
|
||||||
comment: <%= options[:comment] %>
|
|
||||||
# <%= I18n.t('form.add_item.otp_key') %>
|
|
||||||
otp_key: <%= options[:otp] %>
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
---
|
---
|
||||||
# <%= I18n.t('form.update_item.url') %>
|
# <%= I18n.t('form.update_item.host') %>
|
||||||
host: <% if options[:url] %><%= options[:url] %><% else %><%= item.url %><% end %>
|
host: <% if options[:host] %><%= options[:host] %><% else %><%= item.host %><% end %>
|
||||||
# <%= I18n.t('form.update_item.login') %>
|
# <%= I18n.t('form.update_item.login') %>
|
||||||
user: <% if options[:user] %><%= options[:user] %><% else %><%= item.user %><% end %><% unless password %>
|
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: <% end %>
|
password: <% end %>
|
||||||
# <%= I18n.t('form.update_item.group') %>
|
# <%= I18n.t('form.update_item.group') %>
|
||||||
group: <% if options[:group] %><%= options[:group] %><% else %><%= item.group %><% end %>
|
group: <% if options[:group] %><%= options[:group] %><% else %><%= item.group %><% end %>
|
||||||
|
# <%= I18n.t('form.update_item.protocol') %>
|
||||||
|
protocol: <% if options[:protocol] %><%= options[:protocol] %><% else %><%= item.protocol %><% end %>
|
||||||
|
# <%= I18n.t('form.update_item.port') %>
|
||||||
|
port: <% if options[:port] %><%= options[:port] %><% else %><%= item.port %><% end %>
|
||||||
# <%= I18n.t('form.update_item.otp_key') %>
|
# <%= I18n.t('form.update_item.otp_key') %>
|
||||||
otp_key: <% if options[:otp_key] %><%= options[:otp_key] %><% end %>
|
otp_key: <% if options[:otp_key] %><%= options[:otp_key] %><% end %>
|
||||||
# <%= I18n.t('form.update_item.comment') %>
|
# <%= I18n.t('form.update_item.comment') %>
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
---
|
---
|
||||||
1:
|
1:
|
||||||
url: https://fric.com
|
host: fric.com
|
||||||
user: 230403
|
user: 230403
|
||||||
group: Bank
|
group: Bank
|
||||||
password: 5XdiTQOubRDw9B0aJoMlcEyL
|
password: 5XdiTQOubRDw9B0aJoMlcEyL
|
||||||
|
protocol: https
|
||||||
|
port:
|
||||||
otp_key: 330223432
|
otp_key: 330223432
|
||||||
comment: I love my bank
|
comment: I love my bank
|
||||||
2:
|
2:
|
||||||
url: https://assurance.com:443
|
|
||||||
user: user_2132
|
|
||||||
host: assurance.com
|
host: assurance.com
|
||||||
|
user: user_2132
|
||||||
group: Assurance
|
group: Assurance
|
||||||
password: DMyK6B3v4bWO52VzU7aTHIem
|
password: DMyK6B3v4bWO52VzU7aTHIem
|
||||||
|
protocol: https
|
||||||
|
port: 443
|
||||||
otp_key:
|
otp_key:
|
||||||
comment:
|
comment:
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
add:
|
add:
|
||||||
url: 'https://example.com:8080'
|
|
||||||
group: 'Bank'
|
group: 'Bank'
|
||||||
host: 'example.com'
|
host: 'example.com'
|
||||||
protocol: 'https'
|
protocol: 'https'
|
||||||
|
@ -10,7 +9,6 @@ add:
|
||||||
|
|
||||||
import:
|
import:
|
||||||
id: 'TEST-ID-XXXXX'
|
id: 'TEST-ID-XXXXX'
|
||||||
url: 'https://gogole.com:8081/toto'
|
|
||||||
group: 'Cloud'
|
group: 'Cloud'
|
||||||
host: 'gogole.com'
|
host: 'gogole.com'
|
||||||
protocol: 'https'
|
protocol: 'https'
|
||||||
|
@ -21,7 +19,6 @@ import:
|
||||||
created: 1386752948
|
created: 1386752948
|
||||||
|
|
||||||
update:
|
update:
|
||||||
url: 'ssh://example2.com:2222'
|
|
||||||
group: 'Assurance'
|
group: 'Assurance'
|
||||||
host: 'example2.com'
|
host: 'example2.com'
|
||||||
protocol: 'ssh'
|
protocol: 'ssh'
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
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
|
|
|
@ -1,3 +0,0 @@
|
||||||
"Group","Title","Username","Password","URL","Notes"
|
|
||||||
"Racine","Bank","123456","ywcExJW8qmBVTSyi","http://bank.com/login","My little bank"
|
|
||||||
"Racine/Cloud","GAFAM","wesh","superpassword","localhost.local",""
|
|
|
@ -1,35 +0,0 @@
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'gpgme'
|
require 'gpgme'
|
||||||
|
|
||||||
|
|
107
test/test_cli.rb
107
test/test_cli.rb
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'i18n'
|
require 'i18n'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
|
@ -17,11 +19,7 @@ class TestConfig < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_00_init_config
|
def test_00_init_config
|
||||||
output = %x(
|
output = %x(echo "#{@password}\n#{@password}" | mpw config --init #{@gpg_key})
|
||||||
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_config.valid'), output)
|
||||||
assert_match(I18n.t('form.setup_gpg_key.valid'), output)
|
assert_match(I18n.t('form.setup_gpg_key.valid'), output)
|
||||||
end
|
end
|
||||||
|
@ -31,16 +29,19 @@ class TestConfig < Test::Unit::TestCase
|
||||||
|
|
||||||
output = %x(
|
output = %x(
|
||||||
echo #{@password} | mpw add \
|
echo #{@password} | mpw add \
|
||||||
--url #{data['url']} \
|
--host #{data['host']} \
|
||||||
|
--port #{data['port']} \
|
||||||
|
--protocol #{data['protocol']} \
|
||||||
--user #{data['user']} \
|
--user #{data['user']} \
|
||||||
--comment '#{data['comment']}' \
|
--comment '#{data['comment']}' \
|
||||||
--group #{data['group']} \
|
--group #{data['group']} \
|
||||||
--random \
|
--random
|
||||||
2>/dev/null
|
|
||||||
)
|
)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.add_item.valid'), output)
|
assert_match(I18n.t('form.add_item.valid'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list 2>/dev/null)
|
output = %x(echo #{@password} | mpw list)
|
||||||
|
puts output
|
||||||
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
||||||
assert_match(data['user'], output)
|
assert_match(data['user'], output)
|
||||||
assert_match(data['comment'], output)
|
assert_match(data['comment'], output)
|
||||||
|
@ -50,19 +51,19 @@ class TestConfig < Test::Unit::TestCase
|
||||||
def test_02_search
|
def test_02_search
|
||||||
data = @fixtures['add']
|
data = @fixtures['add']
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list --group #{data['group']} 2>/dev/null)
|
output = %x(echo #{@password} | mpw list --group #{data['group']})
|
||||||
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list --pattern #{data['host']} 2>/dev/null)
|
output = %x(echo #{@password} | mpw list --pattern #{data['host']})
|
||||||
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list --pattern #{data['comment']} 2>/dev/null)
|
output = %x(echo #{@password} | mpw list --pattern #{data['comment']})
|
||||||
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list --group R1Pmfbp626TFpjlr 2>/dev/null)
|
output = %x(echo #{@password} | mpw list --group R1Pmfbp626TFpjlr)
|
||||||
assert_match(I18n.t('display.nothing'), output)
|
assert_match(I18n.t('display.nothing'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list --pattern h1IfnKqamaGM9oEX 2>/dev/null)
|
output = %x(echo #{@password} | mpw list --pattern h1IfnKqamaGM9oEX)
|
||||||
assert_match(I18n.t('display.nothing'), output)
|
assert_match(I18n.t('display.nothing'), output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,15 +73,18 @@ class TestConfig < Test::Unit::TestCase
|
||||||
output = %x(
|
output = %x(
|
||||||
echo #{@password} | mpw update \
|
echo #{@password} | mpw update \
|
||||||
-p #{@fixtures['add']['host']} \
|
-p #{@fixtures['add']['host']} \
|
||||||
--url #{data['url']} \
|
--host #{data['host']} \
|
||||||
|
--port #{data['port']} \
|
||||||
|
--protocol #{data['protocol']} \
|
||||||
--user #{data['user']} \
|
--user #{data['user']} \
|
||||||
--comment '#{data['comment']}' \
|
--comment '#{data['comment']}' \
|
||||||
--new-group #{data['group']} \
|
--new-group #{data['group']}
|
||||||
2>/dev/null
|
|
||||||
)
|
)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.update_item.valid'), output)
|
assert_match(I18n.t('form.update_item.valid'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list 2>/dev/null)
|
output = %x(echo #{@password} | mpw list)
|
||||||
|
puts output
|
||||||
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
assert_match(%r{#{data['protocol']}://.+#{data['host']}.+:#{data['port']}}, output)
|
||||||
assert_match(data['user'], output)
|
assert_match(data['user'], output)
|
||||||
assert_match(data['comment'], output)
|
assert_match(data['comment'], output)
|
||||||
|
@ -88,14 +92,12 @@ class TestConfig < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_04_delete_item
|
def test_04_delete_item
|
||||||
output = %x(
|
output = %x(echo "#{@password}\ny" | mpw delete -p #{@fixtures['update']['host']})
|
||||||
echo "#{@password}\ny" | mpw delete \
|
puts output
|
||||||
-p #{@fixtures['update']['host']} \
|
|
||||||
2>/dev/null
|
|
||||||
)
|
|
||||||
assert_match(I18n.t('form.delete_item.valid'), output)
|
assert_match(I18n.t('form.delete_item.valid'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw list 2>/dev/null)
|
output = %x(echo #{@password} | mpw list)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('display.nothing'), output)
|
assert_match(I18n.t('display.nothing'), output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,10 +105,10 @@ class TestConfig < Test::Unit::TestCase
|
||||||
file_import = './test/files/fixtures-import.yml'
|
file_import = './test/files/fixtures-import.yml'
|
||||||
file_export = '/tmp/test-mpw.yml'
|
file_export = '/tmp/test-mpw.yml'
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw import --file #{file_import} 2>/dev/null)
|
output = %x(echo #{@password} | mpw import --file #{file_import})
|
||||||
assert_match(I18n.t('form.import.valid', file: file_import), output)
|
assert_match(I18n.t('form.import.valid', file: file_import), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw export --file #{file_export} 2>/dev/null)
|
output = %x(echo #{@password} | mpw export --file #{file_export})
|
||||||
assert_match(I18n.t('form.export.valid', file: file_export), output)
|
assert_match(I18n.t('form.export.valid', file: file_export), output)
|
||||||
assert(File.exist?(file_export))
|
assert(File.exist?(file_export))
|
||||||
assert_equal(YAML.load_file(file_export).length, 2)
|
assert_equal(YAML.load_file(file_export).length, 2)
|
||||||
|
@ -115,80 +117,84 @@ class TestConfig < Test::Unit::TestCase
|
||||||
error = true
|
error = true
|
||||||
|
|
||||||
YAML.load_file(file_export).each_value do |export|
|
YAML.load_file(file_export).each_value do |export|
|
||||||
next if import['url'] != export['url']
|
next if import['host'] != export['host']
|
||||||
|
|
||||||
%w[user group password protocol port otp_key comment].each do |key|
|
%w[user group password protocol port otp_key comment].each do |key|
|
||||||
assert_equal(import[key].to_s, export[key].to_s)
|
assert_equal(import[key].to_s, export[key].to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
error = false
|
error = false
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(!error)
|
assert(!error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_06_copy
|
def test_06_copy
|
||||||
data = YAML.load_file('./test/files/fixtures-import.yml')[2]
|
data = YAML.load_file('./test/files/fixtures-import.yml')[1]
|
||||||
|
|
||||||
output = %x(
|
output = %x(
|
||||||
echo "#{@password}\np\nq" | mpw copy \
|
echo "#{@password}\np\nq" | mpw copy \
|
||||||
--disable-clipboard \
|
--disable-clipboard \
|
||||||
-p #{data['host']} \
|
-p #{data['host']}
|
||||||
2>/dev/null
|
|
||||||
)
|
)
|
||||||
|
puts output
|
||||||
assert_match(data['password'], output)
|
assert_match(data['password'], output)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_07_setup_wallet
|
def test_07_setup_wallet
|
||||||
|
path = '/tmp/'
|
||||||
gpg_key = 'test2@example.com'
|
gpg_key = 'test2@example.com'
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw wallet --add-gpg-key #{gpg_key} 2>/dev/null)
|
output = %x(echo #{@password} | mpw wallet --add-gpg-key #{gpg_key})
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.add_key.valid'), output)
|
assert_match(I18n.t('form.add_key.valid'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw wallet --list-keys 2>/dev/null)
|
output = %x(echo #{@password} | mpw wallet --list-keys)
|
||||||
|
puts output
|
||||||
assert_match("| #{@gpg_key}", output)
|
assert_match("| #{@gpg_key}", output)
|
||||||
assert_match("| #{gpg_key}", output)
|
assert_match("| #{gpg_key}", output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw wallet --delete-gpg-key #{gpg_key} 2>/dev/null)
|
output = %x(echo #{@password} | mpw wallet --delete-gpg-key #{gpg_key})
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.delete_key.valid'), output)
|
assert_match(I18n.t('form.delete_key.valid'), output)
|
||||||
|
|
||||||
output = %x(echo #{@password} | mpw wallet --list-keys 2>/dev/null)
|
output = %x(echo #{@password} | mpw wallet --list-keys)
|
||||||
|
puts output
|
||||||
assert_match("| #{@gpg_key}", output)
|
assert_match("| #{@gpg_key}", output)
|
||||||
assert_no_match(/\| #{gpg_key}/, output)
|
assert_no_match(/\| #{gpg_key}/, output)
|
||||||
|
|
||||||
output = %x(mpw wallet)
|
output = %x(mpw wallet)
|
||||||
|
puts output
|
||||||
assert_match('| default', output)
|
assert_match('| default', output)
|
||||||
|
|
||||||
output = %x(mpw wallet --path '.')
|
output = %x(mpw wallet --path #{path})
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.set_wallet_path.valid'), output)
|
assert_match(I18n.t('form.set_wallet_path.valid'), output)
|
||||||
|
|
||||||
output = %x(mpw config)
|
output = %x(mpw config)
|
||||||
assert_match(%r{path_wallet_default.+\| #{Dir.pwd}/default.mpw}, output)
|
puts output
|
||||||
assert(File.exist?("#{Dir.pwd}/default.mpw"))
|
assert_match(%r{path_wallet_default.+\| #{path}/default.mpw}, output)
|
||||||
|
assert(File.exist?("#{path}/default.mpw"))
|
||||||
output = %x(mpw wallet)
|
|
||||||
assert_match('default', output)
|
|
||||||
|
|
||||||
output = %x(mpw wallet --default-path)
|
output = %x(mpw wallet --default-path)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.set_wallet_path.valid'), output)
|
assert_match(I18n.t('form.set_wallet_path.valid'), output)
|
||||||
|
|
||||||
output = %x(mpw config)
|
output = %x(mpw config)
|
||||||
|
puts output
|
||||||
assert_no_match(/path_wallet_default/, output)
|
assert_no_match(/path_wallet_default/, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_08_setup_config
|
def test_08_setup_config
|
||||||
gpg_key = 'test2@example.com'
|
gpg_key = 'user@example2.com'
|
||||||
gpg_exe = '/usr/bin/gpg2'
|
gpg_exe = '/usr/bin/gpg2'
|
||||||
wallet_dir = '/tmp'
|
wallet_dir = '/tmp/mpw'
|
||||||
length = 24
|
length = 24
|
||||||
wallet = 'work'
|
wallet = 'work'
|
||||||
|
|
||||||
output = %x(
|
output = %x(
|
||||||
mpw config \
|
mpw config \
|
||||||
--gpg-exe #{gpg_exe} \
|
--gpg-exe #{gpg_exe} \
|
||||||
--key #{gpg_key} \
|
|
||||||
--enable-pinmode \
|
--enable-pinmode \
|
||||||
--disable-alpha \
|
--disable-alpha \
|
||||||
--disable-special-chars \
|
--disable-special-chars \
|
||||||
|
@ -197,10 +203,12 @@ class TestConfig < Test::Unit::TestCase
|
||||||
--wallet-dir #{wallet_dir} \
|
--wallet-dir #{wallet_dir} \
|
||||||
--default-wallet #{wallet}
|
--default-wallet #{wallet}
|
||||||
)
|
)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.set_config.valid'), output)
|
assert_match(I18n.t('form.set_config.valid'), output)
|
||||||
|
|
||||||
output = %x(mpw config)
|
output = %x(mpw config)
|
||||||
assert_match(/gpg_key.+\| #{gpg_key}/, output)
|
puts output
|
||||||
|
assert_match(/gpg_key.+\| #{@gpg_key}/, output)
|
||||||
assert_match(/gpg_exe.+\| #{gpg_exe}/, output)
|
assert_match(/gpg_exe.+\| #{gpg_exe}/, output)
|
||||||
assert_match(/pinmode.+\| true/, output)
|
assert_match(/pinmode.+\| true/, output)
|
||||||
assert_match(/default_wallet.+\| #{wallet}/, output)
|
assert_match(/default_wallet.+\| #{wallet}/, output)
|
||||||
|
@ -212,17 +220,18 @@ class TestConfig < Test::Unit::TestCase
|
||||||
|
|
||||||
output = %x(
|
output = %x(
|
||||||
mpw config \
|
mpw config \
|
||||||
--gpg-exe '' \
|
--key #{gpg_key} \
|
||||||
--key #{@gpg_key} \
|
|
||||||
--alpha \
|
--alpha \
|
||||||
--special-chars \
|
--special-chars \
|
||||||
--numeric \
|
--numeric \
|
||||||
--disable-pinmode
|
--disable-pinmode
|
||||||
)
|
)
|
||||||
|
puts output
|
||||||
assert_match(I18n.t('form.set_config.valid'), output)
|
assert_match(I18n.t('form.set_config.valid'), output)
|
||||||
|
|
||||||
output = %x(mpw config)
|
output = %x(mpw config)
|
||||||
assert_match(/gpg_key.+\| #{@gpg_key}/, output)
|
puts output
|
||||||
|
assert_match(/gpg_key.+\| #{gpg_key}/, output)
|
||||||
assert_match(/pinmode.+\| false/, output)
|
assert_match(/pinmode.+\| false/, output)
|
||||||
%w[numeric alpha special].each do |k|
|
%w[numeric alpha special].each do |k|
|
||||||
assert_match(/password_#{k}.+\| true/, output)
|
assert_match(/password_#{k}.+\| true/, output)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'mpw/config'
|
require 'mpw/config'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'locale'
|
require 'locale'
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
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
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'mpw/item'
|
require 'mpw/item'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
@ -21,8 +23,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
def test_01_add
|
def test_01_add
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['add']['group'],
|
group: @fixtures['add']['group'],
|
||||||
|
host: @fixtures['add']['host'],
|
||||||
|
protocol: @fixtures['add']['protocol'],
|
||||||
user: @fixtures['add']['user'],
|
user: @fixtures['add']['user'],
|
||||||
url: @fixtures['add']['url'],
|
port: @fixtures['add']['port'],
|
||||||
comment: @fixtures['add']['comment']
|
comment: @fixtures['add']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +35,6 @@ class TestItem < Test::Unit::TestCase
|
||||||
assert(!item.nil?)
|
assert(!item.nil?)
|
||||||
assert(!item.empty?)
|
assert(!item.empty?)
|
||||||
|
|
||||||
assert_equal(@fixtures['add']['url'], item.url)
|
|
||||||
assert_equal(@fixtures['add']['group'], item.group)
|
assert_equal(@fixtures['add']['group'], item.group)
|
||||||
assert_equal(@fixtures['add']['host'], item.host)
|
assert_equal(@fixtures['add']['host'], item.host)
|
||||||
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
||||||
|
@ -44,8 +47,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
data = {
|
data = {
|
||||||
id: @fixtures['import']['id'],
|
id: @fixtures['import']['id'],
|
||||||
group: @fixtures['import']['group'],
|
group: @fixtures['import']['group'],
|
||||||
|
host: @fixtures['import']['host'],
|
||||||
|
protocol: @fixtures['import']['protocol'],
|
||||||
user: @fixtures['import']['user'],
|
user: @fixtures['import']['user'],
|
||||||
url: @fixtures['import']['url'],
|
port: @fixtures['import']['port'],
|
||||||
comment: @fixtures['import']['comment'],
|
comment: @fixtures['import']['comment'],
|
||||||
created: @fixtures['import']['created']
|
created: @fixtures['import']['created']
|
||||||
}
|
}
|
||||||
|
@ -56,7 +61,6 @@ class TestItem < Test::Unit::TestCase
|
||||||
assert(!item.empty?)
|
assert(!item.empty?)
|
||||||
|
|
||||||
assert_equal(@fixtures['import']['id'], item.id)
|
assert_equal(@fixtures['import']['id'], item.id)
|
||||||
assert_equal(@fixtures['import']['url'], item.url)
|
|
||||||
assert_equal(@fixtures['import']['group'], item.group)
|
assert_equal(@fixtures['import']['group'], item.group)
|
||||||
assert_equal(@fixtures['import']['host'], item.host)
|
assert_equal(@fixtures['import']['host'], item.host)
|
||||||
assert_equal(@fixtures['import']['protocol'], item.protocol)
|
assert_equal(@fixtures['import']['protocol'], item.protocol)
|
||||||
|
@ -69,8 +73,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
def test_03_update
|
def test_03_update
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['add']['group'],
|
group: @fixtures['add']['group'],
|
||||||
|
host: @fixtures['add']['host'],
|
||||||
|
protocol: @fixtures['add']['protocol'],
|
||||||
user: @fixtures['add']['user'],
|
user: @fixtures['add']['user'],
|
||||||
url: @fixtures['add']['url'],
|
port: @fixtures['add']['port'],
|
||||||
comment: @fixtures['add']['comment']
|
comment: @fixtures['add']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +90,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['update']['group'],
|
group: @fixtures['update']['group'],
|
||||||
|
host: @fixtures['update']['host'],
|
||||||
|
protocol: @fixtures['update']['protocol'],
|
||||||
user: @fixtures['update']['user'],
|
user: @fixtures['update']['user'],
|
||||||
url: @fixtures['update']['url'],
|
port: @fixtures['update']['port'],
|
||||||
comment: @fixtures['update']['comment']
|
comment: @fixtures['update']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +102,6 @@ class TestItem < Test::Unit::TestCase
|
||||||
|
|
||||||
assert(!item.empty?)
|
assert(!item.empty?)
|
||||||
|
|
||||||
assert_equal(@fixtures['update']['url'], item.url)
|
|
||||||
assert_equal(@fixtures['update']['group'], item.group)
|
assert_equal(@fixtures['update']['group'], item.group)
|
||||||
assert_equal(@fixtures['update']['host'], item.host)
|
assert_equal(@fixtures['update']['host'], item.host)
|
||||||
assert_equal(@fixtures['update']['protocol'], item.protocol)
|
assert_equal(@fixtures['update']['protocol'], item.protocol)
|
||||||
|
@ -109,8 +116,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
def test_05_update_one_element
|
def test_05_update_one_element
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['add']['group'],
|
group: @fixtures['add']['group'],
|
||||||
|
host: @fixtures['add']['host'],
|
||||||
|
protocol: @fixtures['add']['protocol'],
|
||||||
user: @fixtures['add']['user'],
|
user: @fixtures['add']['user'],
|
||||||
url: @fixtures['add']['url'],
|
port: @fixtures['add']['port'],
|
||||||
comment: @fixtures['add']['comment']
|
comment: @fixtures['add']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +131,8 @@ class TestItem < Test::Unit::TestCase
|
||||||
last_edit = item.last_edit
|
last_edit = item.last_edit
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
item.update(comment: @fixtures['update']['comment'])
|
assert(item.update(comment: @fixtures['update']['comment']))
|
||||||
|
|
||||||
assert_equal(@fixtures['add']['url'], item.url)
|
|
||||||
assert_equal(@fixtures['add']['group'], item.group)
|
assert_equal(@fixtures['add']['group'], item.group)
|
||||||
assert_equal(@fixtures['add']['host'], item.host)
|
assert_equal(@fixtures['add']['host'], item.host)
|
||||||
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
assert_equal(@fixtures['add']['protocol'], item.protocol)
|
||||||
|
@ -138,8 +146,10 @@ class TestItem < Test::Unit::TestCase
|
||||||
def test_05_delete
|
def test_05_delete
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['add']['group'],
|
group: @fixtures['add']['group'],
|
||||||
|
host: @fixtures['add']['host'],
|
||||||
|
protocol: @fixtures['add']['protocol'],
|
||||||
user: @fixtures['add']['user'],
|
user: @fixtures['add']['user'],
|
||||||
url: @fixtures['add']['url'],
|
port: @fixtures['add']['port'],
|
||||||
comment: @fixtures['add']['comment']
|
comment: @fixtures['add']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +163,6 @@ class TestItem < Test::Unit::TestCase
|
||||||
assert(item.empty?)
|
assert(item.empty?)
|
||||||
|
|
||||||
assert_equal(nil, item.id)
|
assert_equal(nil, item.id)
|
||||||
assert_equal(nil, item.url)
|
|
||||||
assert_equal(nil, item.group)
|
assert_equal(nil, item.group)
|
||||||
assert_equal(nil, item.host)
|
assert_equal(nil, item.host)
|
||||||
assert_equal(nil, item.protocol)
|
assert_equal(nil, item.protocol)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'mpw/mpw'
|
require 'mpw/mpw'
|
||||||
require 'mpw/item'
|
require 'mpw/item'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
@ -31,8 +33,10 @@ class TestMPW < Test::Unit::TestCase
|
||||||
def test_02_add_item
|
def test_02_add_item
|
||||||
data = {
|
data = {
|
||||||
group: @fixtures['add']['group'],
|
group: @fixtures['add']['group'],
|
||||||
|
host: @fixtures['add']['host'],
|
||||||
|
protocol: @fixtures['add']['protocol'],
|
||||||
user: @fixtures['add']['user'],
|
user: @fixtures['add']['user'],
|
||||||
url: @fixtures['add']['url'],
|
port: @fixtures['add']['port'],
|
||||||
comment: @fixtures['add']['comment']
|
comment: @fixtures['add']['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +93,10 @@ class TestMPW < Test::Unit::TestCase
|
||||||
@fixtures.each_value do |v|
|
@fixtures.each_value do |v|
|
||||||
data = {
|
data = {
|
||||||
group: v['group'],
|
group: v['group'],
|
||||||
|
host: v['host'],
|
||||||
|
protocol: v['protocol'],
|
||||||
user: v['user'],
|
user: v['user'],
|
||||||
url: v['url'],
|
port: v['port'],
|
||||||
comment: v['comment']
|
comment: v['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue