pax_global_header00006660000000000000000000000064132431532440014513gustar00rootroot0000000000000052 comment=d2c6a49cd752772a4d1f071254003e85cb1a3beb gopass-1.2.0/000077500000000000000000000000001324315324400130075ustar00rootroot00000000000000gopass-1.2.0/.gitignore000066400000000000000000000000101324315324400147660ustar00rootroot00000000000000/gopass gopass-1.2.0/.travis.yml000066400000000000000000000003341324315324400151200ustar00rootroot00000000000000language: go install: - make get-deps - go get -u github.com/golang/lint/golint - go get -u github.com/mattn/goveralls script: - make - $GOPATH/bin/goveralls -service=travis-ci notifications: email: false gopass-1.2.0/COPYING000066400000000000000000001046211324315324400140460ustar00rootroot00000000000000Copyright (C) 2015-2018 Alexandre Viau GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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. But first, please read . gopass-1.2.0/Makefile000066400000000000000000000025511324315324400144520ustar00rootroot00000000000000# Copyright (C) 2017 Alexandre Viau # # This file is part of gopass. # # gopass 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 3 of the License, or # (at your option) any later version. # # gopass 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 gopass. If not, see . all: fmt gopass test vet lint SOURCEDIR=. SOURCES := $(shell find $(SOURCEDIR) -name '*.go') Makefile GO_IMPORT_PATH := github.com/aviau/gopass gopass: $(SOURCES) go build -v -o gopass ${GO_IMPORT_PATH}/cmd/gopass .PHONY: test test: go test -v ${GO_IMPORT_PATH}/... .PHONY: install install: go install ${GO_IMPORT_PATH}/... .PHONY: clean clean: rm -rf gopass .PHONY: vet vet: install go get github.com/stretchr/testify/assert go vet -v ${GO_IMPORT_PATH}/... .PHONY: lint lint: golint ${GO_IMPORT_PATH}/... .PHONY: fmt fmt: go fmt ${GO_IMPORT_PATH}/... .PHONY: get-deps get-deps: go get -t ${GO_IMPORT_PATH}/... gopass-1.2.0/README.md000066400000000000000000000100121324315324400142600ustar00rootroot00000000000000# gopass [![Build Status](https://travis-ci.org/aviau/gopass.svg?branch=master)](https://travis-ci.org/aviau/gopass) [![Coverage Status](https://coveralls.io/repos/github/aviau/gopass/badge.svg?branch=master)](https://coveralls.io/github/aviau/gopass?branch=master) [![GoDoc](https://godoc.org/github.com/aviau/gopass?status.svg)](http://godoc.org/github.com/aviau/gopass) [Pass](http://www.passwordstore.org/) implementation in Go. Password management should be simple and follow Unix philosophy. With ``gopass``, each password lives inside of a ``gpg`` encrypted file whose filename is the title of the website or resource that requires the password. These encrypted files may be organized into meaningful folder hierarchies, copied from computer to computer, and, in general, manipulated using standard command line file management utilities. ``gopass`` makes managing these individual password files extremely easy. All passwords live in ``~/.password-store``, and gopass provides some nice commands for adding, editing, generating, and retrieving passwords. It's capable of temporarily putting passwords on your clipboard and tracking password changes using git. ## Install gopass is available in official Debian repositories. Install it with ``apt-get install gopass``. ## Project Status This section was just added so that I could get an idea of where I am at. ### ``gopass init`` - [X] Creates a folder and a .gpg-id file - [X] Support ``--path`` option - [ ] Re-encryption functionality - [ ] Should output: ``Password store initialized for [gpg-id].`` - [ ] ``--clone `` allows to init from an existing repo ### ``gopass insert`` - [X] ``gopass insert test.com`` prompts for a password and creates a test.com.gpg file - [X] Multi-line support - [X] Create a git commit - [X] Prompt before overwriting an existing password, unless --force or -f is specified. - [ ] When inserting in a folder with a .gpg-id file, insert should use the .gpg-id file's key ### ``gopass show`` - [X] ``gopass show test.com`` will display the content of test.com.gpg - [X] ``--clip, -c`` copies the first line to the clipboard - [ ] ``--clip, -c`` clears after a while - [ ] ``--password``, and ``--username`` options. Accepted format: ``` login: url: ``` ### ``gopass connect`` (or ``ssh``) This new command should connect to a server using an encrypted rsa key. ### ``gopass ls`` - [X] ``gopass ls`` shows the content of the password store with ``tree`` - [X] ``gopass`` invokes ``gopass ls`` by default - [X] ``gopass ls subfolder`` calls tree on the subfolder only - [ ] Hide .gpg at the end of each entry - [X] First output line should be ``Password Store`` ### ``gopass rm`` - [X] ``gopass rm test.com`` removes the test.com.gpg file - [X] ``gopass remove`` and ``gopass delete`` aliases - [X] ``gopass rm -r folder`` (or ``--recursive``) will remove a folder and all of it's content (not interactive!) - [X] Ask for confirmation ### ``gopass find`` - [X] ``gopass find python.org test`` will show a tree with password entries that match python.org or test - [X] Accepts one or many search terms ### ``gopass cp`` - [X] ``gopass cp old-path new-pah`` copies a password to a new path - [X] Dont overwrite ### ``gopass mv`` - [X] ``gopass mv old-path new-path`` moves a password to a new path - [X] Dont overwrite ### ``gopass git`` - [X] Pass commands to git - [ ] ``gopass git init`` should behave differently with an existing password store - [ ] Add tests ### ``gopass edit`` - [X] ``gopass edit test.com`` will open a text editor and let you edit the password ### ``gopass grep`` - [X] ``gopass grep searchstring`` will search for the given string inside all of the encrypted passwords ### ``gopass generate`` - [X] ``gopass generate [pass-name] [pass-length]`` Genrates a new password using of length pass-length and inserts it into pass-name. - [X] ``--no-symbols, -n`` - [ ] ``--clip, -c`` - [ ] ``--in-place, -i`` - [X] ``--force, -f`` - [X] Prompt before overwriting an existing password, unless --force or -f is specified. gopass-1.2.0/bash_completion.d/000077500000000000000000000000001324315324400163775ustar00rootroot00000000000000gopass-1.2.0/bash_completion.d/gopass000066400000000000000000000067751324315324400176350ustar00rootroot00000000000000# Copyright (C) 2012 - 2014 Jason A. Donenfeld and # Brian Mattern . All Rights Reserved. # This file is licensed under the GPLv2+. # completion file for bash _gopass_complete_entries () { prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store/}" suffix=".gpg" autoexpand=${1:-0} local IFS=$'\n' local items=($(compgen -f $prefix$cur)) for item in ${items[@]}; do [[ $item =~ /\.[^/]*$ ]] && continue # if there is a unique match, and it is a directory with one entry # autocomplete the subentry as well (recursively) if [[ ${#items[@]} -eq 1 && $autoexpand -eq 1 ]]; then while [[ -d $item ]]; do local subitems=($(compgen -f "$item/")) local filtereditems=( ) for item2 in "${subitems[@]}"; do [[ $item2 =~ /\.[^/]*$ ]] && continue filtereditems+=( "$item2" ) done if [[ ${#filtereditems[@]} -eq 1 ]]; then item="${filtereditems[0]}" else break fi done fi # append / to directories [[ -d $item ]] && item="$item/" item="${item%$suffix}" COMPREPLY+=("${item#$prefix}") done } _gopass_complete_folders () { prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store/}" local IFS=$'\n' local items=($(compgen -d $prefix$cur)) for item in ${items[@]}; do [[ $item == $prefix.* ]] && continue COMPREPLY+=("${item#$prefix}/") done } _gopass_complete_keys () { local IFS=$'\n' # Extract names and email addresses from gpg --list-keys local keys="$(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')" COMPREPLY+=($(compgen -W "${keys}" -- ${cur})) } _gopass() { COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" local commands="init ls find grep show insert generate edit rm mv cp git help version" if [[ $COMP_CWORD -gt 1 ]]; then local lastarg="${COMP_WORDS[$COMP_CWORD-1]}" COMPREPLY+=($(compgen -W "-h --help" -- ${cur})) case "${COMP_WORDS[1]}" in init) if [[ $lastarg == "-p" || $lastarg == "--path" ]]; then _gopass_complete_folders else COMPREPLY+=($(compgen -W "-p --path" -- ${cur})) _gopass_complete_keys fi ;; ls|list|edit) _gopass_complete_entries ;; show|-*) _gopass_complete_entries 1 ;; insert) COMPREPLY+=($(compgen -W "-m --multiline -f --force" -- ${cur})) _gopass_complete_entries ;; generate) COMPREPLY+=($(compgen -W "-n --no-symbols -f --force" -- ${cur})) _gopass_complete_entries ;; cp|mv) COMPREPLY+=($(compgen -W "-f --force" -- ${cur})) _gopass_complete_entries ;; rm) COMPREPLY+=($(compgen -W "-r --recursive -f --force" -- ${cur})) _gopass_complete_entries ;; git) COMPREPLY+=($(compgen -W "init push pull config log reflog rebase status" -- ${cur})) ;; esac else _gopass_complete_entries 1 fi } complete -o filenames -o nospace -F _gopass gopass gopass-1.2.0/cmd/000077500000000000000000000000001324315324400135525ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/000077500000000000000000000000001324315324400150465ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/000077500000000000000000000000001324315324400166625ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/000077500000000000000000000000001324315324400174315ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/cli.go000066400000000000000000000062001324315324400205250ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "io" cmd_cp "github.com/aviau/gopass/cmd/gopass/internal/cli/command/cp" cmd_edit "github.com/aviau/gopass/cmd/gopass/internal/cli/command/edit" cmd_find "github.com/aviau/gopass/cmd/gopass/internal/cli/command/find" cmd_generate "github.com/aviau/gopass/cmd/gopass/internal/cli/command/generate" cmd_git "github.com/aviau/gopass/cmd/gopass/internal/cli/command/git" cmd_grep "github.com/aviau/gopass/cmd/gopass/internal/cli/command/grep" cmd_help "github.com/aviau/gopass/cmd/gopass/internal/cli/command/help" cmd_init "github.com/aviau/gopass/cmd/gopass/internal/cli/command/init" cmd_insert "github.com/aviau/gopass/cmd/gopass/internal/cli/command/insert" cmd_mv "github.com/aviau/gopass/cmd/gopass/internal/cli/command/mv" cmd_rm "github.com/aviau/gopass/cmd/gopass/internal/cli/command/rm" cmd_show "github.com/aviau/gopass/cmd/gopass/internal/cli/command/show" cmd_version "github.com/aviau/gopass/cmd/gopass/internal/cli/command/version" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //Run parses the arguments and executes the gopass CLI func Run(args []string, writerOutput io.Writer, writerError io.Writer, readerInput io.Reader) error { cfg := command.NewConfig(writerOutput, writerError, readerInput) return runCommand(cfg, args) } func runCommand(cfg command.Config, cmdAndArgs []string) error { cmd := "" if len(cmdAndArgs) > 0 { cmd = cmdAndArgs[0] } switch cmd { case "show": return cmd_show.ExecShow(cfg, cmdAndArgs[1:]) case "edit": return cmd_edit.ExecEdit(cfg, cmdAndArgs[1:]) case "insert", "add": return cmd_insert.ExecInsert(cfg, cmdAndArgs[1:]) case "find", "ls", "search", "list": return cmd_find.ExecFind(cfg, cmdAndArgs[1:]) case "": return cmd_find.ExecFind(cfg, cmdAndArgs) case "grep": return cmd_grep.ExecGrep(cfg, cmdAndArgs[1:]) case "cp", "copy": return cmd_cp.ExecCp(cfg, cmdAndArgs[1:]) case "mv", "rename": return cmd_mv.ExecMv(cfg, cmdAndArgs[1:]) case "rm", "remove", "delete": return cmd_rm.ExecRm(cfg, cmdAndArgs[1:]) case "generate": return cmd_generate.ExecGenerate(cfg, cmdAndArgs[1:]) case "git": return cmd_git.ExecGit(cfg, cmdAndArgs[1:]) case "help", "-h", "--help": return cmd_help.ExecHelp(cfg) case "init": return cmd_init.ExecInit(cfg, cmdAndArgs[1:]) case "version": return cmd_version.ExecVersion(cfg) default: return cmd_show.ExecShow(cfg, cmdAndArgs) } } gopass-1.2.0/cmd/gopass/internal/cli/cli_test.go000066400000000000000000000040271324315324400215710ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "bytes" "testing" "github.com/aviau/gopass" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" "github.com/aviau/gopass/internal/gopasstest" ) //testConfig is a fake command.Config, it does not use env variables. type testConfig struct { command.Config passwordStoreTest *gopasstest.PasswordStoreTest } func (cfg *testConfig) PasswordStore() *gopass.PasswordStore { return cfg.passwordStoreTest.PasswordStore } type cliTest struct { OutputWriter bytes.Buffer ErrorWriter bytes.Buffer t *testing.T passwordStoreTest *gopasstest.PasswordStoreTest } func newCliTest(t *testing.T) *cliTest { passwordStoreTest := gopasstest.NewPasswordStoreTest(t) cliTest := cliTest{ t: t, passwordStoreTest: passwordStoreTest, } return &cliTest } func (cliTest *cliTest) PasswordStore() *gopass.PasswordStore { return cliTest.passwordStoreTest.PasswordStore } func (cliTest *cliTest) Run(args []string) error { baseConfig := command.NewConfig(&cliTest.OutputWriter, &cliTest.ErrorWriter, nil) testConfig := testConfig{ Config: baseConfig, passwordStoreTest: cliTest.passwordStoreTest, } return runCommand(&testConfig, args) } func (cliTest *cliTest) Close() { cliTest.passwordStoreTest.Close() } gopass-1.2.0/cmd/gopass/internal/cli/command/000077500000000000000000000000001324315324400210475ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/command_config.go000066400000000000000000000020621324315324400243410ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package command import ( "io" "github.com/aviau/gopass" ) //Config contains everything that commands need to run. type Config interface { WriterOutput() io.Writer WriterError() io.Writer ReaderInput() io.Reader Editor() string PasswordStoreDir() string PasswordStore() *gopass.PasswordStore } gopass-1.2.0/cmd/gopass/internal/cli/command/cp/000077500000000000000000000000001324315324400214515ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/cp/cp.go000066400000000000000000000054561324315324400224140ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cp import ( "flag" "fmt" "io/ioutil" "path/filepath" "strings" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecCp runs the "cp" command. func ExecCp(cfg command.Config, args []string) error { var recursive, r bool var force, f bool var help, h bool fs := flag.NewFlagSet("cp", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass cp old-path new-path") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&recursive, "recursive", false, "") fs.BoolVar(&r, "r", false, "") fs.BoolVar(&force, "force", false, "") fs.BoolVar(&f, "f", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } recursive = recursive || r force = force || f store := cfg.PasswordStore() source := fs.Arg(0) dest := fs.Arg(1) if source == "" || dest == "" { return fmt.Errorf("received empty source or dest argument") } // If the dest ends with a '/', then it is a directory. if strings.HasSuffix(dest, "/") { _, sourceFile := filepath.Split(source) dest = filepath.Join(dest, sourceFile) } if sourceIsPassword, _ := store.ContainsPassword(source); sourceIsPassword { if destAlreadyExists, _ := store.ContainsPassword(dest); destAlreadyExists { if !force { return fmt.Errorf("destination \"%s\" already exists. Use -f to override", dest) } } if err := store.CopyPassword(source, dest); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Copied password from \"%s\" to \"%s\".\n", source, dest) return nil } if sourceIsDirectory, _ := store.ContainsDirectory(source); sourceIsDirectory { if !recursive { return fmt.Errorf("\"%s\" is a directory, use -r to copy recursively", source) } if err := store.CopyDirectory(source, dest); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Copied directory from \"%s\" to \"%s\".\n", source, dest) return nil } return fmt.Errorf("could not find source \"%s\" to copy", source) } gopass-1.2.0/cmd/gopass/internal/cli/command/default_config.go000066400000000000000000000044501324315324400243520ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package command import ( "io" "os" "path" "github.com/aviau/gopass" ) //DefaultConfig is a default Config implementation. type DefaultConfig struct { writerOutput io.Writer //The writer to use for output writerError io.Writer //The writer to use for errors readerInput io.Reader //The reader to use for input } //NewConfig creates a Config. func NewConfig(writerOutput, writerError io.Writer, readerInput io.Reader) *DefaultConfig { cfg := DefaultConfig{ writerOutput: writerOutput, writerError: writerError, readerInput: readerInput, } return &cfg } //WriterOutput returns the output writer func (cfg *DefaultConfig) WriterOutput() io.Writer { return cfg.writerOutput } //WriterError returns the output writer func (cfg *DefaultConfig) WriterError() io.Writer { return cfg.writerError } //ReaderInput returns the input reader func (cfg *DefaultConfig) ReaderInput() io.Reader { return cfg.readerInput } //PasswordStoreDir returns the password store directory. func (cfg *DefaultConfig) PasswordStoreDir() string { storePath := os.Getenv("PASSWORD_STORE_DIR") if storePath == "" { storePath = path.Join(os.Getenv("HOME"), ".password-store") } return storePath } //Editor returns the configured editor. func (cfg *DefaultConfig) Editor() string { editor := os.Getenv("EDITOR") if editor == "" { editor = "editor" } return editor } //PasswordStore returns the PasswordStore. func (cfg *DefaultConfig) PasswordStore() *gopass.PasswordStore { storePath := cfg.PasswordStoreDir() s := gopass.NewPasswordStore(storePath) return s } gopass-1.2.0/cmd/gopass/internal/cli/command/edit/000077500000000000000000000000001324315324400217745ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/edit/edit.go000066400000000000000000000042541324315324400232550ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package edit import ( "flag" "fmt" "io/ioutil" "os" "os/exec" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecEdit runs the "edit" command. func ExecEdit(cfg command.Config, args []string) error { var help, h bool fs := flag.NewFlagSet("edit", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass edit pass-name") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } store := cfg.PasswordStore() passname := fs.Arg(0) action := "inserted" password := "" if containsPasword, _ := store.ContainsPassword(passname); containsPasword { var err error password, err = store.GetPassword(passname) if err != nil { return err } action = "edited" } file, _ := ioutil.TempFile(os.TempDir(), "gopass") defer os.Remove(file.Name()) ioutil.WriteFile(file.Name(), []byte(password), 0600) editor := exec.Command(cfg.Editor(), file.Name()) editor.Stdout = cfg.WriterOutput() editor.Stderr = cfg.WriterError() editor.Stdin = cfg.ReaderInput() editor.Run() pwText, _ := ioutil.ReadFile(file.Name()) password = string(pwText) if err := store.InsertPassword(passname, password); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Succesfully %s password \"%s\".\n", action, passname) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/find/000077500000000000000000000000001324315324400217675ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/find/find.go000066400000000000000000000033361324315324400232430ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package find import ( "flag" "fmt" "io/ioutil" "os/exec" "strings" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecFind runs the "find" command. func ExecFind(cfg command.Config, args []string) error { var help, h bool fs := flag.NewFlagSet("find", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass find patterns...") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } store := cfg.PasswordStore() terms := fs.Args() pattern := "*" + strings.Join(terms, "*|*") + "*" find := exec.Command( "tree", "-C", "-l", "--noreport", "--prune", // tree>=1.5 "--matchdirs", // tree>=1.7 "--ignore-case", // tree>=1.7 "-P", pattern, store.Path) find.Stdout = cfg.WriterOutput() find.Stderr = cfg.WriterError() find.Run() return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/generate/000077500000000000000000000000001324315324400226415ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/generate/generate.go000066400000000000000000000050371324315324400247670ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package generate import ( "flag" "fmt" "io/ioutil" "strconv" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" gopass_terminal "github.com/aviau/gopass/cmd/gopass/internal/terminal" "github.com/aviau/gopass/internal/pwgen" ) //ExecGenerate runs the "generate" command. func ExecGenerate(cfg command.Config, args []string) error { var noSymbols, n bool var force, f bool var help, h bool fs := flag.NewFlagSet("generate", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), `Usage: gopass generate [--no-symbols,-n] [--force,-f] pass-name pass-length`) } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&noSymbols, "no-symbols", false, "") fs.BoolVar(&n, "n", false, "") fs.BoolVar(&force, "force", false, "") fs.BoolVar(&f, "f", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } noSymbols = noSymbols || n force = force || f passName := fs.Arg(0) store := cfg.PasswordStore() if containsPassword, _ := store.ContainsPassword(passName); containsPassword && !force { if !gopass_terminal.AskYesNo(cfg.WriterOutput(), fmt.Sprintf("Password \"%s\" already exists. Would you like to overwrite? [y/n] ", passName)) { return nil } } passLength, err := strconv.ParseInt(fs.Arg(1), 0, 64) if err != nil { return fmt.Errorf("second argument must be an int, got \"%s\"", fs.Arg(1)) } runes := append(pwgen.Alpha, pwgen.Num...) if !noSymbols { runes = append(runes, pwgen.Symbols...) } password := pwgen.RandSeq(int(passLength), runes) if err := store.InsertPassword(passName, password); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Password \"%s\" added to the store.\n", passName) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/git/000077500000000000000000000000001324315324400216325ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/git/git.go000066400000000000000000000023741324315324400227520ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package git import ( "os/exec" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecGit runs the "git" command. func ExecGit(cfg command.Config, args []string) error { store := cfg.PasswordStore() gitArgs := []string{ "--git-dir=" + store.GitDir, "--work-tree=" + store.Path} gitArgs = append(gitArgs, args...) git := exec.Command( "git", gitArgs...) git.Stdout = cfg.WriterOutput() git.Stderr = cfg.WriterError() git.Stdin = cfg.ReaderInput() git.Run() return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/grep/000077500000000000000000000000001324315324400220045ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/grep/grep.go000066400000000000000000000032141324315324400232700ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package grep import ( "flag" "fmt" "regexp" "strings" "github.com/mgutz/ansi" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecGrep runs the "grep" command. func ExecGrep(cfg command.Config, args []string) error { fs := flag.NewFlagSet("grep", flag.ExitOnError) fs.Parse(args) pattern, _ := regexp.CompilePOSIX(fs.Arg(0)) store := cfg.PasswordStore() passwords := store.GetPasswordsList() for _, password := range passwords { decryptedPassword, _ := store.GetPassword(password) lines := strings.Split(decryptedPassword, "\n") output := "" for _, line := range lines { result := pattern.FindAllString(line, -1) if len(result) > 0 { output += strings.Replace(line+"\n", result[0], ansi.Color(result[0], "red+b"), -1) } } if output != "" { fmt.Fprintf(cfg.WriterOutput(), "%s:\n%s", ansi.Color(password, "cyan+b"), output) } } return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/help/000077500000000000000000000000001324315324400217775ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/help/help.go000066400000000000000000000033071324315324400232610ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package help import ( "fmt" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecHelp runs the "help" command. func ExecHelp(cfg command.Config) error { fmt.Fprintln(cfg.WriterOutput(), `Usage: init Initialize a new password store. ls List passwords. find List passwords that match a string. show Show an encryped password. grep Search for a string in all passwords. insert Insert a new password. edit Edit an existing password. generate Generate a new password. rm Remove a password. mv Move a password. cp Copy a password. git Execute a git command. help Show this text. version Show version information. `) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/init/000077500000000000000000000000001324315324400220125ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/init/init.go000066400000000000000000000035621324315324400233120ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package init import ( "flag" "fmt" "io/ioutil" "path/filepath" "github.com/aviau/gopass" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecInit runs the "init" command. func ExecInit(cfg command.Config, args []string) error { var path, p string var help, h bool fs := flag.NewFlagSet("init", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.StringVar(&path, "path", cfg.PasswordStoreDir(), "") fs.StringVar(&p, "p", "", "") fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), `Usage: gopass init [ --path=sub-folder, -p sub-folder ] gpg-id`) } if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } if p != "" { path = p } path, err := filepath.Abs(path) if err != nil { return err } if fs.NArg() != 1 { fs.Usage() return nil } gpgID := fs.Arg(0) store := gopass.NewPasswordStore(path) if err := store.Init(gpgID); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Successfully created Password Store at \"%s\".\n", path) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/insert/000077500000000000000000000000001324315324400223535ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/insert/insert.go000066400000000000000000000060301324315324400242050ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package insert import ( "flag" "fmt" "io/ioutil" "os" "os/exec" "golang.org/x/crypto/ssh/terminal" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" gopass_terminal "github.com/aviau/gopass/cmd/gopass/internal/terminal" ) //ExecInsert runs the "insert" command. func ExecInsert(cfg command.Config, args []string) error { var multiline, m bool var force, f bool var help, h bool fs := flag.NewFlagSet("insert", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&multiline, "multiline", false, "") fs.BoolVar(&m, "m", false, "") fs.BoolVar(&force, "force", false, "") fs.BoolVar(&f, "f", false, "") fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), `Usage: gopass insert [ --multiline, -m ] [ --force, -f ] pass-name`) } if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } multiline = multiline || m force = force || f pwname := fs.Arg(0) store := cfg.PasswordStore() // Check if password already exists if containsPassword, _ := store.ContainsPassword(pwname); containsPassword && !force { if !gopass_terminal.AskYesNo(cfg.WriterOutput(), fmt.Sprintf("Password \"%s\" already exists. Would you like to overwrite? [y/n] ", pwname)) { return nil } } var password string if multiline { file, _ := ioutil.TempFile(os.TempDir(), "gopass") defer os.Remove(file.Name()) editor := exec.Command(cfg.Editor(), file.Name()) editor.Stdout = os.Stdout editor.Stdin = os.Stdin editor.Run() pwText, _ := ioutil.ReadFile(file.Name()) password = string(pwText) } else { fd := int(os.Stdin.Fd()) for { fmt.Fprintln(cfg.WriterOutput(), "Enter password:") try1, _ := terminal.ReadPassword(fd) fmt.Fprintln(cfg.WriterOutput()) fmt.Fprintln(cfg.WriterOutput(), "Enter confirmation:") try2, _ := terminal.ReadPassword(fd) fmt.Fprintln(cfg.WriterOutput()) if string(try1) == string(try2) { password = string(try1) break } else { fmt.Fprintln(cfg.WriterOutput(), "Passwords did not match, try again...") } } } if err := store.InsertPassword(pwname, password); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Password \"%s\" added to the store.\n", pwname) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/mv/000077500000000000000000000000001324315324400214715ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/mv/mv.go000066400000000000000000000050741324315324400224500ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package mv import ( "flag" "fmt" "io/ioutil" "path/filepath" "strings" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" ) //ExecMv runs the "mv" comand. func ExecMv(cfg command.Config, args []string) error { var force, f bool var help, h bool fs := flag.NewFlagSet("mv", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass mv old-path new-path") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&force, "force", false, "") fs.BoolVar(&f, "f", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } force = force || f store := cfg.PasswordStore() source := fs.Arg(0) dest := fs.Arg(1) if source == "" || dest == "" { return fmt.Errorf("received empty source or dest argument") } // If the dest ends with a '/', then it is a directory. if strings.HasSuffix(dest, "/") { _, sourceFile := filepath.Split(source) dest = filepath.Join(dest, sourceFile) } if sourceIsPassword, _ := store.ContainsPassword(source); sourceIsPassword { if destAlreadyExists, _ := store.ContainsPassword(dest); destAlreadyExists { if !force { return fmt.Errorf("destination \"%s\" already exists. Use -f to override", dest) } } if err := store.MovePassword(source, dest); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Moved password from \"%s\" to \"%s\".\n", source, dest) return nil } if sourceIsDirectory, _ := store.ContainsDirectory(source); sourceIsDirectory { if err := store.MoveDirectory(source, dest); err != nil { return err } fmt.Fprintf(cfg.WriterOutput(), "Moved directory from \"%s\" to \"%s\".\n", source, dest) return nil } return fmt.Errorf("could not find source \"%s\" to copy", source) } gopass-1.2.0/cmd/gopass/internal/cli/command/rm/000077500000000000000000000000001324315324400214655ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/rm/rm.go000066400000000000000000000052311324315324400224330ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package rm import ( "flag" "fmt" "io/ioutil" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" gopass_terminal "github.com/aviau/gopass/cmd/gopass/internal/terminal" ) //ExecRm runs the "rm" command. func ExecRm(cfg command.Config, args []string) error { var recursive, r bool var force, f bool var help, h bool fs := flag.NewFlagSet("rm", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass rm pass-name") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&recursive, "recursive", false, "") fs.BoolVar(&r, "r", false, "") fs.BoolVar(&force, "force", false, "") fs.BoolVar(&f, "f", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } force = force || f recursive = recursive || r store := cfg.PasswordStore() pwname := fs.Arg(0) if pwname == "" { fs.Usage() return nil } if containsPassword, _ := store.ContainsPassword(pwname); containsPassword { if !force { if !gopass_terminal.AskYesNo(cfg.WriterOutput(), fmt.Sprintf("Are you sure you would like to delete %s? [y/n] ", pwname)) { return nil } } if err := store.RemovePassword(pwname); err != nil { return err } } else if containsDirectory, _ := store.ContainsDirectory(pwname); containsDirectory { if !recursive { return fmt.Errorf("\"%s\" is a directory, use -r to remove recursively", pwname) } if !force { if !gopass_terminal.AskYesNo(cfg.WriterOutput(), fmt.Sprintf("Are you sure you would like to delete \"%s\" recursively? [y/n] ", pwname)) { return nil } } if err := store.RemoveDirectory(pwname); err != nil { return err } } else { return fmt.Errorf("could not find password or directory to remove") } fmt.Fprintf(cfg.WriterOutput(), "Removed password/directory at path \"%s\".\n", fs.Arg(0)) return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/show/000077500000000000000000000000001324315324400220275ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/show/show.go000066400000000000000000000040051324315324400233350ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package show import ( "errors" "flag" "fmt" "io/ioutil" "strings" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" "github.com/aviau/gopass/internal/clipboard" ) //ExecShow runs the "show" command. func ExecShow(cfg command.Config, args []string) error { var clip, c bool var help, h bool fs := flag.NewFlagSet("show", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.Usage = func() { fmt.Fprintln(cfg.WriterOutput(), "Usage: gopass show [pass-name]") } fs.BoolVar(&help, "help", false, "") fs.BoolVar(&h, "h", false, "") fs.BoolVar(&clip, "clip", false, "") fs.BoolVar(&c, "c", false, "") if err := fs.Parse(args); err != nil { return err } if help || h { fs.Usage() return nil } clip = clip || c password := fs.Arg(0) if password == "" { return errors.New("missing password name") } store := cfg.PasswordStore() password, err := store.GetPassword(password) if err != nil { return err } if clip { firstPasswordLine := strings.Split(password, "\n")[0] if err := clipboard.CopyToClipboard(firstPasswordLine); err != nil { return err } fmt.Fprintln(cfg.WriterOutput(), "the first line of the password was copied to clipboard.") } else { fmt.Fprintln(cfg.WriterOutput(), password) } return nil } gopass-1.2.0/cmd/gopass/internal/cli/command/version/000077500000000000000000000000001324315324400225345ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/cli/command/version/version.go000066400000000000000000000021001324315324400245410ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package version import ( "fmt" "github.com/aviau/gopass/cmd/gopass/internal/cli/command" "github.com/aviau/gopass/cmd/gopass/internal/version" ) //ExecVersion runs the "version" command. func ExecVersion(cfg command.Config) error { fmt.Fprintf(cfg.WriterOutput(), "gopass v%s\n", version.Version) return nil } gopass-1.2.0/cmd/gopass/internal/cli/cp_test.go000066400000000000000000000026411324315324400214240ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestCpDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"cp", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass cp")) } func TestCpDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"cp", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass cp")) } gopass-1.2.0/cmd/gopass/internal/cli/edit_test.go000066400000000000000000000026551324315324400217540ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestEditDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"edit", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass edit")) } func TestEditDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"edit", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass edit")) } gopass-1.2.0/cmd/gopass/internal/cli/find_test.go000066400000000000000000000026541324315324400217460ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TesFindDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"find", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass find")) } func TestFindDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"find", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass find")) } gopass-1.2.0/cmd/gopass/internal/cli/generate_test.go000066400000000000000000000027051324315324400226150ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestGenerateDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"generate", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass generate")) } func TestGenerateDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"generate", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass generate")) } gopass-1.2.0/cmd/gopass/internal/cli/help_test.go000066400000000000000000000041021324315324400217440ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "init")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "insert")) } func TestDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "init")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "insert")) } func TestDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "init")) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "insert")) } gopass-1.2.0/cmd/gopass/internal/cli/init_test.go000066400000000000000000000026551324315324400217720ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestInitDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"init", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass init")) } func TestInitDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"init", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass init")) } gopass-1.2.0/cmd/gopass/internal/cli/insert_test.go000066400000000000000000000026621324315324400223310ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestInsertHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"insert", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass insert")) } func TestInsertDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"insert", "--h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass insert")) } gopass-1.2.0/cmd/gopass/internal/cli/mv_test.go000066400000000000000000000026411324315324400214440ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestMvDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"mv", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass mv")) } func TestMvDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"mv", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass mv")) } gopass-1.2.0/cmd/gopass/internal/cli/rm_test.go000066400000000000000000000040241324315324400214350ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "os" "path/filepath" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestRmDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"rm", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass rm")) } func TestRmDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"rm", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass rm")) } func TestRmDirectoryWithoutRecursive(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() testDirectoryPath := filepath.Join(cliTest.PasswordStore().Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } err := cliTest.Run([]string{"rm", "dir"}) assert.EqualError(t, err, "\"dir\" is a directory, use -r to remove recursively") } func TestRmUnexistingPassword(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"rm", "dir"}) assert.EqualError(t, err, "could not find password or directory to remove") } gopass-1.2.0/cmd/gopass/internal/cli/show_test.go000066400000000000000000000033211324315324400217760ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestShowDashDashHelp(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"show", "--help"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass show")) } func TestShowDashH(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"show", "-h"}) assert.Nil(t, err) assert.Equal(t, "", cliTest.ErrorWriter.String()) assert.True(t, strings.Contains(cliTest.OutputWriter.String(), "Usage: gopass show")) } func TestShowMissingPassword(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"show"}) assert.EqualError(t, err, "missing password name") assert.Equal(t, cliTest.OutputWriter.String(), "") assert.Equal(t, cliTest.ErrorWriter.String(), "") } gopass-1.2.0/cmd/gopass/internal/cli/version_test.go000066400000000000000000000022061324315324400225040ustar00rootroot00000000000000// Copyright (C) 2017-2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package cli import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/cmd/gopass/internal/version" ) func TestVersion(t *testing.T) { cliTest := newCliTest(t) defer cliTest.Close() err := cliTest.Run([]string{"version"}) assert.Nil(t, err) assert.Equal(t, cliTest.OutputWriter.String(), fmt.Sprintf("gopass v%s\n", version.Version)) } gopass-1.2.0/cmd/gopass/internal/terminal/000077500000000000000000000000001324315324400204755ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/terminal/ask_yes_no.go000066400000000000000000000021241324315324400231550ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package terminal import ( "fmt" "io" ) //AskYesNo asks a Yes/No question to the user and returns the result func AskYesNo(writer io.Writer, question string) bool { fmt.Fprint(writer, question) var response string fmt.Scanln(&response) switch response { case "y", "Y", "yes", "YES": return true default: return false } } gopass-1.2.0/cmd/gopass/internal/version/000077500000000000000000000000001324315324400203475ustar00rootroot00000000000000gopass-1.2.0/cmd/gopass/internal/version/version.go000066400000000000000000000015271324315324400223700ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package version var ( //Version is the current gopass version Version = "1.2.0" ) gopass-1.2.0/cmd/gopass/internal/version/version_test.go000066400000000000000000000020441324315324400234220ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package version_test import ( "testing" "unicode" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/cmd/gopass/internal/version" ) func TestVersionNoLetters(t *testing.T) { for _, character := range version.Version { assert.False(t, unicode.IsLetter(character)) } } gopass-1.2.0/cmd/gopass/main.go000066400000000000000000000021031324315324400163150ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package main import ( "fmt" "os" "github.com/aviau/gopass/cmd/gopass/internal/cli" ) func main() { // Retrieve args and Shift binary name off argument list. args := os.Args[1:] if err := cli.Run(args, os.Stdout, os.Stderr, os.Stdin); err != nil { fmt.Fprintf(os.Stderr, "Error: %s.\n", err) os.Exit(1) } } gopass-1.2.0/internal/000077500000000000000000000000001324315324400146235ustar00rootroot00000000000000gopass-1.2.0/internal/clipboard/000077500000000000000000000000001324315324400165625ustar00rootroot00000000000000gopass-1.2.0/internal/clipboard/clipboard.go000066400000000000000000000023721324315324400210540ustar00rootroot00000000000000// Copyright (C) 2018 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package clipboard import ( "os/exec" ) //CopyToClipboard copies a string to the clipboard using xclip func CopyToClipboard(s string) error { xclip := exec.Command( "xclip", "-in", "-selection", "clipboard", ) stdin, err := xclip.StdinPipe() if err != nil { return err } if err := xclip.Start(); err != nil { return err } _, err = stdin.Write([]byte(s)) if err != nil { return err } if err := stdin.Close(); err != nil { return err } err = xclip.Wait() return err } gopass-1.2.0/internal/gopasstest/000077500000000000000000000000001324315324400170175ustar00rootroot00000000000000gopass-1.2.0/internal/gopasstest/gopasstest.go000066400000000000000000000032271324315324400215460ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopasstest import ( "io/ioutil" "os" "testing" "github.com/aviau/gopass" ) //PasswordStoreTest allows for testing password stores. type PasswordStoreTest struct { PasswordStore *gopass.PasswordStore storePath string t *testing.T } //NewPasswordStoreTest creates a password store for testing func NewPasswordStoreTest(t *testing.T) *PasswordStoreTest { storePath, err := ioutil.TempDir("", "gopass") if err != nil { t.Fatal(err) } passwordStore := gopass.NewPasswordStore(storePath) passwordStore.UsesGit = false if err := passwordStore.Init("test"); err != nil { t.Fatal(err) } passwordStoreTest := PasswordStoreTest{ PasswordStore: passwordStore, storePath: storePath, } return &passwordStoreTest } //Close removes the password store func (test *PasswordStoreTest) Close() { if err := os.RemoveAll(test.storePath); err != nil { test.t.Fatal(err) } } gopass-1.2.0/internal/io/000077500000000000000000000000001324315324400152325ustar00rootroot00000000000000gopass-1.2.0/internal/io/copy.go000066400000000000000000000027671324315324400165470ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package io import ( "io" "os" ) // CopyFileContents copies the contents of the file named src to the file named // by dst. The file will be created if it does not already exist. If the // destination file exists, all it's contents will be replaced by the contents // of the source file. // Credits to 'markc' at stackoverflow (http://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang) func CopyFileContents(src, dst string) (err error) { in, err := os.Open(src) if err != nil { return } defer in.Close() out, err := os.Create(dst) if err != nil { return } defer func() { cerr := out.Close() if err == nil { err = cerr } }() if _, err = io.Copy(out, in); err != nil { return } err = out.Sync() return } gopass-1.2.0/internal/pwgen/000077500000000000000000000000001324315324400157435ustar00rootroot00000000000000gopass-1.2.0/internal/pwgen/pwgen.go000066400000000000000000000025171324315324400174170ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package pwgen import ( "crypto/rand" "math/big" ) //Alpha is a-Z and A-Z var Alpha = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") // Num is 0-9 var Num = []rune("0123456789") //Symbols is all printable symbols var Symbols = []rune("!#$%&'()*+,-./:;<=>?@[]^_`{|}~") //RandSeq returns a random sequence of lenght n func RandSeq(n int, runes []rune) string { b := make([]rune, n) for i := range b { randomInt, err := rand.Int(rand.Reader, big.NewInt(int64(len(runes)))) if err != nil { panic(err) } b[i] = runes[randomInt.Int64()] } return string(b) } gopass-1.2.0/internal/pwgen/pwgen_test.go000066400000000000000000000030711324315324400204520ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package pwgen_test import ( "strings" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/pwgen" ) func TestLength(t *testing.T) { runes := pwgen.Alpha password := pwgen.RandSeq(10, runes) assert.Equal(t, len(password), 10) password = pwgen.RandSeq(30, runes) assert.Equal(t, len(password), 30) } func TestContainsNumsOnly(t *testing.T) { runes := pwgen.Num password := pwgen.RandSeq(50, runes) numsString := string(pwgen.Num) for _, character := range password { assert.True(t, strings.ContainsRune(numsString, character)) } } func TestContainsAlphaOnly(t *testing.T) { runes := pwgen.Alpha password := pwgen.RandSeq(50, runes) numsString := string(pwgen.Alpha) for _, character := range password { assert.True(t, strings.ContainsRune(numsString, character)) } } gopass-1.2.0/man/000077500000000000000000000000001324315324400135625ustar00rootroot00000000000000gopass-1.2.0/man/gopass.1000066400000000000000000000151161324315324400151440ustar00rootroot00000000000000.TH GOPASS 1 "2015 March 29" Alexandre\ Viau "Password Store" .SH NAME gopass - stores, retrieves, generates, and synchronizes passwords securely .SH SYNOPSIS .B gopass [ .I COMMAND ] [ .I OPTIONS ]... [ .I ARGS ]... .SH DESCRIPTION .B gopass is a very simple password store that keeps passwords inside .BR gpg2 (1) encrypted files inside a simple directory tree residing at .IR ~/.password-store . The .B gopass utility provides a series of commands for manipulating the password store, allowing the user to add, remove, edit, synchronize, generate, and manipulate passwords. If no COMMAND is specified, COMMAND defaults to either .B show or .BR ls , depending on the type of specifier in ARGS. Otherwise COMMAND must be one of the valid commands listed below. Several of the commands below rely on or provide additional functionality if the password store directory is also a git repository. If the password store directory is a git repository, all password store modification commands will cause a corresponding git commit. .BR git (1). The \fBinit\fP command must be run before other commands in order to initialize the password store with the correct gpg key id. Passwords are encrypting using the gpg key set with \fBinit\fP. There is a corresponding bash completion script for use with tab completing password names in .BR bash (1). .SH COMMANDS .TP \fBinit\fP [ \fI--path=path\fP, \fI-p path\fP ] \fIgpg-id...\fP Initialize new password storage and use .I gpg-id for encryption. This command must be run first before a password store can be used. Note that use of .BR gpg-agent (1) is recommended so that the batch decryption does not require as much user intervention. .TP \fBls\fP \fIsubfolder\fP List names of passwords inside the tree at .I subfolder by using the .BR tree (1) program. This command is alternatively named \fBlist\fP. .TP \fBgrep\fP \fIsearch-string\fP Searches inside each decrypted password file for \fIsearch-string\fP, and displays line containing matched string along with filename. .TP \fBfind\fP \fIpass-names\fP... List names of passwords inside the tree that match \fIpass-names\fP by using the .BR tree (1) program. This command is alternatively named \fBsearch\fP. .TP \fBshow\fP [ \fI--clip\fP, \fI-c\fP ] \fIpass-name\fP Decrypt and print a password named \fIpass-name\fP. If \fI--clip\fP or \fI-c\fP is specified, do not print the password but instead copy the first line to the clipboard using \fBxclip\fP(1). .TP \fBinsert\fP [ \fI--multiline\fP, \fI-m\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name\fP Insert a new password into the password store called \fIpass-name\fP. This will read the new password from standard in. If \fI--multiline\fP or \fI-m\fP is specified, an editor will be opened for you to type the password. Otherwise, only a single line from standard in is read. Prompt before overwriting an existing password, unless \fI--force\fP or \fI-f\fP is specified. This command is alternatively named \fBadd\fP. .TP \fBedit\fP \fIpass-name\fP Insert a new password or edit an existing password using the default text editor specified by the environment variable \fIEDITOR\fP or using .BR editor as a fallback. This mode makes use of temporary files for editing. .TP \fBgenerate\fP [ \fI--no-symbols\fP, \fI-n\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name pass-length\fP Generate a new password of length \fIpass-length\fP and insert into \fIpass-name\fP. If \fI--no-symbols\fP or \fI-n\fP is specified, do not use any non-alphanumeric characters in the generated password. Prompt before overwriting an existing password, unless \fI--force\fP or \fI-f\fP is specified. .TP \fBrm\fP [ \fI--recursive\fP, \fI-r\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name\fP Remove the password named \fIpass-name\fP from the password store. This command is alternatively named \fBremove\fP or \fBdelete\fP. If \fI--recursive\fP or \fI-r\fP is specified, delete pass-name recursively if it is a directory. If \fI--force\fP or \fI-f\fP is specified, do not interactively prompt before removal. .TP \fBmv\fP [ \fI--force\fP, \fI-f\fP ] \fIold-path\fP \fInew-path\fP Renames the password or directory named \fIold-path\fP to \fInew-path\fP. This command is alternatively named \fBrename\fP. If \fI--force\fP is specified, silently overwrite \fInew-path\fP if it exists. If \fInew-path\fP ends in a trailing \fI/\fP, it is always treated as a directory. .TP \fBcp\fP [ \fI--force\fP, \fI-f\fP ] \fIold-path\fP \fInew-path\fP Copies the password or directory named \fIold-path\fP to \fInew-path\fP. This command is alternatively named \fBcopy\fP. If \fI--force\fP is specified, silently overwrite \fInew-path\fP if it exists. If \fInew-path\fP ends in a trailing \fI/\fP, it is always treated as a directory. .TP \fBgit\fP \fIgit-command-args\fP... If the password store is a git repository, pass \fIgit-command-args\fP as arguments to .BR git (1) using the password store as the git repository. If \fIgit-command-args\fP is \fBinit\fP, in addition to initializing the git repository, add the current contents of the password store to the repository in an initial commit. .TP \fBhelp\fP Show usage message. .TP \fBversion\fP Show version information. .SH FILES .TP .B ~/.password-store The default password storage directory. .TP .B ~/.password-store/.gpg-id Contains the default gpg key identification used for encryption and decryption. Multiple gpg keys may be specified in this file, one per line. .SH ENVIRONMENT VARIABLES .TP .I PASSWORD_STORE_DIR Overrides the default password storage directory. .TP .I EDITOR Text editor to use. .SH SEE ALSO .BR gpg2 (1), .BR git (1), .SH AUTHOR .B gopass was written by .MT alexandre@alexandreviau.net Alexandre Viau .ME . For updates and more information, a project page is available on the .UR http://\:www.github.com/aviau/gopass World Wide Web .UE . .B pass was written by .MT Jason@zx2c4.com Jason A. Donenfeld .ME . For updates and more information, a project page is available on the .UR http://\:www.passwordstore.org/ World Wide Web .UE . .SH COPYING 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 3 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. gopass-1.2.0/password_store.go000066400000000000000000000237321324315324400164230ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass import ( "fmt" "io" "io/ioutil" "os" "os/exec" "path" "path/filepath" "strings" gopassio "github.com/aviau/gopass/internal/io" ) //PasswordStore represents a password store. type PasswordStore struct { Path string //path of the store GitDir string //The path of the git directory GPGBin string //The GPG binary to use GPGID string //The GPG ID used to encrypt the passwords UsesGit bool //Whether or not the store uses git } // NewPasswordStore returns a new password store. func NewPasswordStore(storePath string) *PasswordStore { s := PasswordStore{} s.Path = storePath s.UsesGit = true s.GitDir = path.Join(s.Path, ".git") // Find the GPG bin which := exec.Command("which", "gpg2") if err := which.Run(); err == nil { s.GPGBin = "gpg2" } else { s.GPGBin = "gpg" } //Read the .gpg-id file gpgIDPath := path.Join(s.Path, ".gpg-id") content, _ := ioutil.ReadFile(gpgIDPath) s.GPGID = strings.TrimSpace(string(content)) return &s } //Init creates a Password Store at the Path func (store *PasswordStore) Init(gpgID string) error { //Check if the password path already exists fi, err := os.Stat(store.Path) if err == nil { //Path exists, but is it a directory? if fi.Mode().IsDir() == false { return fmt.Errorf( "could not create password store. Path \"%s\" already exists and it is not a directory", store.Path) } } else { //Error during os.Stat if os.IsNotExist(err) { //Path does not exist, create it if err := os.Mkdir(store.Path, 0700); err != nil { return err } } else { return err } } //Check if the .gpg-id file already exists. gpgIDFilePath := path.Join(store.Path, ".gpg-id") fi, err = os.Stat(gpgIDFilePath) if err == nil { //.gpg-id already exists return fmt.Errorf("there is already a .gpg-id file at \"%s\". Stopping init", gpgIDFilePath) } gpgIDFile, err := os.Create(path.Join(store.Path, ".gpg-id")) if err != nil { return err } defer gpgIDFile.Close() gpgIDFile.WriteString(gpgID + "\n") store.GPGID = gpgID if err := store.git("init"); err != nil { return err } return store.AddAndCommit("initial commit", ".gpg-id") } //InsertPassword inserts a new password or overwrites an existing one func (store *PasswordStore) InsertPassword(pwname, pwtext string) error { containsPassword, passwordPath := store.ContainsPassword(pwname) //Check if password already exists var gitAction string if containsPassword { gitAction = "edited" } else { gitAction = "added" } gpg := exec.Command( store.GPGBin, "-e", "-r", store.GPGID, "--batch", "--use-agent", "--no-tty", "--yes", "-o", passwordPath) stdin, _ := gpg.StdinPipe() io.WriteString(stdin, pwtext) stdin.Close() output, err := gpg.CombinedOutput() if err != nil { return fmt.Errorf("gpg error: \"%s\"", string(output)) } store.AddAndCommit( fmt.Sprintf("%s password \"%s\"", gitAction, pwname), passwordPath) return nil } //RemoveDirectory removes the directory at the given path func (store *PasswordStore) RemoveDirectory(dirname string) error { containsDirectory, directoryPath := store.ContainsDirectory(dirname) if !containsDirectory { return fmt.Errorf("could not find directory at path \"%s\"", directoryPath) } if err := os.RemoveAll(directoryPath); err != nil { return err } store.AddAndCommit( fmt.Sprintf("removed directory \"%s\" from the store", dirname), directoryPath) return nil } //RemovePassword removes the password at the given path func (store *PasswordStore) RemovePassword(pwname string) error { containsPassword, passwordPath := store.ContainsPassword(pwname) if !containsPassword { return fmt.Errorf("could not find password at path \"%s\"", passwordPath) } os.Remove(passwordPath) store.AddAndCommit( fmt.Sprintf("removed password \"%s\" from the store", pwname), passwordPath) return nil } //MoveDirectory moves a directory from source to dest func (store *PasswordStore) MoveDirectory(source, dest string) error { containsDirectory, sourceDirectoryPath := store.ContainsDirectory(source) if !containsDirectory { return fmt.Errorf("could not find directory at path \"%s\"", sourceDirectoryPath) } destDirectoryPath := path.Join(store.Path, dest) if err := os.Rename(sourceDirectoryPath, destDirectoryPath); err != nil { return err } store.AddAndCommit( fmt.Sprintf("moved directory \"%s\" to \"%s\"", source, dest), sourceDirectoryPath, destDirectoryPath) return nil } //MovePassword moves a passsword or directory from source to dest. func (store *PasswordStore) MovePassword(source, dest string) error { containsPassword, sourcePasswordPath := store.ContainsPassword(source) if !containsPassword { return fmt.Errorf("could not find password path \"%s\"", sourcePasswordPath) } // If the dest ends with a '/', then it is a directory. var destPasswordPath string if strings.HasSuffix(dest, "/") { _, file := filepath.Split(sourcePasswordPath) destPasswordPath = path.Join(store.Path, dest, file) } else { destPasswordPath = path.Join(store.Path, dest+".gpg") } if err := os.Rename(sourcePasswordPath, destPasswordPath); err != nil { return err } store.AddAndCommit( fmt.Sprintf("moved Password \"%s\" to \"%s\"", source, dest), sourcePasswordPath, destPasswordPath) return nil } //CopyPassword copies a password from source to dest func (store *PasswordStore) CopyPassword(source, dest string) error { containsPassword, sourcePasswordPath := store.ContainsPassword(source) if !containsPassword { return fmt.Errorf("could not find password or at path \"%s\"", sourcePasswordPath) } // If the dest ends with a '/', then it is a directory. var destPasswordPath string if strings.HasSuffix(dest, "/") { _, file := filepath.Split(sourcePasswordPath) destPasswordPath = path.Join(store.Path, dest, file) } else { destPasswordPath = path.Join(store.Path, dest+".gpg") } if err := gopassio.CopyFileContents(sourcePasswordPath, destPasswordPath); err != nil { return err } store.AddAndCommit( fmt.Sprintf("copied Password \"%s\" to \"%s\"", source, dest), destPasswordPath) return nil } //CopyDirectory copies a directory from source to dest func (store *PasswordStore) CopyDirectory(source, dest string) error { containsDirectory, sourceDirectoryPath := store.ContainsDirectory(source) if !containsDirectory { return fmt.Errorf("could not find directory at path \"%s\"", path.Join(store.Path, source)) } destDirectoryPath := path.Join(store.Path, dest) if err := exec.Command("cp", "-r", sourceDirectoryPath, destDirectoryPath).Run(); err != nil { return err } store.AddAndCommit( fmt.Sprintf("copied directory \"%s\" to \"%s\"", source, dest), destDirectoryPath) return nil } //GetPassword returns a decrypted password func (store *PasswordStore) GetPassword(pwname string) (string, error) { containsPassword, passwordPath := store.ContainsPassword(pwname) //Error if the password does not exist if containsPassword == false { return "", fmt.Errorf("could not find password \"%s\" at path \"%s\"", pwname, passwordPath) } //TODO: Use GPG lib instead show := exec.Command(store.GPGBin, "--quiet", "--batch", "--use-agent", "-d", passwordPath) output, err := show.CombinedOutput() if err != nil { return "", err } return strings.TrimSpace(string(output)), nil } //ContainsPassword returns whether or not the store contains a password with this name. //it also conveniently returns the password path that was checked func (store *PasswordStore) ContainsPassword(pwname string) (bool, string) { passwordPath := path.Join(store.Path, pwname+".gpg") if _, err := os.Stat(passwordPath); os.IsNotExist(err) { return false, passwordPath } return true, passwordPath } //ContainsDirectory returns whether or not the store contains a directory with this name. //it also conveniently returns the directory path that was checked func (store *PasswordStore) ContainsDirectory(dirname string) (bool, string) { directoryPath := path.Join(store.Path, dirname) if _, err := os.Stat(directoryPath); os.IsNotExist(err) { return false, directoryPath } return true, directoryPath } //GetPasswordsList returns a list of all the passwords func (store *PasswordStore) GetPasswordsList() []string { var list []string var scan = func(path string, fileInfo os.FileInfo, inpErr error) (err error) { if strings.HasSuffix(path, ".gpg") { _, file := filepath.Split(path) password := strings.TrimSuffix(file, ".gpg") list = append(list, password) } return } filepath.Walk(store.Path, scan) return list } //AddAndCommit adds paths to the index and creates a commit func (store *PasswordStore) AddAndCommit(message string, paths ...string) error { store.git("reset") for _, path := range paths { store.git("add", path) } store.git("commit", "-m", message) return nil } //git executes a git command func (store *PasswordStore) git(args ...string) error { if !store.UsesGit { return nil } gitArgs := []string{ "--git-dir=" + store.GitDir, "--work-tree=" + store.Path} gitArgs = append(gitArgs, args...) git := exec.Command("git", gitArgs...) //Should we do that? git.Stdout = os.Stdout git.Stderr = os.Stderr git.Stdin = os.Stdin if err := git.Run(); err != nil { fmt.Println(err.Error()) return fmt.Errorf("git error: \"%s\"", err.Error()) } return nil } gopass-1.2.0/password_store_contains_directory_test.go000066400000000000000000000042521324315324400234400ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestContainsDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() containsDirectory, _ := st.PasswordStore.ContainsDirectory("dir") assert.False(t, containsDirectory, "The password store should contain dir") testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "the directory should have been created") containsDirectory, _ = st.PasswordStore.ContainsDirectory("dir") assert.True(t, containsDirectory, "The password store should contain dir") } func TestContainsDirectoryTrailingSlash(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() containsDirectory, _ := st.PasswordStore.ContainsDirectory("dir") assert.False(t, containsDirectory, "The password store should contain dir") testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "the directory should have been created") containsDirectory, _ = st.PasswordStore.ContainsDirectory("/dir///") assert.True(t, containsDirectory, "The password store should contain dir") } gopass-1.2.0/password_store_contains_password_test.go000066400000000000000000000043361324315324400233010ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestContainsPassword(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() containsPassword, _ := st.PasswordStore.ContainsPassword("test.com") assert.False(t, containsPassword, "The password store should not contain test.com") testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") containsPassword, _ = st.PasswordStore.ContainsPassword("test.com") assert.True(t, containsPassword, "The password store should contain test.com") } func TestContainsPasswordDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() containsPassword, _ := st.PasswordStore.ContainsPassword("test.com") assert.False(t, containsPassword, "The password store should not contain test.com") testDirectoryPath := filepath.Join(st.PasswordStore.Path, "test.com") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "test.com directory should have been created") containsPassword, _ = st.PasswordStore.ContainsPassword("test.com") assert.False(t, containsPassword, "The password store should not a password named test.com") } gopass-1.2.0/password_store_copy_password_test.go000066400000000000000000000047171324315324400224400ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestCopyPassword(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") destPasswordPath := filepath.Join(st.PasswordStore.Path, "test2.com.gpg") _, err = os.Stat(destPasswordPath) assert.True(t, os.IsNotExist(err), "test2.com.gpg should not have been created yet") st.PasswordStore.CopyPassword("test.com", "test2.com") _, err = os.Stat(destPasswordPath) assert.Nil(t, err, "test.com.gpg shoudl have been copied to test2.com.gpg") } func TestCopyPasswordInDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } destPasswordPath := filepath.Join(st.PasswordStore.Path, "dir", "test.com.gpg") _, err = os.Stat(destPasswordPath) assert.True(t, os.IsNotExist(err), "test2.com.gpg should have been created yet") st.PasswordStore.CopyPassword("test.com", "dir/") _, err = os.Stat(destPasswordPath) assert.Nil(t, err, "test.com.gpg shoudl have been copied to dir/test2.com.gpg") } gopass-1.2.0/password_store_get_password_list_test.go000066400000000000000000000027761324315324400233030ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestGetPasswordsList(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() _, err := os.Create(filepath.Join(st.PasswordStore.Path, "test.com.gpg")) if err != nil { t.Fatal(err) } _, err = os.Create(filepath.Join(st.PasswordStore.Path, "test2.com.gpg")) if err != nil { t.Fatal(err) } _, err = os.Create(filepath.Join(st.PasswordStore.Path, "test3")) if err != nil { t.Fatal(err) } passwords := st.PasswordStore.GetPasswordsList() assert.Equal( t, passwords, []string{"test.com", "test2.com"}, "Password list should contain test.com and test2.com", ) } gopass-1.2.0/password_store_move_password_test.go000066400000000000000000000051671324315324400224340ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestMovePassword(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") st.PasswordStore.MovePassword("test.com", "test2.com") _, err = os.Stat(testPasswordPath) assert.True(t, os.IsNotExist(err), "test.com.gpg should no longer exist") destPasswordPath := filepath.Join(st.PasswordStore.Path, "test2.com.gpg") _, err = os.Stat(destPasswordPath) assert.Nil(t, err, "test2.com.gpg should now exist") } func TestMovePasswordInDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") err = os.Mkdir(testDirectoryPath, 0700) if err != nil { t.Fatal(err) } _, err = os.Stat(testDirectoryPath) assert.Nil(t, err, "dir should have been created") destinationPath := filepath.Join(testDirectoryPath, "test.com.gpg") _, err = os.Stat(destinationPath) assert.True(t, os.IsNotExist(err), "destination path should not exist yet") if err = st.PasswordStore.MovePassword("test.com", "dir/"); err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.True(t, os.IsNotExist(err), "test.com.gpg should no longer exist") _, err = os.Stat(destinationPath) assert.Nil(t, err, "dir/test.com.gpg should now exist") } gopass-1.2.0/password_store_new_test.go000066400000000000000000000022531324315324400203260ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass" ) func TestNewPasswordStoreUsesGit(t *testing.T) { storePath, err := ioutil.TempDir("", "gopass") if err != nil { t.Fatal(err) } defer os.RemoveAll(storePath) passwordStore := gopass.NewPasswordStore(storePath) assert.True(t, passwordStore.UsesGit, "UsesGit should be true by default") } gopass-1.2.0/password_store_remove_directory_test.go000066400000000000000000000055151324315324400231220ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestRemoveDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "dir should have been created") if err := st.PasswordStore.RemoveDirectory("dir"); err != nil { t.Fatal(err) } _, err = os.Stat(testDirectoryPath) assert.True(t, os.IsNotExist(err), "dir should have been removed") } func TestRemoveDirectoryTrailingSlash(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "dir should have been created") if err := st.PasswordStore.RemoveDirectory("//dir///"); err != nil { t.Fatal(err) } _, err = os.Stat(testDirectoryPath) assert.True(t, os.IsNotExist(err), "dir should have been removed") } func TestRemoveDirectoryRecursive(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testDirectoryPath := filepath.Join(st.PasswordStore.Path, "dir") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } testPasswordPath := filepath.Join(testDirectoryPath, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") _, err = os.Stat(testDirectoryPath) assert.Nil(t, err, "dir should have been created") if err := st.PasswordStore.RemoveDirectory("dir"); err != nil { t.Fatal(err) } _, err = os.Stat(testDirectoryPath) assert.True(t, os.IsNotExist(err), "dir should have been removed") _, err = os.Stat(testPasswordPath) assert.True(t, os.IsNotExist(err), "test.com.gpg should have been removed") } gopass-1.2.0/password_store_remove_password_test.go000066400000000000000000000047061324315324400227610ustar00rootroot00000000000000// Copyright (C) 2017 Alexandre Viau // // This file is part of gopass. // // gopass 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 3 of the License, or // (at your option) any later version. // // gopass 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 gopass. If not, see . package gopass_test import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/aviau/gopass/internal/gopasstest" ) func TestRemovePassword(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") st.PasswordStore.RemovePassword("test.com") _, err = os.Stat(testPasswordPath) assert.True(t, os.IsNotExist(err), "test.com should have been removed") } func TestRemovePasswordTrailingSlash(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testPasswordPath := filepath.Join(st.PasswordStore.Path, "test.com.gpg") _, err := os.Create(testPasswordPath) if err != nil { t.Fatal(err) } _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "test.com.gpg should have been created") st.PasswordStore.RemovePassword("test.com/") _, err = os.Stat(testPasswordPath) assert.Nil(t, err, "RemovePassword with a trailing slash should not remove a password") } func TestRemovePasswordDirectory(t *testing.T) { st := gopasstest.NewPasswordStoreTest(t) defer st.Close() testDirectoryPath := filepath.Join(st.PasswordStore.Path, "test.com") if err := os.Mkdir(testDirectoryPath, 0700); err != nil { t.Fatal(err) } _, err := os.Stat(testDirectoryPath) assert.Nil(t, err, "test.com.gpg should have been created") st.PasswordStore.RemovePassword("test.com") _, err = os.Stat(testDirectoryPath) assert.False( t, os.IsNotExist(err), "RemovePassword should not remove directories", ) }