├── .env.sample
├── .gitignore
├── LICENSE.md
├── README.md
├── docs
├── password-retrieval.png
└── shut-up.png
├── package.json
├── passbot.js
├── src
├── index.js
└── lib.js
└── tasks
└── README.md
/.env.sample:
--------------------------------------------------------------------------------
1 | PASSBOT_TOKEN="your-api-token"
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Packages #
2 | ############
3 | # it's better to unpack these files and commit the raw source
4 | # git has its own built in compression methods
5 | *.7z
6 | *.dmg
7 | *.iso
8 | *.jar
9 | *.rar
10 | # *.gz
11 | # *.tar so it uploads test prepackaged app
12 | *.zip
13 |
14 | # OS generated files #
15 | ######################
16 | .DS_Store
17 | .DS_Store?
18 | ._*
19 | .Spotlight-V100
20 | .Trashes
21 | ehthumbs.db
22 | Thumbs.db
23 |
24 | # Project ignores #
25 | ###################
26 | .env
27 | .log
28 | .sass-cache/
29 | .passwords.json
30 | node_modules
31 | npm-debug.log
32 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ### GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2 |
3 | 0. This License applies to any program or other work which contains
4 | a notice placed by the copyright holder saying it may be distributed
5 | under the terms of this General Public License. The "Program", below,
6 | refers to any such program or work, and a "work based on the Program"
7 | means either the Program or any derivative work under copyright law:
8 | that is to say, a work containing the Program or a portion of it,
9 | either verbatim or with modifications and/or translated into another
10 | language. (Hereinafter, translation is included without limitation in
11 | the term "modification".) Each licensee is addressed as "you".
12 |
13 | Activities other than copying, distribution and modification are not
14 | covered by this License; they are outside its scope. The act of
15 | running the Program is not restricted, and the output from the Program
16 | is covered only if its contents constitute a work based on the
17 | Program (independent of having been made by running the Program).
18 | Whether that is true depends on what the Program does.
19 |
20 | 1. You may copy and distribute verbatim copies of the Program's
21 | source code as you receive it, in any medium, provided that you
22 | conspicuously and appropriately publish on each copy an appropriate
23 | copyright notice and disclaimer of warranty; keep intact all the
24 | notices that refer to this License and to the absence of any warranty;
25 | and give any other recipients of the Program a copy of this License
26 | along with the Program.
27 |
28 | You may charge a fee for the physical act of transferring a copy, and
29 | you may at your option offer warranty protection in exchange for a fee.
30 |
31 | 2. You may modify your copy or copies of the Program or any portion
32 | of it, thus forming a work based on the Program, and copy and
33 | distribute such modifications or work under the terms of Section 1
34 | above, provided that you also meet all of these conditions:
35 |
36 | a) You must cause the modified files to carry prominent notices
37 | stating that you changed the files and the date of any change.
38 |
39 | b) You must cause any work that you distribute or publish, that in
40 | whole or in part contains or is derived from the Program or any
41 | part thereof, to be licensed as a whole at no charge to all third
42 | parties under the terms of this License.
43 |
44 | c) If the modified program normally reads commands interactively
45 | when run, you must cause it, when started running for such
46 | interactive use in the most ordinary way, to print or display an
47 | announcement including an appropriate copyright notice and a
48 | notice that there is no warranty (or else, saying that you provide
49 | a warranty) and that users may redistribute the program under
50 | these conditions, and telling the user how to view a copy of this
51 | License. (Exception: if the Program itself is interactive but
52 | does not normally print such an announcement, your work based on
53 | the Program is not required to print an announcement.)
54 |
55 | These requirements apply to the modified work as a whole. If
56 | identifiable sections of that work are not derived from the Program,
57 | and can be reasonably considered independent and separate works in
58 | themselves, then this License, and its terms, do not apply to those
59 | sections when you distribute them as separate works. But when you
60 | distribute the same sections as part of a whole which is a work based
61 | on the Program, the distribution of the whole must be on the terms of
62 | this License, whose permissions for other licensees extend to the
63 | entire whole, and thus to each and every part regardless of who wrote it.
64 |
65 | Thus, it is not the intent of this section to claim rights or contest
66 | your rights to work written entirely by you; rather, the intent is to
67 | exercise the right to control the distribution of derivative or
68 | collective works based on the Program.
69 |
70 | In addition, mere aggregation of another work not based on the Program
71 | with the Program (or with a work based on the Program) on a volume of
72 | a storage or distribution medium does not bring the other work under
73 | the scope of this License.
74 |
75 | 3. You may copy and distribute the Program (or a work based on it,
76 | under Section 2) in object code or executable form under the terms of
77 | Sections 1 and 2 above provided that you also do one of the following:
78 |
79 | a) Accompany it with the complete corresponding machine-readable
80 | source code, which must be distributed under the terms of Sections
81 | 1 and 2 above on a medium customarily used for software interchange; or,
82 |
83 | b) Accompany it with a written offer, valid for at least three
84 | years, to give any third party, for a charge no more than your
85 | cost of physically performing source distribution, a complete
86 | machine-readable copy of the corresponding source code, to be
87 | distributed under the terms of Sections 1 and 2 above on a medium
88 | customarily used for software interchange; or,
89 |
90 | c) Accompany it with the information you received as to the offer
91 | to distribute corresponding source code. (This alternative is
92 | allowed only for noncommercial distribution and only if you
93 | received the program in object code or executable form with such
94 | an offer, in accord with Subsection b above.)
95 |
96 | The source code for a work means the preferred form of the work for
97 | making modifications to it. For an executable work, complete source
98 | code means all the source code for all modules it contains, plus any
99 | associated interface definition files, plus the scripts used to
100 | control compilation and installation of the executable. However, as a
101 | special exception, the source code distributed need not include
102 | anything that is normally distributed (in either source or binary
103 | form) with the major components (compiler, kernel, and so on) of the
104 | operating system on which the executable runs, unless that component
105 | itself accompanies the executable.
106 |
107 | If distribution of executable or object code is made by offering
108 | access to copy from a designated place, then offering equivalent
109 | access to copy the source code from the same place counts as
110 | distribution of the source code, even though third parties are not
111 | compelled to copy the source along with the object code.
112 |
113 | 4. You may not copy, modify, sublicense, or distribute the Program
114 | except as expressly provided under this License. Any attempt
115 | otherwise to copy, modify, sublicense or distribute the Program is
116 | void, and will automatically terminate your rights under this License.
117 | However, parties who have received copies, or rights, from you under
118 | this License will not have their licenses terminated so long as such
119 | parties remain in full compliance.
120 |
121 | 5. You are not required to accept this License, since you have not
122 | signed it. However, nothing else grants you permission to modify or
123 | distribute the Program or its derivative works. These actions are
124 | prohibited by law if you do not accept this License. Therefore, by
125 | modifying or distributing the Program (or any work based on the
126 | Program), you indicate your acceptance of this License to do so, and
127 | all its terms and conditions for copying, distributing or modifying
128 | the Program or works based on it.
129 |
130 | 6. Each time you redistribute the Program (or any work based on the
131 | Program), the recipient automatically receives a license from the
132 | original licensor to copy, distribute or modify the Program subject to
133 | these terms and conditions. You may not impose any further
134 | restrictions on the recipients' exercise of the rights granted herein.
135 | You are not responsible for enforcing compliance by third parties to
136 | this License.
137 |
138 | 7. If, as a consequence of a court judgment or allegation of patent
139 | infringement or for any other reason (not limited to patent issues),
140 | conditions are imposed on you (whether by court order, agreement or
141 | otherwise) that contradict the conditions of this License, they do not
142 | excuse you from the conditions of this License. If you cannot
143 | distribute so as to satisfy simultaneously your obligations under this
144 | License and any other pertinent obligations, then as a consequence you
145 | may not distribute the Program at all. For example, if a patent
146 | license would not permit royalty-free redistribution of the Program by
147 | all those who receive copies directly or indirectly through you, then
148 | the only way you could satisfy both it and this License would be to
149 | refrain entirely from distribution of the Program.
150 |
151 | If any portion of this section is held invalid or unenforceable under
152 | any particular circumstance, the balance of the section is intended to
153 | apply and the section as a whole is intended to apply in other
154 | circumstances.
155 |
156 | It is not the purpose of this section to induce you to infringe any
157 | patents or other property right claims or to contest validity of any
158 | such claims; this section has the sole purpose of protecting the
159 | integrity of the free software distribution system, which is
160 | implemented by public license practices. Many people have made
161 | generous contributions to the wide range of software distributed
162 | through that system in reliance on consistent application of that
163 | system; it is up to the author/donor to decide if he or she is willing
164 | to distribute software through any other system and a licensee cannot
165 | impose that choice.
166 |
167 | This section is intended to make thoroughly clear what is believed to
168 | be a consequence of the rest of this License.
169 |
170 | 8. If the distribution and/or use of the Program is restricted in
171 | certain countries either by patents or by copyrighted interfaces, the
172 | original copyright holder who places the Program under this License
173 | may add an explicit geographical distribution limitation excluding
174 | those countries, so that distribution is permitted only in or among
175 | countries not thus excluded. In such case, this License incorporates
176 | the limitation as if written in the body of this License.
177 |
178 | 9. The Free Software Foundation may publish revised and/or new versions
179 | of the General Public License from time to time. Such new versions will
180 | be similar in spirit to the present version, but may differ in detail to
181 | address new problems or concerns.
182 |
183 | Each version is given a distinguishing version number. If the Program
184 | specifies a version number of this License which applies to it and "any
185 | later version", you have the option of following the terms and conditions
186 | either of that version or of any later version published by the Free
187 | Software Foundation. If the Program does not specify a version number of
188 | this License, you may choose any version ever published by the Free Software
189 | Foundation.
190 |
191 | 10. If you wish to incorporate parts of the Program into other free
192 | programs whose distribution conditions are different, write to the author
193 | to ask for permission. For software which is copyrighted by the Free
194 | Software Foundation, write to the Free Software Foundation; we sometimes
195 | make exceptions for this. Our decision will be guided by the two goals
196 | of preserving the free status of all derivatives of our free software and
197 | of promoting the sharing and reuse of software generally.
198 |
199 | NO WARRANTY
200 |
201 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
202 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
203 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
204 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
205 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
206 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
207 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
208 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
209 | REPAIR OR CORRECTION.
210 |
211 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
212 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
213 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
214 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
215 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
216 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
217 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
218 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
219 | POSSIBILITY OF SUCH DAMAGES.
220 |
221 | END OF TERMS AND CONDITIONS
222 |
223 | How to Apply These Terms to Your New Programs
224 |
225 | If you develop a new program, and you want it to be of the greatest
226 | possible use to the public, the best way to achieve this is to make it
227 | free software which everyone can redistribute and change under these terms.
228 |
229 | To do so, attach the following notices to the program. It is safest
230 | to attach them to the start of each source file to most effectively
231 | convey the exclusion of warranty; and each file should have at least
232 | the "copyright" line and a pointer to where the full notice is found.
233 |
234 | IoT apps dashboard by NetBeast.
235 | Copyright (C) 2015 Netbeast SL.
236 |
237 | This program is free software; you can redistribute it and/or modify
238 | it under the terms of the GNU General Public License as published by
239 | the Free Software Foundation; either version 2 of the License.
240 |
241 | This program is distributed in the hope that it will be useful,
242 | but WITHOUT ANY WARRANTY; without even the implied warranty of
243 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
244 | GNU General Public License for more details.
245 |
246 | You should have received a copy of the GNU General Public License along
247 | with this program; if not, write to the Free Software Foundation, Inc.,
248 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
249 |
250 | ### CONTACT INFO
251 |
252 | http://netbeast.co
253 | staff@netbeast.co
254 |
255 | C/ Roger de Lauria,
256 | Valencia
257 | Spain
258 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # passbot
2 | :package: Slack robot password manager
3 |
4 | > passbot is in a really early stage and all aspects of this documentation are not yet implemented. Those must serve as roadmap.
5 |
6 | Passbot will take your bot name and avatar. It will respond to mentions or direct messages, but will only share passwords to a set of authorised users.
7 |
8 | 
9 |
10 | It gets funny and makes some comments about your team or reacts before certain words. If it gets annoying just tell it to shut up:
11 |
12 | 
13 |
14 |
15 | ## Get started
16 | ```
17 | git clone https://github.com/netbeast/passbot && cd passbot
18 | npm install
19 | npm start -- --token
20 | ```
21 |
22 | If token is not present it will look for a environment variable in `process.env.PASSBOT_TOKEN`.
23 | If you do not have such integration token ready you can get one [here](https://netbeast.slack.com/apps/new/A0F7YS25R-bots).
24 |
25 | It will read passwords from **.passwords.json** on project folder, which is gitignored. If no passwords are found
26 | a error sound like `mec mec mec` will be its answer. You can create it telling passbot to save its first pass.
27 |
28 | It will react before certain expressions even if not mentioned. Those can be added directly chatting with passbot
29 | through slack, like before, or manually on **.expressions.json** file, also on project folder.
30 |
31 | ## Contribute
32 | If you have nodemon installed you can start development mode as:
33 | ```
34 | nodemon passbot.js
35 | ```
36 | Please open an issue or make a Pull Request if you want a new feature to be released! If you please, help me creating mocha tests for bot connection, passwords database and tasks!
37 |
38 | ### tasks
39 | You can ask the bot to perform tasks. By default no tasks are installed. Tasks are javascript single-file programs installed under **./tasks** folder. To ask the bot to execute a task tell him:
40 |
41 | ```
42 | @bb-8 please ...arguments you want to pass it
43 | ```
44 |
--------------------------------------------------------------------------------
/docs/password-retrieval.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netbeast/passbot/e50c50f742d80acfc99e8c73015a1b24e10c665d/docs/password-retrieval.png
--------------------------------------------------------------------------------
/docs/shut-up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netbeast/passbot/e50c50f742d80acfc99e8c73015a1b24e10c665d/docs/shut-up.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "passbot",
3 | "version": "0.0.2",
4 | "description": ":robot_face: slack robot password manager",
5 | "main": "passbot.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node passbot.js",
9 | "dev": "nodemon passbot.js"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/netbeast/passbot.git"
14 | },
15 | "keywords": [
16 | "slack",
17 | "bot",
18 | "robot",
19 | "password",
20 | "manager",
21 | "netbeast",
22 | "iot"
23 | ],
24 | "author": "staff@netbeast.co",
25 | "license": "AGPL-3.0",
26 | "bugs": {
27 | "url": "https://github.com/netbeast/passbot/issues"
28 | },
29 | "homepage": "https://github.com/netbeast/passbot#readme",
30 | "dependencies": {
31 | "botkit": "0.0.5",
32 | "commander": "^2.9.0",
33 | "dotenv": "^2.0.0",
34 | "fs-promise": "^0.3.1"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/passbot.js:
--------------------------------------------------------------------------------
1 | // touch file if it does not exist
2 | const fs = require('fs')
3 | fs.closeSync(fs.openSync('.passwords.json', 'w'))
4 |
5 | // load environment
6 | require('dotenv').config()
7 |
8 | // launch bot
9 | require('./src')
10 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | const Botkit = require('botkit')
2 | const cmd = require('commander')
3 | const helper = require('./lib')
4 |
5 | cmd.option('--token [token]', 'Slack bot integration token').parse(process.argv)
6 |
7 | const PASSBOT_TOKEN = cmd.token || process.env.PASSBOT_TOKEN
8 |
9 | console.log('PASSBOT_TOKEN', PASSBOT_TOKEN)
10 |
11 | const controller = Botkit.slackbot()
12 | const bot = controller.spawn({
13 | token: PASSBOT_TOKEN
14 | })
15 |
16 | bot.startRTM((err, bot, payload) => {
17 | if (err) throw new Error('Could not connect to Slack')
18 | console.log('Bot is online')
19 | })
20 |
21 | controller.on('mention', handle)
22 | controller.on('direct_message', handle)
23 | controller.on('direct_mention', handle)
24 |
25 | function handle (bot, msg) {
26 | const text = msg.text
27 |
28 | if (text.indexOf('shut up') > -1)
29 | return bot.reply('_Entering standby mode..._')
30 |
31 | if (text.indexOf('get password') > -1)
32 | return helper.retrieve(text).then(function (res) { bot.reply(msg, res) })
33 |
34 | if (text.indexOf('save password') > -1)
35 | return helper.store(text).then(function (res) { bot.reply(msg, res) })
36 |
37 | return bot.reply(msg, 'bip bip bip!')
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs-promise')
2 |
3 | module.exports = { retrieve, store }
4 |
5 | function store (input) {
6 | const site = parseSite(input)
7 | const password = parsePassword(input)
8 | console.log('site', site)
9 | return fs.readFile('.passwords.json', 'utf8').then(function (data) {
10 | var passwords
11 | console.log('data', data)
12 | try {
13 | passwords = JSON.parse(data)
14 | } catch (e) {
15 | passwords = {}
16 | }
17 | console.log('all passwords', passwords)
18 | passwords[site] = password
19 | console.log('passwords', passwords)
20 | return fs.writeFile('.passwords.json', JSON.stringify(passwords))
21 | .then(function () {
22 | return '_tweep tweep tweep_'
23 | })
24 | })
25 | .catch(function (err) {
26 | console.trace(err)
27 | return '\`' + err.message + '\`'
28 | })
29 | }
30 |
31 | function retrieve (input) {
32 | const site = parseSite(input)
33 | return fs.readFile('.passwords.json', 'utf8').then(function (data) {
34 | var passwords
35 | try {
36 | passwords = JSON.parse(data)
37 | } catch (e) {
38 | passwords = {}
39 | }
40 | return passwords[site] || '\`!@#$%\`'
41 | })
42 | .catch(function (err) {
43 | console.trace(err)
44 | return '\`' + err.message + '\`'
45 | })
46 | }
47 |
48 | function parseSite (input) {
49 | const words = input.split(' ')
50 | return words[words.lastIndexOf('for') + 1]
51 | }
52 |
53 | function parsePassword (input) {
54 | const words = input.split(' ')
55 | return words[words.lastIndexOf('for') + 2]
56 | }
57 |
--------------------------------------------------------------------------------
/tasks/README.md:
--------------------------------------------------------------------------------
1 | ### tasks
2 | You can ask the bot to perform tasks. By default no tasks are installed. Tasks are javascript (or babel ES6/7) single-file programs
3 | installed under **./tasks** folder. To ask the bot to execute a task tell him:
4 |
5 | ```@bb-8 please ...arguments you want to pass it```
6 |
--------------------------------------------------------------------------------